Programming Assignment 2
CS 45500
Computer Graphics
Fall, 2022

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

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 data structure.

For this assignment, you will define three Model data structures that can be used to build scenes. Then you will use your models to build a sequence of Scene data structures that can be given to the renderer to create a sequence of FrameBuffer data structures. You will then use the sequence of framebuffers to create a movie.

As we have said in class, a Scene is mainly a collection of models positioned in camera space. A Model is a list of vertices in 3-dimensional space (which we call "model 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 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. Each Model is combined with a Vector in a Position object. The vector is used by the renderer to translate every vertex in the model from "model space" to "camera space". This positiones the model where we want it in front of the camera.

In the zip file that are three java source files, P.java, N.java, and W.java. Each of these files defines a sub-class of the Model class (from the scene package). The file P.java is complete. You need to complete the other two files so that each one defines a model that represents the letter of the alphabet the file is named after. You need to determine how many Vertex and LineSegment objects each model needs and then write the code that instantiates those objects and puts them into the model. These are two-dimensional models (all the vertices are in the xy-plane, with z = 0). Make each letter one unit tall (in the y-direction), and one unit wide (in the x-direction).

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

After you have defined your letter models, complete the program Hw2.java that uses your letter models to create an animation that looks like the file Hw2_animation.gif from the zip file (your letters do not have to look exactly like my letters). Your code should move the models by modifying the Vector object associated with each Model object. If we look at the letter N in the animation, it moves 2 units up, then 5 units down and 2.5 units right, then 2 units left, then 1 unit up and 1 unit left, then 1 unit left, then 1 unit up and 1 unit right, and, finally, 1 unit up and 0.5 units right. This brings the P back to where it started (so the animation can cycle through the frames to create a continuous loop). In Hw2.java the three letters have been pushed back into the z = -3 plane, and the view volume, in the z = -3 plane, extends from -3 to 3 along the x-axis, and from -3 to 3 along the y-axis.

After you have Hw2.java working, convert the image frames that your program produces into a real "animation" file. To do this you need to download the following zip file and unzip it to your C:\ directory as the folder C:\ImageMagick-7.1.0-portable-Q8-x64.

ImageMagick-7.1.0-portable-Q8-x64.zip

After you have ImageMagick on your computer, and after you run your program to produce all the animation frames, just double click on the command file ImageMagick.cmd and it should (I hope) use your frames to create an animation file called animation.gif. Double click on your animation file to see your movie.

Turn in a zip file called CS455Hw2Surname.zip (where Surname is your last name) containing your versions of N.java, W.java, Hw2.java, and the animation.gif for Hw2.java. Please do NOT submit the frames for your animation.

This assignment is due Tuesday, September 27.