Game Development Reference
In-Depth Information
A scaling matrix is very simple to create, as all you have to do is place the scaling
factors required for the x, y, and z axes in the diagonal going from the top left to the
bottom right of the 3 x 3 rotation part of the matrix. All the other cells are left as zero.
Since creating a scaling matrix is so simple, the CIwFMat class does not include
any methods for creating a general scaling matrix. It does however provide some
shortcut methods that make it easy to scale a matrix by the same scaling factor on
each axis. The following code snippet provides an example:
CIwFMat lMat;
lMat.SetRotX(PI / 2.0f);
lMat.ScaleRot(2.0f);
This code will create a rotation matrix of 90 degrees around the x axis and then scale
up just the rotation part of the matrix by a factor of two. You can also choose to scale
up just the translation part of the matrix or both the rotation and translation by using
the ScaleTrans and Scale methods respectively.
3D model animation
Model matrix animation is, of course, extremely important, as without it we would
be unable to orient and move our 3D models in the game world; but on its own it
doesn't make for the most exciting looking game.
Most games require more than this. For example, we might want a human or animal
character to walk, run, jump, or perform some other type of motion. Ideally, we need
a way of making the overall shape of our 3D model change over time.
The following sections explain how we can achieve this.
Using morph targets
A simple approach to 3D model animation is to use morph targets . For this we alter
the vertex positions of our 3D model to yield key frames of the animation. A key
frame is just a particular set of vertex positions for the model that are an important
part of the overall animation, such as the various positions a character's legs move
through as they walk. The key frame also has a time associated with it.
The following diagram shows a very simple example of a stick man raising his
arm. Key Frame 1 at time index 0 seconds has the arm in a lowered position, while
Key Frame 2 at time index 2 seconds has it raised. Each of these key frames can be
thought of as an individually exported 3D model.
 
Search WWH ::




Custom Search