Jump to content

  • Log In with Google      Sign In   
  • Create Account

Matrix math for OPENGL


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Max   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 October 1999 - 09:38 AM

I've been stuck on this particular routine for a couple of weeks now and I need help.

The routine I need is a function that would calculate a 4x4 rotation matrix in opengl around an arbitrary point (vertex T(x,y,z,w)) based on a previous matrix. Something like

function RotateAroundAoint(point,angx,angy,angz,matrix): matrix.

for example:

glLoadidentity;

gltranslatef(10,-1,5);

glRotatef(20,10,-30);

glGetfloatv(GL_MODELVIEW_MATRIX,@m);

M:=RotateAroundPoint(Vetex(1,2,3,1),10,20,40,M)

GlLoadMatrixfv(@m);

DrawScene;

So if somebody could help me with some code or an precise idea how I could do this I would really appreciated it.


Sponsor:

#2 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 21 October 1999 - 09:38 AM

Are you just doing this for rendering purposes? For stuff like weighed verticies and collision detection, you might need to calculate your own matrix, but for the rendering you should let openGL do it. Right now only GeForce would accelerate it but you still want to keep things in the GL pipeline if possible.

If the order isn't extremely important, you just do the transformation and rotations at the arbitrary point BEFORE your other transformations:


glTranslatef(...)
glRotatef(...) // X-axis
glRotatef(...) // Y-axis
glRotatef(...) // Z-axis

THEN

// from your code
gltranslatef(10,-1,5);
glRotatef(20,10,-30);

and this will achieve the same effect. If you absolutely positively have to rotate around the point after the fact, I believe you could load the matrix into memory, loadIdentity(), perform transformation/ rotation, and then multiply the matrix by the one stored in memory(although I haven't tried it out.)

Good luck.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS