Skip to content

Instantly share code, notes, and snippets.

@zeroeth
Created March 31, 2009 16:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeroeth/88262 to your computer and use it in GitHub Desktop.
Save zeroeth/88262 to your computer and use it in GitHub Desktop.
// called with
[self shape_tree:3 angle:current_rotation leaves:5];
// definition
- (void)shape_tree:(int)depth angle:(GLint)angle leaves:(int)leaves {
double offset = 360/leaves;
for (double i = 0; i <= 360; i+=offset) {
glPushMatrix();
glScalef(0.5, 0.5, 1.0);
glRotatef(i, 0.0f, 0.0f, 1.0f);
glTranslatef(0.7, 0.7, 0.0);
glRotatef(angle, 0.0f, 0.0f, 1.0f);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
if(depth > 1)
{
[self shape_tree:(depth-1) angle:angle leaves:leaves];
}
glPopMatrix();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment