urgent help needed - tree from cylinders

Started by
1 comment, last by soaloa 18 years, 10 months ago
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(); }
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
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 ...

This topic is closed to new replies.

Advertisement