 # translation using my own matrices

I have an object located at the origin and I’m trying to translate it using my own matrix(instead of glTranslate). My matrix looks like this:
float translate = { 1.0, 0.0, 0.0, 5.0,
0.0, 1.0, 0.0,-3.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0 };
Simple right? Well the problem is that I don’t what to do to make it translate my object. I tried using glLoadMatrix and then glMultMatrix, but my object doesn’t move. Am I doing something wrong?

Thanks, Bino

[This message has been edited by Bino (edited 09-12-2000).]

Almost correct.
The order in which the matrices are stored in the array is colunm-wise. Yours is row-wise.

See the image in the glLoadMatrix help here: http://msdn.microsoft.com/library/default.asp?URL=/library/psdk/opengl/legalgl_62pa.htm

So
GLfloat translate =
{
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
5.0, -3.0, 0.0, 1.0
};

should do the trick.
Also look at the glMultMatrix command if you want to integrate your matrix in between some other tansformation calls.

Forget that first question. I have a new one How do I rotate an object using matrices? I how to set up the matrix, but what do I do after that?(Since glMultMatrix doesn’t work anymore) I heard you have to use loops or something like that, is that right?

Thanks, Bino

[This message has been edited by Bino (edited 09-12-2000).]

The opengl call glRotate work this way:

typedef float Matrixf;
void CreateRotateMatrixf (Matrixf mat, float a, float x, float y, float z)
{
float InvSqrt = isqrt (x * x + y * y + z * z);
float Ux = x * InvSqrt,
Uy = y * InvSqrt,
Uz = z * InvSqrt;

``````float sinA = (float) sin (a * PI / 180.0f), cosA = (float) cos (a * PI / 180.0f);
Matrixf SsinA, UUt, ImUUt;

SsinA =	-Uz * sinA;
SsinA =	Uy * sinA;
SsinA =	Uz * sinA;
SsinA =	-Ux * sinA;
SsinA =	-Uy * sinA;
SsinA =	Ux * sinA;

UUt = Ux * Ux;
UUt = Uy * Ux;
UUt = Uz * Ux;
UUt = UUt;
UUt = Uy * Uy;
UUt = Uz * Uy;
UUt = UUt;
UUt = UUt;
UUt= Uz * Uz;

ImUUt = (1 - UUt) * cosA;
ImUUt = -UUt * cosA;
ImUUt = -UUt * cosA;
ImUUt = -UUt * cosA;
ImUUt = (1 - UUt) * cosA;
ImUUt = -UUt * cosA;
ImUUt = -UUt * cosA;
ImUUt = -UUt * cosA;
ImUUt= (1 - UUt) * cosA;

mat	= UUt + ImUUt;
mat	= UUt + ImUUt + SsinA;
mat	= UUt + ImUUt + SsinA;
mat	= 0.0f;
mat	= UUt + ImUUt + SsinA;
mat	= UUt + ImUUt;
mat	= UUt + ImUUt + SsinA;
mat	= 0.0f;
mat	= UUt + ImUUt + SsinA;
mat	= UUt + ImUUt + SsinA;
mat	= UUt + ImUUt;
mat	= 0.0f;
mat	= 0.0f;
mat	= 0.0f;
mat	= 0.0f;
mat	= 1.0f;
``````

}

Use that… it works…