Urgent:Matrices....I need help!

Yes I have only the weekend to code so I don´t want to waste all my time with this one.
I want to rotate a vertex by the OpenGl-Rotation-Matrix-myself.I do it this way:

//Types:
typedef vertex float[3];//[0]=x,[1]=y,[2]=z
typedef matrix4x4 float[16];

//Code:
vertex V,vrot;
matrix4x4 M;
glMatrix(GL_MODELVIEW);//is it called glLoadMatrix??,doesn´t´matter…

glRotatef(xrot,…);
glRotatef(yrot,…);

glGetFloatV(GL_MODELVIEW,matrix4x4);

vrot[0]=M[0]*V[0] + M[1]*V[1] + M[2] *V[2];
vrot[1]=M[4]*V[0] + M[5]*V[1] + M[6] *V[2];
vrot[2]=M[8]*V[0] + M[9]*V[1] + M[10]*V[2];

Is this correct?
This seems to give me wrong results,but it is part of another (alot more complex)caculation so I just want to know if this is wrong or not.(It seems that this code is the prob,but I don´t know what is wrong in here)

Please help me fast and thanx in advance,XBTC!

[This message has been edited by XBCT (edited 06-24-2000).]

Here it is:

vrot[0]=M[0]*V[0] + M[4]*V[1] + M[8] *V[2];
vrot[1]=M[1]*V[0] + M[5]*V[1] + M[9] *V[2];
vrot[2]=M[2]*V[0] + M[6]*V[1] + M[10]*V[2];

I’m assuming you just want to rotate it? Otherwise you will have to use the w-component of the vertex and more than the upper 3x3 of the model view matrix.

Thanx alot for your answer!
I think what I did is the notation in the mathematical way.Yours seems to be the correct OpenGl-way(columns-rows swapped).
Thanx again!

P.s.:You´re right,I only want to rotate.
XBTC

[This message has been edited by XBCT (edited 06-24-2000).]

Kinda cool that I helped a “frequent contributor” in the “advanced opengl coding” forum since I’ve only been coding opengl for less than three days =)

Yes it’s interesting…

Well I opened up a tutorial page (unrelated to OpenGL, but about 3D nonetheless) at Planetquake after messing around with an editor for about a week…
( http://www.planetquake.com/gothic )

it’s funny sometimes

[This message has been edited by drakaza (edited 06-24-2000).]

Ceasar:Yeah thanx again(even I don´t know everything,my know of matrices is very weak)!
Drakaza: Don´t seem any connection between your site and my post,but I edit q3-levels myself and your page is really cool!!!

Greets,XBTC!

[This message has been edited by XBCT (edited 06-25-2000).]

XBCT, I was just saying that it’s funny how sometimes, people with the less experience than others know more than others…

I’ve been OpenGL coding for a few months and I STILL don’t get the hang of matrices completely…all of my functions in my code use matrices differently, i mean like flipped around, so i don’t know which ones are right!

But on the other hand, an editor like Q3Rad seems like a simple toy…while others would
argue the opposite to the death.

That’s the connection

It should be noted that OpenGL matrices are not “swapped”. Base vectors are laid out consecutively in memory just as you would expect. The OpenGL Specification uses the mathematically correct column-order notation, not traditionaly used in 3D graphics, along with post-multiplication. Postmultiplying with column-major matrices is equivalent to premultiplying with row-major matrices.

Really, the only thing that is swapped is the notational convention used in the spec.