Programming Assignment 2
CS 45500
Computer Graphics
Fall, 2021

This assignment makes use of the files contained in this zip file. This assignment is due Tuesday, October 5.

This assignment and your previous assignment are about the data structures used at the two ends of the 3D graphics rendering pipeline; what goes into the beginning of the pipeline and what comes out of the end of the pipeline. Roughly, what goes into the pipeline is the Scene data structure which describes the geometry of what the renderer should draw. What comes out of the pipeline is the FrameBuffer data structure which holds the pixel image of the scene drawn by the renderer. The previous assignment was about just the FrameBuffer data structure. This assignment is about what goes into the rendering pipeline, the Scene and Model data structures.

For this assignment, you will define several Model data structures that represent fractal shapes and then test your models in an interactive Scene.

As we have said in class, a Scene is a collection of models. A Model is a list of vertices in 3-dimensional space (which we call "camera space") and a list of line segments. Each Vertex contains three doubles (for the x, y, and z coordinates of a point). Each LineSegment contains the (integer) index for each of two Vertex objects from the Model's vertex list. The vertices and line segments combine to form a wireframe shape that we see as a geometric object in the scene.

In the zip file there is a package, fractals, of seven Java source files. Each of those files defines a sub-class of the Model class from the scene package. The files Canopy.java and KochCurve.java are complete. You need to complete the other five files in the package. These are two-dimensional models (all the vertices are in the xy-plane). For each model, you need to determine the Vertex and LineSegment objects that the model needs and then write the code that instantiates those objects and puts them into the model. Use the two completed models to help you figure out how to complete the other five models. Each model in the package has completed Javadocs. The Javadocs include all the formulas that you need to define the fractal shapes.

If you want to see more examples of Model classes, look at the files in the models package in renderer_2.zip. In particular, look at the files Square.java, Circle.java, Cube.java, and Tetrahedron.java, because those are the simplest models.

In the zip file there is a program InteractiveModelsAll.java that instantiates examples of all the fractal models. Use this program to interactively test your definitions of the models. Work on one model at a time. Comment out from InteractiveModelsAll.java the code that instantiates models that you have not completed. The program InteractiveModelsAll.java tests the two completed models first, so you can run InteractiveModelsAll.java even before you write any code.

In the zip file there is a folder called demo which contains a demo version of the completed assignment. Double click on the file hw2_demo.cmd to run the demo program (you may be able to run the program by double clicking on the hw2_demo.jar file).

Fractals are examples of recursive shapes. Like recursive data structures, recursive shapes are best defined using recursive functions. Defining recursive shapes and recursive data structures using recursive functions is often referred to as "structural recursion".

Turn in a zip file called CS455Hw2Surname.zip (where Surname is your last name) containing InteractiveModelsAll.java and your sub folder fractals.

This assignment is due Tuesday, October 5.