Simple world space rotation?

Started by
22 comments, last by VanKurt 19 years, 6 months ago
@mikeman
That's what I tried all the time. It didn't work! ;-)

@renderer and silvermace

I'll try both of your ideas. Thank's a lot for your help! I'm sure at least one of them is going to work... ;-)
Advertisement
AAAAAAAARGH!!! I'm getting crazy! ;-)

Now I changed the whole System to quarternions to avoid the problem ("gimbal lock"???). But guess what? NOTHING CHANGED :-(

Here's the code:

glPushMatrix();CQuaternion q1( mBalls.mRotX, CVector3(0,0,1) );CQuaternion q2( -mBalls.mRotZ, CVector3(0,1,0) );q1.Normalize();q2.Normalize();CQuaternion q3;q3 = q1*q2;q3.Normalize();float matrix[16];q3.CreateMatrix(matrix);glMultMatrixf( matrix );gluSphere( mSphere, 6.0f, 15, 15 );glPopMatrix();


Did I do something wrong? I thought with quaternions everything would work [crying]
No more ideas? [crying] pleeeeeease ;-)
*bump*
CQuaternion q1( mBalls.mRotX, CVector3(0,0,1) );
CQuaternion q2( -mBalls.mRotZ, CVector3(0,1,0) );

this is a problem. Although you are using quaternions, you are still storing you angles as mRotX and mRotZ, you just convert them to quaternions before converting them into matrices. Effectively you are still using Eulers
Its been a while since I've done this so I may be off, you'll have to play around. What you want to do is store the rotation of the ball as a single quaternion ie

mBalls.rotation

then whenever the ball moves apply the appropriate rotation to that. This way you are storing the rotation as a quaternion rather than as an Euler angle.
Urks! That sounds right to me ;-)

But to be honest that goes completely beyond my logic... It is so simple to handle, imagine and visualize the ball's rotation as X and Z values...how could these two be convertet to ONE quaternion???
I dunno if I'm late on this, or if this is even what you're asking, but here's what I do:


glRotatef(world.xangle(), 1.0, 0, 0);
glRotatef(world.yangle(), 0, 1.0, 0);
glRotatef(world.zangle(), 0, 0, 1.0);

glTranslatef(model.xoffset, model.yoffset, model.zoffset);

glTranslatef(world.xoffset, world.yoffset, world.zoffset);

glRotatef(model.xangle, 1.0, 0, 0);
glRotatef(model.yangle, 0, 1.0, 0);
glRotatef(model.zangle, 0, 0, 1.0);

model.draw();
Well...no, that's not what I was looking for...but thanks you nevertheless ;-)
Ok then, I guess I'll put that project on ice for now. Thanks for your ideas!
If anyone can find a solution or good link regarding that topic please let me know! :-)
Vankurt,I'm sorry,but I just can't understand why my approach doesn't work.Ok,let's see if I got things straight:
1)This is a 2D top-down game.
2)The ball moves in the XZ plane.That means you will place the ball with commands like glTranslatef(ball.x,0,ball.z).
3)You want the ball to spin while it moves.

Correct?

This topic is closed to new replies.

Advertisement