Author: matt
Date: 2010-12-06 07:39:31 -0800 (Mon, 06 Dec 2010)
New Revision: 7961
Log:
Fixed 'Fractal' demo. Tree's were not random at all.
Modified:
branches/branch-1.3/test/fractals.cxx
Modified: branches/branch-1.3/test/fractals.cxx
===================================================================
--- branches/branch-1.3/test/fractals.cxx 2010-12-06 15:14:42 UTC (rev
7960)
+++ branches/branch-1.3/test/fractals.cxx 2010-12-06 15:39:31 UTC (rev
7961)
@@ -312,7 +312,7 @@
/*
* recursive tree drawing thing, fleshed out from class notes pseudocode
*/
-void FractalTree(int level)
+void FractalTree(int level, long level_seed)
{
long savedseed; /* need to save seeds while building tree too */
@@ -328,26 +328,25 @@
glTranslatef(0, 1, 0);
glScalef(0.7, 0.7, 0.7);
- savedseed = (long)((ulong)drand48()*ULONG_MAX);
+ srand48(level_seed+1);
glPushMatrix();
glRotatef(110 + drand48()*40, 0, 1, 0);
glRotatef(30 + drand48()*20, 0, 0, 1);
- FractalTree(level + 1);
+ FractalTree(level + 1, level_seed+4);
glPopMatrix();
- srand48(savedseed);
- savedseed = (long)((ulong)drand48()*ULONG_MAX);
+ srand48(level_seed+2);
glPushMatrix();
glRotatef(-130 + drand48()*40, 0, 1, 0);
glRotatef(30 + drand48()*20, 0, 0, 1);
- FractalTree(level + 1);
+ FractalTree(level + 1, level_seed+5);
glPopMatrix();
- srand48(savedseed);
+ srand48(level_seed+3);
glPushMatrix();
glRotatef(-20 + drand48()*40, 0, 1, 0);
glRotatef(30 + drand48()*20, 0, 0, 1);
- FractalTree(level + 1);
+ FractalTree(level + 1, level_seed+6);
glPopMatrix();
glPopMatrix();
@@ -421,7 +420,7 @@
glPushAttrib(GL_LIGHTING_BIT);
glCallList(TREE_MAT);
glTranslatef(0, -1, 0);
- FractalTree(0);
+ FractalTree(0, TreeSeed);
glPopAttrib();
glPopMatrix();
glEndList();
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit