Sign in to follow this  
soaloa

urgent help needed - tree from cylinders

Recommended Posts

hello, this code should generate (recursively) a tree from cylinders. However there are visible problems at higher levels than 2. Some screenshots at http://www.computergames.ro/forum/showthread.php?t=123038 thanks ! void drawCylinders(double r, double h) { if (r <= R_MIN || h <= H_MIN || level >= MAX_LEVEL) return; level++; glPushMatrix(); glTranslatef(0, h, 0); glRotatef(120, 0, 1, 0); glRotatef(45, 0, 0, 1); auxSolidCylinder(r, h); drawCylinders(r * R_DECREASE, h * H_DECREASE); glPopMatrix(); glPushMatrix(); glTranslatef(0, h, 0); glRotatef(240, 0, 1, 0); glRotatef(45, 0, 0, 1); auxSolidCylinder(r, h); drawCylinders(r * R_DECREASE, h * H_DECREASE); glPopMatrix(); //glPushMatrix(); glTranslatef(0, h, 0); //glRotatef(0, 0, 1, 0); glRotatef(45, 0, 0, 1); auxSolidCylinder(r, h); drawCylinders(r * R_DECREASE, h * H_DECREASE); //glPopMatrix(); level--; } void CALLBACK display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //glColor3f (1.0, 1.0, 1.0); glPushMatrix(); glTranslatef (0.0, 0.0, -5.0); glRotatef (angle, 1.0, 1.0, 0.0); auxSolidCylinder(0.75, 2); drawCylinders(0.5, 1); glPopMatrix(); glFlush(); Sleep(10); auxSwapBuffers(); }

Share this post


Link to post
Share on other sites
the problem is visible only at higher iterations in drawCylinders (i uploaded another screenshot that should clarify the situation) and i don't know what i'm doing wrong ...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this