In standard mode:
In modify keyframe mode:
All keyframes for my ant model are read in from a data file when the program begins. Also when an ant changes modes, for example from walking to carrying, a key frame file is read to update the keyframes for the new mode. The keyframe files are found in the /keyframes directory.
While the program is being run, keyframes can be modified by pressing "m". The user can then navigate through the data structure (see below for more details on the Hierachical Data Structure) with the number pad, view individual key frames and modify any joint in the structure. When a joint is selected, a trasparent yellow sphere encases the joint. A yellow arrow coming out of the joint indicates the axis of rotation, and the amount of rotation can be modifyed. If there are two axis' of rotation on one joint, the second axis will be white and can be switch to by pressing 5 on the number pad, causing this axis to turn yellow.
Once the user is satified with the changes made to the keyframes, the file can be saved by pressing "w". The next time the program runs, all the keyframes will be updated.
The basis of my design was the structure of each indidual ant. Below shows a diagram of the data structure.
RearThorax
|
|
Tail----FrontThorax----RRLS0----LRLS0----RMLS0----LMLS0
| | | | |
| RRLS1 LRLS1 RMLS1 LMLS1
| | | | |
| RRLS2 LRLS2 RMLS2 LMLS2
| | | | |
| RRLS3 LRLS3 RMLS3 LMLS3
| | | | |
| RRLS4 LRLS4 RMLS4 LMLS4
|
|
Head----RFLS0----LFLS0
| | |
| RFLS1 LFLS1
| | |
| RFLS2 LFLS2
| | |
| RFLS3 LFLS3
| | |
| RFLS4 LFLS4
|
|
LowerRightAntenna----LowerLeftAntenna
| |
UpperRightAntenna UpperLeftAntenna
Note:
RRLS0 = Right Rear Leg Segment 0
RRLS1 = Right Rear Leg Segment 1
etc...
In the diagram, if a node (A) is below another node (B), then A is B's child and B is A's parent. If a node (C) is to the left another node (D), then C is D's previous sibling and D is C's next sibling.
My design ustilises polygon meshes for the head and tail of the ant. Implementing the verticies of these meshes was reasonably easy, but implementing the normals was much more dificult as it involved differentiation and much fiddling before it worked properly.
My design implemented fog. It can be accessed by pressing "f". Much work was needed to implement this feature. Luckily, it wasn't on my part ;)
My design implemented texturemapping on multiple objects:
The ants are very simple creatures with a few goals in life:
Not getting to far away from the mound is implemented by the ants checking that their position is not greater than a predifined amount, if it is they turn around.
Trying not to run into each other is implemented by each ant scanning each other and finding which is the closest. If the other closest ant is too close, then turn away from it.
Picking up food is implemented by scanning each sugar cube and seeing if it within a predifined distance. If it is, rotate towards it, walk towards it, pick it up, rotate towards the ant mound, walk towards the ant mound then once at the ant mound drop it off.