View Full Version : Rotation around local axes.(Again)

Micke

10-21-2000, 02:05 AM

Hi , everyone.

Im quite new to OpenGL and have moved from Direct3D retained mode.

I was going to use Immediate mode but OpenGL looks a lot more easy to use.

Now, the problem I have has been posted here before but it didnt help me at all.

I have a spaceship that must be able to rotate freely around all three local axes.

Now everyone says that I must use quaternions , right.

So I went to Gamasutra and find some really lousy text about Qs.

After some trial and error I got it to work , but the result is still the same , no

matter in which order I do the rotations .

As usual I guess that Im doing something wrong here , as usual , but I would really

like someone to explain this to me .

Thanks in advance !

Micke.

CGameProgrammer

10-22-2000, 10:33 PM

Do you mean the world is being rotated around its own origin instead of around the camera's origin?

This happened to me, but I fixed it by calling glRotate *before* calling glTranslate.

Could you send some code ?? It should help us to explain you what is wrong...

Thanks

forget using glRotate use matrices instead.

euler angles dont cut it as youve discovered when u use all 3 axises.

try these two sites they should have a few explanations of matrixs. www.gamedev.net (http://www.gamedev.net) www.flipcode.com (http://www.flipcode.com)

Micke

10-23-2000, 06:08 AM

Hi Zed.

According to the issue about quaternions I read on Gamasutra matrices are no good to use for rotations.

There was something about cumulative errors and gimbal lock.

Ive started using matrices once before but came up with the same result.

Anyway.I will check out your recommended sites.

Thanx :-)

Micke

Originally posted by zed:

forget using glRotate use matrices instead.

euler angles dont cut it as youve discovered when u use all 3 axises.

try these two sites they should have a few explanations of matrixs. www.gamedev.net (http://www.gamedev.net) www.flipcode.com (http://www.flipcode.com)

DFrey

10-23-2000, 08:20 AM

Actually there has been a rather extensive discussion about quaternions vs matrices in news:comp.games.development.programming.algorithms (that discussion might still be available to you depending on your news server's retention) it should still be available via Deja too. They made several good points for and against the use of matrices. But basically it all boiled down to just one major advantage quaternions had over rotation matrices, and that was easy SLERPing. Otherwise matrices can be used for rotation, without gimbal lock even. The drifting can be minimized or eliminated. And matrices in general are useful for much more than just rotations. Quaternions are only useful for rotations, and they only have an advantage when you need to SLERP between two rotations.

Well, with a little bit of poking (not too much, a little), SLERP can easily be done with matrices aswell.

Read the article about quaternions vs matrices, it's really good, http://www.gamedev.net/reference/articles/article1199.asp

Micke

10-24-2000, 07:20 AM

Alright!

Lets say I drop that quaternion thing and go for matrices.

How do I combine those matrices.

Ive tried taking three X,Y,Z rotation matrices and then multiplying them and then applying them to the model.

But the result is still the same as using three glRotate commands.

HELP PLEASE!

Micke.

haust

11-02-2000, 05:41 AM

Well here is my little game main code :

glRotatef(cam.orientation[0], 1.0f, 0.0f, 0.0f);

glRotatef(cam.orientation[1], 0.0f, 1.0f, 0.0f);

glRotatef(cam.orientation[2], 0.0f, 0.0f, 1.0f);

glTranslatef(-cam.pos[0], -cam.pos[1], -cam.pos[2]);

It's something like a quake 3 arena spectator view and all is fine...

Currently the last rotation does nothing as there is no Z rotation. X rotation is for looking up/down and Y rotation is for looking left/right. These rotation values are set with the mouse : x delta move added to Y rotation and y delta move added to X rotation.

With sin and cos you can find the forward direction vector....

By the way : does someone know how to find those rotation values from this direction vector ??

Michael Steinberg

11-02-2000, 05:30 PM

Maybe that is totally wrong.

I consider my space ship as a unity matrix (?) at the beginning. Now, the matrix basically includes the objects axises, as I discovered. So, if the ship rotates around its local x-Axis lets say 15 degrees, the I rotate the y and the z axis around the x-Axis, exactly 15 degrees, that is now the space ships local matrix, which gets mutliplied with the actual Modelview matrix when the spaceship is being drawn.

Is there any logical error?

An what are quaternations? I collected a formula, that creates a rotation matrix, that rotates a vertex around a vector. Isn'T that the way to go?

Oh. Well, If you have the direction vector, simply take the components, an look for the angles which it has in relation to the components of the starting view vector, which could be (0;0;-1) or something similar. Hope I understood your question.

[This message has been edited by Michael Steinberg (edited 11-02-2000).]

Micke

11-07-2000, 10:05 AM

Hi Michael.

I think were getting somewere now.

Your description really should do it.

Maybe you could explain this further for me.Maybe you got a code snippet?

Micke.

MikeC

11-07-2000, 10:24 AM

Bob - just had a look at that gamedev article you mentioned. I agree with most of it, but can't see how she gets around the SLERP issue. Obviously you can slerp vectors without using quats, but how does this solve the issue of how to slerp rotations? (She claims it does, in the mini-FAQ at the end, but doesn't give any details.)

Am I missing something obvious here?

[This message has been edited by MikeC (edited 11-07-2000).]

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.