Welcome to Bodo's HX 541 - 3d graphics page!
Or: How the M&Ms came to RMIT
my Details
Splash Image
Usage
Funcionality (Model and Motion Curves)
Design and Implementation
Miscellaneous
my details are:
Name: Bodo v. Billerbeck
Student ID: 9707969Q
Email: bodob@cs.rmit.edu.au
1. One of the best Shots
2. Usage
To run the program (after it has been compiled), simply type 'ant'.
Command Line arguments are not needed, the motion curves are read from default file names.
All options are executable via simple clicks with the left mouse button.
Most of these options are also executable by obvious keys on the keyboard, like 'f' for toggling the fog.
The user can choose between two different motion curves, or no animation.
One of the main features of my program is the option that the user can specify a certain frame rate, which the program will then try to achieve.
If the desired frame rate is higher than the momentarily one, then the program will increase the number of polygons of the ant, which will in turn slow decrease the frame rate.
But if the frame rate desired is higher, then the number of polygons is decreased until either the frame rate is achieved, or the minimum number of polygons is reached.
To exit, either use the quit option on the glut menu, or press 'esc'.
3. Functionality (Model and Motion Curves)
The program automatically reads the object from the file named 'bugModel.dat'.
The model is stored in the following format:
- an integer showing the level of the part in relation to the lowest level in the hierarchy of the model
- an individual id (integer)
- three floats, which command the translation of the part relative to the parent in the x, y and z directions
- three floats signifying the rotation of the part about the x, y and z axis
- three floats for a further translation AFTER the rotation
- three floats for the scaling of each dimension of the part
- three floats for the colour of the part (in red green blue components)
- one integer specifying which primitive the part is made of (one of either a sphere, a cone, or a cylinder)
- and finally an integer, which specifies the number of polygons relative to the standard number
For instance the instruction to build the front left thigh of the ant:
1
//level one, just one level down from the main part of the and, its belly
21
//part number 21
-0.6 -0.2 0.1
//translation of 0.6 in direction of the negative x, 0.2 in the negative y and 0.1 in the z axis
-200.0 15.0 7.5
//rotation of 200 degrees in clockwise direction about the x axis, with other rotations following
0.0 0.0 -1.0
//further translations
0.09 0.09 1.2
//the part has dimensioning of 9% of the unit length in the x and y directions, and 120% in the z direction
0.0 1.0 0.0
//the colour of the part is completely green, neither red or blue are mixed in
1
//1 specifying a cone
1
//only the usual number of subdivisions for this part
The object is read in hierarchically, that means the main part of the ant first (I chose the belly), and from there on all extremeties
which is done in a recursively manner.
All parts are sorted into a pseudo binary tree (each parent has one sister and one child), where all parts on equal 'distance' from the belly are on the same level,
for instance the feet are on the same level as the fourth cylinder of the antennas, although there is no connection between those parts.
Therefore the belly only has one child (I chose the head), which then has a sister (the abdomen), and a child of it's own (the left eye).
The motion curves are also read from files, for each motion curve there is one.
The way the motion curver are stored in the file and read from them is simialr to the way the object is handled:
- an integer as the part id
- another integer specifying the animation cycle
- three floats for an animated translation
- three floats for a rotation around the three main axis using an animation based on a cos value
- three floats for a rotation around the three main axis using an animation based on a sin value
For instance the animation for the left front thigh, in the file for the animation of the walking ants:
21
//part number 21 (same as in the file for the object)
2
//cycle 2
0.0 0.0 0.0
//no translations
0.0 10.0 0.0
//rotation of 10 degrees anti clockwise around the y axis
-10.0 0.0 0.0
//rotation of 10 degrees clockwise around the x axis
The cycle specifies in which cycle the sin function executes (all other animations are always executed), - either the first (1), the second (2), or never (0).
The animation curves units are then stored differently to the object, namely in a linked list.
This linked list is then stepped through consecutively to the end.
I provided files for two different animations:
In one, the ant is standing in the foreground and just hovering a little, in the other it is chasing an identical ant around a circular path.
A few pictures with the first motion curve:
lots of polygons, but low frame rate
less polygons, but a high frame rate
the same as the first picture, just with a wire frame instead of fully shaded filled polygons
again, lots of polygons and a low frame rate, but this time in wire frame mode
fog disabled
light source disabled
lighting disabled
depth disabled
normalisation disabled
flat shading
And a picture of the second motion curve:
lots of polygons with a low frame rate
4. Design and Implementation
The program I wrote reads in the model and all motion curves from different files and then - after initialising some parameters like the mixed in fog
- recursively visits each node in the tree of the object, while checking the needed animation from the linked list.
5. Miscellaneous