• Advertisement
Sign in to follow this  

urgent help needed - tree from cylinders

This topic is 4647 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
i cant see anything really wrong with the screenshots
perhaps try glTranslatef(0, h*2, 0);

btw aux is old/buggy and should not be used

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
Sign in to follow this  

  • Advertisement