UW Graphics Group

CS 559: Computer Graphics
Fall 2001

CS 559 Home
Calendar Resources Assignments Projects 1 2 3  

Sample Code For Project 3

Note: this is not a complete project, just snippets of the example so you can get some ideas as to how it works. You can try the sample executable. Or read about the project. The complete source code is available as an ZIP archive. Remember, there are rules in using the example program.

Two pieces are probably directly useful: my texture manager (see the texture hints page), and a set of matrix routines (MMatrix.H and MMatrix.cpp). There are some basic drawing utilities too (DrawUtils.H and DrawUtils.cpp).

The two key classes for the project:

  • GrObject - The base class for all objects in the world. Described in GrObject.H. The main thing that is interesting would be the design of objects. You can look at the implementation too (GrObject.cpp), but it is pretty specific, and may not be too easy to understand.
  • Behavior - The base class for thinks that move objects around. Described in Behaviors.H. (you can look at Behaviors.cpp, but its not too interesting)

For some specific examples, you can see my code for...

  • Cars (Cars.H Cars.cpp) - draws very simple cars.
  • Houses (Houses.H, Houses.cpp) - draws some simple buildings
  • Drive (Roads.H, Drive.cpp) - this is a rather complex behavior that implements a network of roads. cars drive around, Stop at the stop signs, ...
    Everything is very random, cars do not avoid rear-ending one another (they always drive on the right side of the road, so there are no head-ons), all intersections are 4-way stops, and turns aren't very realistic.
    Be warned: this is pretty ugly code, and is pretty complicated. View it as an advanced example.

Note: you may use my code for your projects. Be sure to give proper attribution (e.g. a comment at the beginning saying where you got the code, what you did to it, ...).
UW Graphics Group

CS559 Web

Home Resources Assignments Tools  
Calendar Policies Projects 1 2 3   Examples
Copyright (C) 2001 by Michael Gleicher
Last modified: 17:10 Nov 20, 2001