In the last programming project you focused on user interaction to define geometric objects. In this project, the focus is on automatic methods to create geometric objects. In class, we discussed how symmetric objects can be created using profile rotation. In this assignment, your task is to create asymmetric objects that have random variations. You have two options: create fractal trees OR create water waves.
Fractal Trees: There are many objects in nature that have similar geometric structures with random variations between objects. For example, each species of tree has its own branching structure and leaf shape, but the branches on each individual tree appear to have random sizes and positions.
Your task is to write a recursive function to create fractal trees by combining cylinders of different sizes and angles to create the tree trunk and branches. The "fractal rules" that control the look of the tree specify how much thinner/shorter the branches are then the trunk, and the average angle between the branches and the trunk. A random number generator is typically called to obtain random variations on the thickness/length/angle of branches.
Water Waves: Simulation of waves in water is another area where automatic techniques are essential. In open water, waves are caused by variations in winds blowing over the water. Near the shoreline, the water depth effects how waves change shape and break. Waves are also created by other objects such as boats moving through the water or reflections off other objects.
Your task is to write a program that creates a "deep water" wave surface. The easiest way to do this is to combine a collection of random sine waves together to define a 2D mesh of water elevations. You can make the water look rough or smooth by adjusting the amplitude and frequency of the sine waves. You can also adjust the wave direction by rotating your 2D sine waves before you combine them. To make your wave surface look real, you need to add some random variations to each of these sine parameters.
Fractal Trees: Before jumping into a 3D fractal tree model, it may be helpful to consider 2D fractal trees. In this case, the trunk and each branch can be represented using a single polygon, and all you need to work on in the recursive function is how to change in branch thickness, length, and angle. When you go to 3D, you need to display each branch using a 3D cylinder, which you can create by scaling and rotating a "unit cylinder". In order to actually "see" the branches, you need to display polygons in different colors. The easiest option at this point would be to base the color on the branch thickness, length or angle somehow. Eventually, we will learn how to make "smooth shaded" images of these cylinders. We have not spoken about leaves, so lets pretend it is fall and all the leaves have fallen.
Water Waves: There are a number of important design decisions involved in creating a water wave model. First of all, how will you represent the 2D mesh of water elevations, and how will this be used to create OpenGL polygons. Second, how will you choose the number of waves to combine, and their respective amplitudes, frequencies, and directions. Finally, in order to actually "see" the waves, we need to display polygons in different colors. One option is to base the colors of polygon vertices on wave elevations. Another option is to calculate the surface normal at each point on the mesh and base the color on the dot product of the normal and the light direction (brighter colors when the normal is pointing towards the light, and darker colors when facing away from the light).
You can implement this program using either a bottom-up approach or a top-down approach. If you go for a bottom-up approach, start by creating basic methods and classes, and test theses methods using a simple main program that calls each method. When this is working, you can create the main program that uses these methods to solve the problem above.
If you go for a top-down approach, start by creating your main program that reads user input, and calls empty methods to pretend to solve the problem. Then add in the code for these methods one at a time. This way, you will get an idea of how the whole program will work before you dive into the details of implementing each method and class.
Regardless of which technique you choose to use, you should develop your code incrementally adding code, compiling, debugging, a little bit at a time. This way, you always have a program that "does something" even if it is not complete.
Test your program to check that it operates correctly for all of the requirements listed above. Also check for the error handling capabilities of the code. Try your program on 2-3 input documents, and save your testing output in text files for submission on the program due date.
When you have completed your C++ program, write a short report (less than one page long) describing what the objectives were, what you did, and the status of the program. Does it work properly for all test cases? Are there any known problems? Save this report in a separate text file to be submitted electronically.
In this class, we will be using electronic project submission to make sure that all students hand their programming projects and labs on time, and to perform automatic analysis of all programs that are submitted. When you have completed the tasks above go to the class web site to "submit" your documentation, C++ program, and testing files.
The dates on your electronic submission will be used to verify that you met the due date above. All late projects will receive reduced credit (50% off if less than 24 hours late, no credit if more than 24 hours late), so hand in your best effort on the due date.
You should also PRINT a copy of these files and hand them into your teaching assistant in your next lab. Include a title page which has your name and uaid, and attach your hand written design notes from above.