<Junkstyle>, <ioquan>, I see what you mean, but there IS logic to implementing a transformation class - here’s why:

Sure, a single matrix is a collection of transformations, which you can transform points with later - but how do you retain the individual components of those transformations? If you want a model to be rotated the same z-angle as the z-rotation of another model, then you’ll need to store some individual rotation values in the model -> like (model.yRotation) or something.

## If you’re going to do that, then why not define something like this:

typedef float matrix4[16];

// 0 4 8 12

// 1 5 9 13

// 2 6 10 14

// 3 7 11 15

// <junkstyles> matrix example…

class Transformation {

// variables

float xLocal, yLocal, zLocal; // models local translation (pivot)

float xScale, yScale, zScale; // models scale

float xRotation, yRotation, zRotation; // models rotation

float xWorldPos, yWorldPos, zWorldPos; // models world position

matrix4 transformation; // 6 combined transformations

// functions

matrix4 multiply(); // produce the 6 combined transformations

};

## …

matrix4 Transformation::multiply()

{

// create a translation matrix called (localTranslation)

// create a scaling matrix called (scale)

// create a xrotation matrix called (xrotation)

// create a yrotation matrix called (yrotation)

// create a zrotation matrix called (zrotation)

// create a translation matrix called (worldTranslation)

// return (localTranslation * scale * xrotation * yrotation * zrotation * worldTranslation)

}

…

…Then, instead of using OpenGL’s transformations <pseudo snippet>:

// …set the viewing transformation earlier…

glPushMatrix();

glTranslate(xLocal, yLocal, zLocal);

glScale(xScale, yScale, zScale);

glRotate(xRotation, 1, 0, 0);

glRotate(yRotation, 0, 1, 0);

glRotate(zRotation, 0, 0, 1);

glTranslate(xWorldPos, yWorldPos, zWorldPos);

// …draw the verticies…

glPopMatrix();

…you could do <pseudo snippet>:

// …set the viewing transformation earlier…

glPushMatrix();

model.transform.localPosition(xLocal, yLocal, zLocal); // these calls are just simple /

model.transform.scale(xScale, yScale, zScale); // component updates, /

model.transform.rotation(xRotation, yRotation, zRotation); // there is no matrix /

model.transform.worldPosition(xWorldPos, yWorldPos, zWorldPos); // multiplication yet…

model.transform.multiply(); // THIS actually creates a

// composite matrix, of 6

// transformations…

glMultMatrix(model.transform.transformation); // add these transformations to

// the modelview transformation

// …draw the verticies…

glPopMatrix();

…Basically, a Transformation class is just a wrapper for the individual component values, plus the combined transformation matrix. Each model has a Transformation instance, which allows you to keep track of the model’s transformation matrix, plus the actual values which transformed it.

Do you dig it?

BTW. ioquan: how did you load the homer model? What format did you load it from? It looks funky too.