Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

CS 351 - Assignment 6:Hierarchical Modeling System

Elena Kirillova and Titobiloluwa Awe


In this ?project, we implemented a hierarchical modeling system that allowed us to create modules and draw them. We created a new set of functions for inserting graphics primitives, transforms, and other attributes into an open module. After this, we created some interesting images and animations using our hierarchical modeling process.

Task Description

For this project, there were two main parts that we needed to create in order to draw a scene using the hierarchical modeling system. We had to implement the Element_init function and Module_draw function. As indicated in the graphics spec, the only required visual objects for the modeling system were points, lines, polylines, and polygons. Therefore, we implemented these inside of our two major functions.

Solution Description

In order to implement the Element_init function, we had to create a switch statement that took care of each of the required types for this project. Then, inside of the switch statement, we copied the data into the element pointer that we created, set the type and return the element pointer. Then, inside of the Module_insert functions for all the types, we call the Element_init function with the given type and the pointer to the object we want to create. For the Module_draw function, we had to traverse a Module's list and draws the scene onto the screen. If we see a module in the list, we called the Module_draw function recursively using a new GTM and the same VTM. 


Hierarchical modeling system

Here we tested our hierarchical modeling system by drawing a 2D formation of three fighters.

Required Image 1:

Module Cube

Part of our modelling system was Module_cube function, that drew a unit cube, axis-aligned and centered on
zero to the Module. For this project our function supported drawing the cube out of 12 lines, rather then using polygons.

Required Image 2: A Blue Cube

Multiple layers of modules

Here was created a scene, that contained a model with 3 layers of modules. First, Module Cube was made, the a formation of three cubes, then a scene with three formations.

Required Image 3: Scene of three layers of Cubes

Draw Polygons

Here we tested drawing polygons as part of the module.

Required Image 4: 3 X-wing fighters in a loose formation


For this task we created a number of images, where for every other images cubes were translated so that they would move from the base cube outward.

GIF animation of Cubes moving outwards:


In this project we implemented a 2D/3D hierarchical modeling system that allowed us to create and draw modules. A set of functions for inserting graphic primitives, and some other attributes were written as the basis of the system. Each function put an instance of the object, transformed it or attributed on the module's list.

Over the project we gained better familiarity with at least two C-structure:

  • Switch Statement
  • Linked Lists

Most important of all, we learned about hierarchical modeling systems. Comparing the way we were creating scenes in previous projects to the way we are able to create them now, we can see how hierarchical modeling systems help us to manipulate easily the objects in the scene, so then when we want to transform somehow a particular object, like a cube, we do not have to deal with every point or pixel and move them to required position, we can just transform the whole cube itself on a higher-level in one line of code.