The CreATureS
Creatures
Creating the little creatures that roam around the world was the most difficult part and also the one
that took the most time. They also very vividly illustrate the
development they and I went through (from simple to more
complex). For example, I pretty much hacked them up in the
beginning, just to get them working and reasonably interesting.
Later I was wondering if it was worth it to make them object
oriented, seeing as I would most probably have only one of each
anyway. I decided for it and even though it took some freshening
up on OOP (see George Wells notes for CS2 and.. yes I have to
admit it: Coad's Book on OOP) it made a lot of things very
user-friendly in the end. For example once the CREATURES class was working and the OFFCREATURE correctly
inheriting, each and every OFFCERATURE knew how to move and
setmove. Creating the tower was also easy (new OFFCREATURE
("tower.off")) and there it was with all the methods
for drawing etc.
| The
Worm This was the first creature invented and actually coded the day before we had our lecture on creating and animating animals etc. It is very hardcoded in a way that the transformations of all vertices are done "by hand". In a way this is an optimisation, because the heavy machinery of matrix manipulations stays out of the game. On the other hand it also demonstrates how difficult it can become to manipulate a movement as simple as that of a crawling worm. Having the worm flat also simplified things immensely. When converting the other Creatures to object oriented, the worm kind off got run over. He wasn't compatible enough and so does not appear in the final version of the World. His code is still available as an example of how it can be done, but shouldn't. <Back to Top>
|
![]() |
| The Paperbird This is actually the third creature brought to life, but is mentioned here second, because the latest version of the real creature number two turned out to be more complex than the bird and illustrates more involved concepts. The bird is actually nice, because he is exactly the way I wanted him and he gave me little hassles. With the other creatures I had to play around and the endproduct is not always what I intended initially. It uses the matrix mechanism, but I incorporated some optimisation that I quite like (if I might say so myself). This of all my creatures is the best, when it comes to exploiting its inherent symmetry and geometry. The fact that it is symmetric along its longitudinal axis is reflected by drawing the one half first, applying a glScale (-1.0,0.0,0.0); which is effectively mirroring in the x-direction and then drawing the other half exactly like the first one. The geometry was taken into consideration, when drawing the wings: The different segments are drawn by a recursive function, which refers back to an array of angles between the segments to be able to specify any kind of wingshape. Animating the wings thus reduced to changing the values in the array. <Back to Top>
|
![]() |
| The bouncing Snowman He was originally creature two, but then he looked different. He was just a sphere on a kind of pogo-stick and was generally boring. Since its bouncing movement didn't involve any kind of angular movement (at first anyway) it became obvious, that anything could be put into the place of the pogo-sphere and be compressed and expanded in the same fashion. So I started AC3D up and played around with it. At first the whole issue of getting objects to look the way I wanted them was very cumbersome, but after a while I got used to it. After several versions I decided to just model the head in AC3D and draw the rest of the body with glutSolidspheres. The Problem was that I wanted the head to look pretty and for that I used the following trick. I declared a variable that I could increment and decrement using the keyboard. I would paint all segments in black until the for loop drawing the head would hit the value of my variable, from then on everything would be painted white. By printing out my variable every time, I was able to get the number of faces that belonged to e.g. the nose, the eyes, etc. After establishing that, I built a case statement into the for-loop changing colours at "landmark" iterations. <Back to Top>
|
![]() |
| The Flower-mobile This was born because I started liking playing around with AC3D. I wanted a flower or something to put in my world as one of the required arbitrary objects. One thing let to another and before I knew it, the flower had a skateboard-like chassis. Obviously flowers move around by propelling their head in a circular fashion. I used the same colouring technique as with the Snowman, but reused the information extracted in a more involved way. I knew now what part of the overall structure made up the petals and the main body but I had to get them to rotate. And they just wouldn't with a capital 'W'! Since the loop that iterated through all vertices was enclosed in a glBegin ().. glEnd() block, I had to break up that block in my case statements, do the necessary transformations and start a new block with glBegin. Obviously this technique can be applied anywhere in the switch block and as often as is required, thus providing a mechanism to use any large structure (e.g. an off-file that was read into a single array, as was the case here) and animate its individual components. |
![]() |