This assignment makes use of the files contained in this zip file. This assignment is due Wednesday, February 10.
This assignment and your next assignment are about the two ends of the 3D graphics rendering pipeline; what goes in the beginning of the pipeline and what comes out the end of the pipeline. This assignment is about what goes in the rendering pipeline, the Scene data structure (and assignment 2 will be about what comes out of the graphics pipeline, the FrameBuffer data structure).
Roughly, what goes into a graphics pipeline, the "Scene" data structure, describes the geometry of what the renderer should draw. For this assignment, you will write a program that reads data from a file and builds an appropriate Scene data structure that can be given to the renderer.
As we have said in class, a scene is mainly a collection of models and a model is a collection of line segments in 3-dimensional space. The line segments combine to form the shapes that we see as models in the scene. In the zip file there are several GRS files which are a kind of container for a list of line segments. In this assignment you will write a program that reads the line segment descriptions stored in a GRS file and instantiates LineSegment
objects that get stored in a Model
object contained in a Scene
object which will be rendered to a FrameBuffer
object and then converted to an image file which can be viewed with an image viewer program.
First, let's look a bit at the structure of a GRS file. A GRS file represents a 2-dimensional line drawing in a plane. The line drawing is made up of many "line-strips". Each line-strip represents a continuous curve in a plane. A line-strip is actually a list of points in the plane. The line-strip begins at the first given point and passes through each of the other given points. Each two consecutive points in a line-strip represents a line segment (so a line-strip with 5 points would represent 4 line segments).
A GRS file is a text file. (In the zip file there is a sub folder called grs
that contains several simple GRS files. You should look at the contents of some of those files using a text editor.) The contents of a GRS file are:
As a quick exercise, draw a picture of the geometry represented by the following lines in a GRS file.
sample grs file ********************** 0.0 2.0 2.0 0.0 2 5 0.0 0.0 1.0 0.0 1.0 1.0 1.0 0.0 0.0 0.0 4 1.0 1.0 1.0 2.0 2.0 2.0 2.0 1.0
In the zip file there is a program DrawGRSFile.java
that demonstrates reading and drawing a GRS file.
In the zip file there is a file Part_1.java
that you need to complete. This program is supposed to read three GRS files whose names are on the command line and build a Scene
object containing three Model
objects that represent the data from each of the three GRS files. Each GRS file should be drawn on a different plane in 3-dimensional space. In Part_1.java
there is an outline of what you need to do.
In the zip file there is a executable demo version of this assignment, Part_1_demo.class
, along with a script file, Part_1_demo.cmd
, that executes the demo. The demo program produces an image file, Part_1_demo.ppm
, and your program should produce an image file that looks just like Part_1_demo.ppm
.
The Scene
, Model
, LineSegment
, and Vertex
classes are all defined in the Scene
sub folder of basic_renderer.zip. The appropriate jar
files are already in this assignment's zip file, along with a make file, and script files for running your programs against the jar files.
As you read through an GRS file, you will need to "parse" the data in the file. A GRS file has such a simple structure that parsing it is not difficult. The main tool to use is Java's Scanner class. In particular, look at the following methods.
Turn in a zip file called CS455Hw1Surname.zip
(where Surname
is your last name) containing your version of Part_1.java
.
This assignment is due Wednesday, February 10.