Last edited 03may2004 by mpfisher@uiuc.edu
Find this document at http://www.ncsa.uiuc.edu/Classes/MATH198/mpfisher

Skel++: An upgrade of illiSkel
Michael Fisher


Abstract

The illiSkel is a skeleton application that is designed to be extended by students. Before starting my project, the illiSkel was written in C and included a number of precompiler macros that enable BASIC-like syntax to be used. But most modern programming is done with object-oriented languages because of their many advantages. The goal for my project is to update the illiSkel. The major update I have done is port the code from C to C++, making extensive use of C++ constructs such as classes, inheritance, and templates. At the same time, I have tried to keep the code simple and understandable. The overall goal of this work is to make the illiSkel easier for future students to understand and extend. My work has included rewriting the entire codebase in an effort to use good coding standards and naming conventions that making reading the code easier.


Code Features

Object Hierarchy

Now each object is encapsulated in its own class. This allows the code related to drawing an object to be separate from the rest of the application. This also allows new object to be added easily and existing objects to be extended. Objects can be individually placed, sized, and rotated on the screen. Objects are allowed to have "child" objects, that are rigidly attached to the parent, yet able to animate relative to the parent if desired. I have included three sample objects: the torus, cube, and tetrahedron.

Lighting

The lighting is the biggest change in how the illiSkel works compared to the C version. The custom lighting called illiLight has been replaced with OpenGL lighting. OpenGL lights are encapsulated in a Light class. I used OpenGL lighting this because this was the easiest way to get object hierarchies to work. Since the objects in a hierarchy don't know their exact location in space, illiLight wouldn't work without significant modification. However, using OpenGL lighting means that objects must tell OpenGL about their normal vectors. Perhaps in the future, illiLight can be put back into illiSkel.

Frame rate counter

There is a class that handles everything related to the frame rate. The counter measures the speed at which frames are drawn, which is important for measuring the performance of graphics applications. The frame rate counter is a spot of incompatibility between the SGIs and Windows. To help reduce this incompatibility, I made a function that returns the current time when running on the SGI or Windows. Now the frame rate counter code and any other code that is time-dependent can be uniform. CurrentTime function is the only place in the code that cares if the system is an SGI or Windows.

Frame rate limiter

This is new to illiSkel. As the name implies, this limits the frame rate of the application. All commercial graphics applications do this to set a maximum rate at which the frames are drawn. The reason you want to do this is because after a certain frame rate, there is no benefit to redrawing any faster. Drawing the extra frames is a waste of CPU processing power and reducing the amount of CPU time available to other applications running on the machine.

Keyboard Input

GLUT sends information about keyboard input to the application, which stores this in a boolean array. Any part of the application, including the object drawing functions, can query about which keys have been pressed. When a query is issued, the application clears its knowledge about that key press so that subsequent queries will only be successful when that key is press again.

Command-line Arguments

Command-line arguments are encapsulated in a class. They are stored in a list of CommandArgument objects. The ease of working with command-line arguments demonstrates the power of object-oriented design.

Overlay (HUD)

The overlay (HUD) is the text that is printed on the screen on top of the graphics. (This was previously known as messages.) I improved the way this is done by creating a function that prints a line of text to the overlay. It is no longer necessary to calculate the coordinates for all the text that gets displayed.

Linked List

I created a simple, templated linked list class as an alternative to STL vectors. Lists are a powerful alternative to arrays that have the advantage of variable size. I used lists in a number of spots in illiSkel, most importantly for keeping track of objects and lights.


Screenshots

Skel++ on SGI
Skel++ displaying a metallic torus, cube, and tetrahedron on the SGI

Skel++ on Windows
Skel++ displaying a metallic torus, cube, and tetrahedron on Windows


Wish List

The following is a list of some possible improvements that can be made. This is for the benefit of anyone wishing to make additional updates to illiSkel.

  • Use GLUT to create window menus that can be used to control the program as an alternative to the keyboard.
  • Use custom lighting calculations when drawing objects instead of the built in OpenGL lighting. Although OpenGL lighting is easy and powerful, custom lighting is a worthwhile intellectual exercise.
  • Create new methods of navigation in addition to "Turn Mode" and "Fly Mode".
  • Add the ability to interact with objects on the screen. This should include being able to select an object with the mouse (or keyboard) and manipulate the selected object's position, size, rotation, color, transparency, etc.
  • Extend the flexibility of keyboard input. Specifically, add in something like SLevy's ability to enter multi-digit numbers as input.
  • Implement more sophisticated rotation for objects. The current rotation scheme only allows easy rotation around a single axis.