View Full Version : Unreal Style Motion

10-06-2003, 06:03 PM
So I'm taking this OpenGL class, and we run Redhat Linux, and I have to create a scene. I want to look around it with the mouse and move with the arrows, just like in the games. I know glutSpecialFunc and glutPassiveMotionFunc, but I'm not sure how to pull it all together. So is there something you know that I don't, Frankie?

10-06-2003, 07:05 PM
I know what you mean. When using glutMotionFunc and glutPassiveMotionFunc, the mouse cursor is limited to the bounds of the screen. To get around this, find how much the mouse moved (aka mouse delta; platform specific if you want it to be), center the cursor (platform specific), and then move whatever is connected to the mouse (gun, head, etc) based on the mouse delta.

10-07-2003, 05:25 AM
Ok. More specifically, do I want the camera to move? or the scene? If i want the camera to move, how to i rotate and translate it smoothly and easily?

10-07-2003, 06:48 AM

10-07-2003, 07:58 AM
Please stop about this quaternion stuff. Using quaternions to manage observers is simply a waste of time.

Proof 1: I had a speak with a person which made a whole tutorial about quaternions. He told me quaternions are really not needed for this (he told me they rock for other things, but not there).

Proof 2: Take a look at the Q2 (or Q1)source code. It uses eulerian angles and since this maps to OpenGL quite easily, I really don't know why to use other things.

As for moving correctly and "easily" the only thing I can say I actually mantain a "foward" and a "right" vector but too much time has passed since I made this stuff and I don't remember anymore (wrapped in a class which has NEVER been modified again).

Now, the object it's used in way like that:

observer.AddAngles(mouse.movement.deltaX * MOUSE_SPEED, mouse.movement.deltaY * MOUSE_SPEED, .0f); // I actually don't roll.
observer.MoveFoward(foward * MOVEMENT_SPEED * framePeriod);
observer.MoveRight(/* similar to the above */);
/* Similar things to move backward and left */

Now, this works pretty fine most of the time and I don't need to work with quaternions. I guess working with trigonometric functions is much easier.

10-07-2003, 07:35 PM
gluLookAt() can be used to simulate a camera. Also you could just do something similar to this (this may or may not be the proper way, I use gluLookAt myself):

glLoadIdentity() //can't remember if this is necessary

10-09-2003, 09:27 AM
Ok. Now i need to keep the mouse centered at all times. Running redhat. Coding in c++. Any ideas?