Jump to content
• Advertisement

Archived

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

OpenGL Matrix math for OPENGL

This topic is 6938 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

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.

Share this post

Share on other sites
Advertisement
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.

Share this post

Share on other sites

• Advertisement
• Advertisement

• Popular Contributors

1. 1
Rutin
29
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 12
• 13
• 11
• 10
• 13
• Forum Statistics

• Total Topics
632954
• Total Posts
3009446
• Who's Online (See full list)

There are no registered users currently online

×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!