Due 11:30 pm Friday April 30
![]() A lupine, by Karoline Hayes, UT Austin. |
In this project we will draw two-dimensional fractal plants. Part of the project is implementing and using your own transformation matrices; this is so that you'll understand how they are used in OpenGL and other graphics systems. The basic project described below is worth 85 points. To do A-level work, you'll need to go beyond the basic project in some way, to make a more interesting, attractive or realistic plant drawing. There are some suggestions below. |
You may work with a partner on this project.
drawVineSegment {
drawStem
translate(5,0)
drawleaf
}
drawVine(i) {
if (i==0) drawVineSegment
else {
drawVineSegment
reflectX
drawVine(i-1)
}
The plant should include at least leaves and stems, and its structure should include branching as well as rotation and translation.
You may use any of the OpenGL functions for drawing primitives: glBegin(GL_POLYGON), glBegin(GL_TRIANGLES), etc., and you can set colors using glColor3f.
You must specify the transformations used by specifying your own 2D transformation matrices, and loading them into the OpenGL MODELVIEW matrix using the function loadTurtle in the program below. If you need to get the 2D matrix corresponding to the current MODELVIEW matrix (after popping the matrix stack, say) you can use the function getTurtle, also part of the program below.
By loading your matrix into the MODELVIEW matrix, you allow OpenGL to use it to produce the correct world coordinates for each vertex. The OpenGL commands you may NOT use this time are glRotate, glScale, glTranslate, and glMultMatrix. You may (and you probably should) use glPushMatrix and glPopMatrix to manipulate the matrix stack.
Your program should take the recursion depth as an integer
input on the command line. For example,
plant 5
should put up a window and draw the plant corresponding to five
levels of recursion.
Look here for some advice about getting started.
Please take a picture of your best plant, suitable for framing or for display on the class Web page, and save it as a .gif. There are instructions for taking a snapshot of a window on the TA's Web page (follow the pointer to the TA Web page from the old class).
Turn in all the source files of your program, the executable, the Makefile, any input data files, your .gif file, and a plain text documentation file called, using handin. Thanks!