🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Help with glRotated(Angle,x,y,z);
http://www.gamasutra.com/features/programming/19980703/quaternions_04.htm
Here's a better description of the behavior:
//setup
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_MODELVIEW);
//more setup
loop {
glLoadIdentity();
gluPerspective(90,1.25,.5,20.0);
//respond to kb
// clamp angles between 0 and 359
glRotated(pitch,1,0,0);
glRotated(yaw, 0,1,0);
glRotated(roll, 0,0,1);
glTranslated(-xEye,-yEye,-zEye);
//draw simple cubes
glFlush();
SwapBuffers( hDC );
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
That is the basic layout of my code. nothing fancy at all.
the behavior is as follows:
pitch & roll interact well. (except for some weirdness when I pitch 180 degrees over, roll seems to invert behavior.)
pitch and yaw do not.
yaw seems to ignore pitch completely - if I pitch *any* angle yaw still acts like I'm facing straight down the z axis.
Is that gimbal lock? From the article it seemed that they were specifically talking about 90 degree rotation problems. Mine behaves like this all the time. It's basically behaves like quake rotation when I want descent.
Thanks,
Nex
Jonathan
Thanks for the input but that didn't do it either.
I think the problem resides in this:
(after much 1 eye closed hand yawing and pitching)
The order of the yaw/pitch is important as well...but whichever I choose (I'm scaling out the roll for now.) I'm incorrect.
If I pitch then yaw then I get proper behavior if thats the way the person moves the camera (look up and turn left/right for extreme example)
If I yaw then pitch then I get improper behavior if the user pitches then yaws the camera (turn 90 left or right and then yaw up/down for extreme example - looks like rotate) but this behaves properly where the other way fails and vice versa.
This seems like something that people would do all the time in OpenGL but I've been scouring tutorials for it - cant find anything.
ARRRRRRGH,
Nex
The reason that OpenGl transformations appear backwards is because of the way that two matrices are multiplyed. the transformations commands (glrotate,glscale,gltranslate) multiply the current matrix C by the transformation matrix T on the right side. C:=C*T.
I'm trying to make the jump to 3d and learn this OpenGL thing and I'm having a bit of difficulty. I'm specifically trying to make a small project in which I can fly the viewpoint around some simple objects. The viewpoint can move forwards, backwards, left, right, pitch, roll, and yaw. The objects should appear to stay still. Here's the problem:
I used the OpenGL programming Guide suggestion to do
glRotated(roll,0,0,1);
glRotated(yaw,0,1,0);
glRotated(pitch,1,0,0);
glTranslated(x,y,z);
Translate works fine but the rotations are screwy and the screwiness depends on the order I do them.
If I do the pitch rotation last then if I'm yawed 90 degrees pitch behaves like roll...
I'm a newbie to 3d stuff but I do have a good deal of experience in 2d and general programming. Can any of you please help me?
Thanks,
Nex