CS 351: Assignment #6

Hierarchical Modeling System

Due midnight 20 October 2008 (Monday night)

In this assignment you'll implement a hierachical modeling system in 2D and learn how to build scene graphs using primitives and matrix transforms.


Read the entire assignment before starting. If you don't, bad things will happen.

The Graphics System Specification outlines the functions required for a 2D hierarchical modeling system that allows you to create modules and draw them. You will create a new set of functions for inserting graphics primitives, transforms, and other attributes into an open module. Each function will do approximately the same thing: put an instance of the object, transform, or attribute on the module's list.

As indicated in the graphics spec, the only required visual objects for the modeling system will be points, lines, polylines, and polygons. All of these primitives are described by one or more Point types. The important thing to remember about the insert function for these items is that graphics primitives need to be copied into the module so that the module has a local copy of the points constituting the object. If you do not copy the data into the module, bad things will happen.

The exception to the copy rule is inserting one module into another. In that case, a pointer to the sub-module needs to be stored in the parent. Modules should not be copied when they are inserted into another module. If you make copies of modules, bad things will happen.

The only tricky function to write is the function that actually traverses a Module's list and draws the scene onto the screen. The lectures notes include an algorithm for proper traversal of the scene graph. The most important aspect of the algorithm is how to organize the matrices.

Viewing Transforms

For this assignment, you will only need to have a 2D viewing transform that is specified by the view window in world coordinates and the screen size in pixels. In the next assignment you will be executing a 3D viewing transformation. The graphics specification for this week includes the function Matrix_2DView(Matrix *m, 2DView *view) that takes in the view information stored in 2DView and returns the matrix that generates the view.

Required Images

  1. Run the C code using your system. The program taks up to 3 arguments on the command line.
  2. Create a formation of at least 3 models (starships/planes/trains/cars/whatever) as a hierarchical structure and then create a scene containing at least three formations acting independently.



All writeups should suggest the format of a lab report. They do not have to be long, but need to provide enough information that I have some idea you knew what you were doing.

  1. Abstract: 200 word description (at most) of what you did and a picture to go along with it.
  2. Description of the task, in your own words. Be brief, but write it as though explaining it to a fellow student not in the course.
  3. Description of how you solved the task, including any key equations or algorithms. You should also include algorithms or descriptions of what you did for any extensions. Include pictures here.
  4. More pictures. Please put a caption on each picture explaining something about it. If you have nothing else, give it a name and indicate whose picture it is.
  5. Summary of what you learned.


Put your code files in your handin folder. Send the prof an email with the URL for your writeup (wiki or standard web page) when it's done. In either case, please edit the assignment handin page on the wiki so there is a link to your assignment.