Sunday 8 January 2012

Adding the peeps

The game needs some sort of aim. In the original game, the aim was to abduct the humans standing on top of the buildings. As I'm doing a remake then I may as well keep this as the aim.

All I've done is created a new in game object called a person (extended from my Base3DObject), which is another model to load in.

However, this time around I want the little person to jump up and down and wave their arms around (like in the original). For this I'm going to need to animate my 3D object.

I'm sure there are many ways to animate the 3D objects from using bones and skeletal structures to probably having multiple frames of the object and quickly load them in succession (this seems daft though).

I could have even used the Xbox avatars as the best way to add a human to abduct. I did look into it, but for now I'll keep things simple.

What I'm going to do is animate the individual meshes of the person 3D object.

The person is made up of 6 sub meshes.

1. The head
2. The body
3. The left leg
4. The right leg
5. The left arm
6. The right arm

Up until now, any matrix transformation I've applied to my objects has been applied to all meshes. So if I rotate anything, then everything in the object rotates with it. This is all I've needed up until now as I wanted my entire UFO to rotate.

What I've done is to add another matrix multiplication to the world matrix for each mesh that I want to transform individually.

In this case, I want to rotate the arms of the person so they look as if they are waving.

I found a great link on how to do this (link)

So now I've got my person class and when I render the little fella to screen, he jumps up and down waving his arms.

All I did then was to add an imposed limit to how many could appear on the the map and in the map generation code randomly place my peeps on top of the buildings.

So when the level starts, the map is now littered with little people waiting to get abducted.

No comments:

Post a Comment