Archived

This topic is now archived and is closed to further replies.

OpenGL Urgent:Matrices....I need help!(OpenGL)

This topic is 6752 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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!

Share on other sites
Looks correct, it matches my vector rotated by a matrice. How ever i do my calcs "manually". So i dont know if its the correct matrix row notation (minor / major)

And you dont initialize the the view matrix.

Edited by - Claus Hansen Ries on June 24, 2000 12:35:23 PM

it took a quick look on the documentation and it says it gets as follows:

a00-a04-a08-a12
a01-a05-a09-a13
a02-a06-a10-a14
a03-a07-a11-a15

so your coloumns are mixed up........"i think they are =)"
try:

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];

Edited by - Claus Hansen Ries on June 24, 2000 1:50:53 PM

Share on other sites
Arrgh....Again I forgot that OpenGl does this fu(king row-column-swap.
Thanx alot,this safes me hours of debbuging!
XBTC!

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• Forum Statistics

• Total Topics
633767
• Total Posts
3013737
×