Rotation in space

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

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 on other sites
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 on other sites
I've tried it... You mean using glLoadMatrix()? Shouldn't it be 4x4 matrix?

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]

1. 1
Rutin
49
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• Forum Statistics

• Total Topics
633409
• Total Posts
3011721
• Who's Online (See full list)

There are no registered users currently online

×