Programming Assignment 2
CS 45500
Computer Graphics
Fall, 2023

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

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 in the model). 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 positions 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 partly done for you. You need to complete it and 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. Make each letter one unit tall (in the y-direction), one unit wide (in the x-direction), and a quarter unit deep (in the z-direction). Each letter should have its base line on the x-axis. The y-axis should touch the left side of each letter. The front face of each letter should be in the plane z = 0. The back face of each letter should be in the plane z = -0.25.

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).

After you have defined your letter models, and before you actually start to work on the animation, write code in Hw2.java that just creates the initial frame of the animation. The three letters should initially have their front faces in the plane z = -1.5. The plane z = -1.5 intersects the camera's view volume in a square that is 3 units wide and tall (the view volume, in the z = -1.5 plane, extends from -1.5 to 1.5 along the x-axis, and from -1.5 to 1.5 along the y-axis.). This square is just wide enough to place the three letters next to each other. First place the three letters next to each other with the x-axis running through the middle of each letter. After you get this image, translate the P up so that it just touches the top of the view volume and translate the W down so that it just touches the bottom of the view volume. That should give you the correct initial positions for the three models. (See the first frame from the sub-folder hw2\animation-frames.)

Your code should move the models by modifying the Vector object associated with each Model object. If we look at the letter P in the animation, it moves 2 units down, then 2 units up. This brings the P back to where it started (so the animation can cycle through the frames to create a continuous loop). The letter W in the animation moves 2 units up, then 2 units down. This brings the W back to where it started. At first, you should write the code that just moves the P and W letters and get them correct. After the P and W are correct, you can start to work on the more difficult N letter.

If you want to see examples of how to move models in an animation, look at the files in the clients_r1 package in renderer_1.zip. In particular, look at OfflineMovie.java and OfflineGRS.java.

The letter N moves up and down and also backwards and forwards. So the letter N really moves around in 3D space. The letter N moves its front face from the plane z = -1.5 to the plane z = -2.5 and then back to the plane z = -1.5. As the letter N initially moves backwards, it moves up until it hits the top of the view volume (when the letter hits the top of the view volume, it should be in the plane z = -2.0), and then it moves down (as it continues to move backwards). When the letter N has its front face in the plane z = -2.5, the letter should be directly behind where it started from. Then the letter starts to move forwards, from z = -2.5 back to z = -1.5. As the letter starts to move forwards, it should continue to move downward until it hits the bottom of the view volume (in the plane z = -2.0). Then it should start to move upward and return to where it began.

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.1-20-portable-Q8-x64.

ImageMagick-7.1.1-20-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-7.1.1-20-portable-Q8-x64.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 P.java, N.java, W.java, Hw2.java, and animation.gif. Please do NOT submit the frames for your animation.

This assignment is due Thursday, October 19.