Jeffrey Dwoskin

332:562: Visualization and Advanced Computer Graphics
Assignment 1 - 10/4/01

" The purpose of this assignment is to re-familiarize yourselves with 3D polygons and simple rendering by building a polygonal viewer with rotation and illumination capabilities. The assignment is broken up into several pieces, with the final assignment due October 4th. The milestone dates (9/20 and 9/27) are guidelines, and each person will be discussing their progress briefly on those dates. The final project presentation is October 4th. You will be discussing your projects in class (1-2 slides) and demonstrating the executable. "

Part 1

" Build a general Vtk application which can display set of polygons, display them in a window. The window must be rotate-able so that the object can be rotated. The initial objects which should be displayed include a sphere and/or any other conic section. Use the functions in Vtk to create these objects. Experiment with adjusting lighting parameters (see Exercise 3.4 in Vtk book, implement all the options). This is the rendering-program "

I chose to model a person's head using VTK primatives. As you can see, The basic components are spheres, cones, and discs which have been translated, streched, resized, colored, and made partially transparent to form the head.

I also added 2 additional light sources, a blue one to the left and a red one to the right

The code was written in tcl using the vtk libraries. The source code is available at

Part 2

" Convert the rendering-program to read in a set of polygons from a file. The polygon format should be in the mesh format discussed in Hill:pg347. Create your own sphere/Cylinder/Cone or any other surface modeling-program (page 326) with a parameter that determines resolution (i.e. do not use the built in Vtk functions for this program). The modeling-program should output a file in the mesh format which can then be read by the rendering-program. "

For this part, I decided to model a cylinder. The modeling program is written in C++ and outputs a vtk mesh file. The rendering program is a vtk tcl script that reads the mesh file and displays the image.

The modeling program takes 3 parameters. First it takes the resolution of the cylinder. This is the number of sides it will have, since it is not a perfect cylinder. The higher we set the resolution, the better quality cylinder we get, however it takes longer to model, and render, and uses more polygons.

The other 2 parameters are the radius and height of the cylinder which are fairly self-explanatory.

In order to model the cylinder, I had to break it up into 3 sections: the top, the sides, and the bottom. Then I had to model each of these pieces with polygons. The sides are simply rectagles and the top and bottom are made of triangles. In the image below I have drawn in (approximate) polygon boundaries onto the resolution=5 cylinder. The vtk mesh format supports polygons with more than 3 sides, however I chose to use only triangles. There are a few reasons for this choice. First, some other mesh formats may only support triangles so conversion is easier. More importantly, with the polygons for the sides and the top modeled as triangles, it should be fairly simple to modify this model to produce a cone instead of a cylinder. For each side, instead of having 2 triangles, I would only need the bottom one and its top vertex would be at the center of the top. The top itself would be unneccessary.

In modeling the cylinder, the first step was to determine the vertices of the top and bottom. To do this, I iterated around the circle from 0 to 2*pi radians (in increments determined by the resolution) and used sin() and cos() to find the x and y coordinates of the vertices. Then the z coordinates for the top was height/2 and the bottom was -height/2. Once I had these points and a center point on both the top and bottom, I constructed the sides with 2 triangles using the 4 vertices that made up that side. I then made another triangle with the top 2 vertices and the top center to make that portion of the top and did the same for the bottom. These 6 triangles form a hollow wedge of the cylinder, and this process was iterated around the cylinder until it was complete.

You can see the source code to the modeling program at In the output directory I have the vtk model files for the resolution examples above as well as individual jpg's for them. I also have a small vtk tcl script that renders the models.

Part 3

" Finishing touches of the program. Be prepared to demonstrate your program. Put any finishing touches, such as a nice user interface/ user input design, etc. Find models from the WEB to import into your program. "

I made this web page and fixed a few small bugs in the modeling code which affected performance.

I also looked for complex vtk models on the web with no success. No one seems to public vtk format models for free. I did however find some obj format models. Therefore, I wrote a perl script that converts .obj files to .vtk format. It is written in perl, called and is available at:

I got some free .obj files from Viewpoint - In order to download them, I had to agree not to republish the models, so I cannot provide them on this site. To try out my model conversion, download the .obj versions of some of their free models.

If you have any questions, feel free to contact me:

Jeffrey Dwoskin