Jump to content
  • Advertisement


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.

If you intended to correct an error in the post then please contact us.

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 this post

Link to post
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:


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

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 this post

Link to post
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!

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!