I’ve tried to create a matrix class that is useful and that i can understand (as I can’t quite grasp anyone else’s classes).

My matrix class is only designed to be used by opengl commands so I probably won’t need to know a lot to make it work.

I’ve done a lot of groundwork before posting and have read a lot of matrix articles. I’m stuck on one point though.

So far I have a camera and an object matrix. The way I understand this is that the object matrix represents a local coordinate system. It’s translation moves the local coordinate system around in world space. (Mhen multiplied).

I rotate my object around the Z axis(roll) by 45deg then rotate around the Y axis 45 deg(yaw) then tell it to move down the Z axis X units. This seems to squish the object at the object remains on the z plane.

Here are some code samples to show what I’m doing:

inline void CMatrix::Yaw(const float a_Degrees)

{

float Radians = Degrees2Radians(a_Degrees);

float c = Cos(Radians);

float s = Sin(Radians);m[0] = c;

m[2] = -s;

m[8] = s;

m[10] = c;

}

andinline void CMatrix::Forward(const float a_Units)

{

m[12] = m[8] * a_Units + m[12];

m[13] = m[9] * a_Units + m[13];

m[14] = m[10] * a_Units + m[14];

m[15] = m[11] * a_Units + m[15];

}inline void CMatrix::Roll(const float a_Degrees)

{

float Radians = Degrees2Radians(a_Degrees);

float c = Cos(Radians);

float s = Sin(Radians);m[0] = c;

m[1] = s;

m[4] = -s;

m[5] = c;

}and this is how I’d like to use my matrix:

glMatrixMode(GL_MODELVIEW);

CMatrix Camera = -Viewer;

glLoadMatrixf(Camera);

glPushMatrix();

glMultMatrixf(Object1);

glColor3f(0,0,1);

glRotatef(180,0,1,0); //Glut cone is back to front

glutWireCone(0.5,1,10,6);

glPopMatrix();

Can anyone see where I’m going wrong?

I also have another problem with that code while it’s up, I can’t seem to work out how to rotate multiple times. How do I take the rotation I have, then ‘add’ another rotation to it. I assume I’ll need to renormalise at some point. Do I renormalise all the 9 elements together or each vector seperatly?

Many, many thanks. (I really need to work this out.

Chris

[This message has been edited by gimp (edited 02-26-2001).]