This assignment makes use of the files contained in this zip file. This assignment is due Wednesday, October 8.
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
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 wire-frame 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.
Be sure to read the Scene, Model, and Position sections from Renderer_1 Readme.md.
Here is a sketch of what a
When you instantiate a
The first two integer parameters are indices into the Model's
In the zip file there are three Java source files,
Notice that the
If you want to see examples of
After you have defined your letter models, complete the program
After you have defined your letter models, and before you actually start to work on the animation, write code in
The animation has 300 frames (numbered 0 to 299) and is divided into three sections of 100 frames each. In the first section,
In the second 100 frame section,
In the third 100 frame section,
Your code should move the models by modifying the translation
The folder
For more information about creating an animation, read the Position and Animation section from Readme_r1.md.
If you want to see examples of how to move models in an animation, look at the files
You should not change the package structure of the
After your program compiles, you run
The included build script,
If you want the VS Code editor to work correctly with
After you have
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
NOTE: The ImageMagick project updates it distribution fairly often. When it does, the previous distribution's link no longer works. The above link to download their zip file will probably no longer work after a week or two. If the link is broken, go to their download page and find the latest version.
Turn in a zip file called
This assignment is due Wednesday, October 8.
Scene
data structure looks like. Notice how a LineSegment object refers to two List
Scene
/ \
/ \
Camera List<Position>
/ | \
/ | \
Position Position Position
/ \ / \ / \
/ \
/ \
Vector Model
/ | \ / | \
x y z /---/ | \---\
/ | \
/ | \
List<Vertex> List<Color> List<Primitive>
/ | \ / | \ / | \
| | |
Vertex Color LineSegment
/ | \ / | \ / \
x y z r g b / \
List<Integer> List<Integer>
(vertices) (colors)
/ \ / \
/ \ / \
Integer Integer Integer Integer
LineSegment
object, you give the LineSegment
constructor four integer values.
Primitive ls = new LineSegment(2, 3, 1, 0);
Vertex
list. The last two integer parameters are indices into the Model's Color
list.
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
, Color
, 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
. Look at the supplied animation to see how each model's line segments should be colored.
P.java
file begins with a ascii-art drawing showing the numbering of its vertices. This can help a lot when you go to write the LineSegment
constructors. I strongly suggest that you draw your own ascii-art picture for each of your N.java
and W.java
models.
Model
classes, look at the files in the renderer.models_L
package in renderer_1.zip. In particular, look at the files Square.java
, ,
Circle.javaCube.java
, and Tetrahedron.java
, because those are the simplest models. (Models in the renderer.models_L
package do not have any colors build into them. These models expect colors to be added to them after the Model
object is created.)
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 be shaped exactly like my letters, but they should be colored the same way.
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 3 units 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. Place the three letters next to each other with the x-axis running through the middle of each letter. That should give you the correct initial positions for the three models. (See the first frame from the sub-folder hw2\animation-frames
.)
Vector
object associated with each Model
object.
hw2\animation-frames
contains an image file for every frame of the animation so that you can check exactly where each model should be positioned in each frame.
OfflineCube.java
, OfflineCubes.java
, and OfflineMovie.java
in the clients_r1
package in renderer_1.zip.
hw2
folder. The files Hw2.java
, P.java
, N.java
, and W.java
are in the default package of the folder hw2
. Do not give those classes a package statement. All the renderer classes are in the renderer_1.jar
jar file. You compile the Hw2.java
file with the following command-line.
javac -cp .;renderer_1.jar Hw2.java
Hw2
with the following command-line.
java -cp .;renderer_1.jar Hw2
build_&_run_client.cmd
sets the classpath appropriately.
Hw2.java
and renderer_1.jar
, then read the section about VS Code and jar libraries from Renderer_1 Readme.md.
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.2-3-portable-Q8-x64.zip
.
ImageMagick-7.1.2-3-portable-Q8-x64.zip.cmd
and it should use your frames to create an animation file called animation.gif
. Double click on your animation file to see your movie.
CS455Hw2Surname.zip
(where Surname
is your last name) containing just your versions of P.java
, N.java
, W.java
, Hw2.java
, and animation.gif
. Please DO NOT submit the frames for your animation or the folder animation-frames
.