Due: Tuesday, September 25, 2001 (1 week) in the assignment box, before midnight
Add teapot objects to your game:
1. Change the "student.fgd" file to support a new kind of object called a "Teapot" (use uppercase to distinguish it from all the other built in halflife types). Provide it with one of two options: Wireframe or Filled. Now, you can build a worldcraft world with five or six teapots in different places in the world. Make big boxes and small ones. The teapot is expected to match the size of the box. If you don't have "student.fgd" or "student.wad", download it from my site.
2. Add a Teapot class in the builder and the game that keeps track of an
extent (a point keeping a width, height, depth)
position (another point representing the center of the teapot)
style (an enumeration or long for Wireframe versus Filled)
rotation (a double that represents a rotation amount in degrees)
In the game version (not the builder) provide methods called tick () that will increase the rotation amount and draw () that will draw it rotated around the y-axis. The draw can be as simple as
draw() {
glPushMatrix ();
glTranslated (position.x, position.y, position.z);
glScaled (extent.x, extent.y, extent.z);
glRotated (rotation, 0.0, 1.0, 0.0);
CODE TO DRAW THE TEAPOT HERE
glPopMatrix ();
}
3. As you will see, unless you change the builder to do something other than output the faces associated with your Teapot objects, you will not be able to draw the teapots the correct size and at the correct location. For this to happen, you need to change the BUILDER.
First, build a BoundingBox class that maintains a minimum point and a maximum point. Then provide methods that might be used as follows:
BoundingBox *box = new BoundingBox (anInitialGamePoint);
loop over the faces of the Teapot pot
loop over the game points of a face
box->add (currentGamePoint)
endloop
endloop
All the add method does is set
minimum.x = min (minimum.x, aGamePoint.x)
maximum.x = min (maximum.x, aGamePoint.x)
AND SIMILAR CODE FOR y AND z
When you are done, you will have two points that represent the leftmost lowest furthest back point
(minimum) and the rightmost highest most in front point (maximum).
The center is just the average, the extent is just minimum - maximum. This is all the information you need to properly place and draw your teapot the size it is supposed to be. So pass this information along to the game engine (NOT THE FACES).
In the future, this is what this assignment will enable you to do some really neat things. You will be able to find (or write) code that draws trees, or flowers, or fire, or a transporter/teleporter thing that breathes, etc. Then you can create an instance anywhere in your Worldcraft world and your engine/builder will materialize it.