Created
March 31, 2009 16:35
-
-
Save zeroeth/88262 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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