Jump to content
  • Advertisement
Sign in to follow this  
CTPAX

Rotation in space

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

Hi... I have a problem, of course... I'm working on a space game where you have absolute freedom of movement... But, as I've progressed with it, I had couple of problems... First of them I'll ask you if you could help me. I had a problem how to menage control of the movement in space, but after a while I've came up with an idea to have 3 orthonormal vectors, first pointing in the direction of movement, second is actually "up", and the third is to the right of the current position... Now it works great when I want to move... But, there apeeread a new problem that I haven't solved yet... I want to load a model of spacecraft into current position witch should be at the center of the screen. But I can't get it to work because the model is spinning strangely. I've tried it for hours, and I couldnt find a solution how to rotate it correctly. I know that I should use that 3 vectors, I've tried to calculate angles, but nothing worked. I know how to use a trick, but that's not what I want. Btw. I control camera with gluLookAt(). Whanks in advance...

Share this post


Link to post
Share on other sites
Advertisement
If you have three orthogonal and normalized axes you can create a rotation matrix very easy. It's simply just putting each axis on each row of a 3x3 matrix.

Share this post


Link to post
Share on other sites
If you have the right, up and forward vector you can indeed create a rotation matrix.

Opengl's matrix looks like this:

0 4 8 12
1 5 9 13
2 6 10 14
3 7 11 15

cells 0, 4, 8 contain the right vector.
cells 1, 5, 9 contain the up vector.
cells 2, 6, 10 contain the forward vector.
cells 12, 13, 14 contain the translation vector.

to get it to work:

float m[16];
// put your vectors in the array here.
// ...
m[3] = m[7] = m[11] = 0;
m[15] = 1;

glMultMatrixf( m );




[Edited by - Centauri on August 18, 2008 12:57:13 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!