Plane camera, opengl

Started by
5 comments, last by Claus Hansen Ries 23 years, 10 months ago
I want to make my camera "move" as it where a air plane. I have tried three times now, the first try went to hell. The second resultet in a misbehaving 1st person shooter movement. The third try gave a working 1st person shooter movement. BUT THATs NOT WHAT I WANTED...(looking straight down the y axis resulted in rolling about the y axis, instead of swinging the head ) so do any one have something that theaches a 4-year old kid, who knowns vectors and matrices, to build "airplane camera" ???
Ries
Advertisement
Source code is also welcome =)
Ries
to move the "airplane" glTranslatef(x,y,z)
to rotate the "airplane" glRotate(angle_measure,x,y,z)
I''m still not sure I know what you mean by an "airplane camera"

JoeMont001@aol.com
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
Im not that stupid =)

my problem is, you are at x,y,z, looking in some direction, and you eg press forward. Then it has to move in the direction i point. Its the hole thing, storing the direction, calucating the new direction when the user move / rotates.

When user input applied, the movement has to be, like you are sitting in a plane and not like you are playing quake3 or UT.


Edited by - Claus Hansen Ries on June 22, 2000 3:28:09 PM
Ries
to make the game feel like an aeroplane (yes, that is how you spell it) simulation, a good idea would be to integrate a reasonable physics engine, some dynamics of the plane and the like.
If you just want a simple camera system, then what you could do is have make the translation a constant depending on the current speed, so whenever a player presses the move forward key the speed is increased, and this is the variable used in a glTranslate() command.
I did have some nifty code that would have helped you out, but I''ve deleted it and I''m afraid I''m too busy to redo it now. Just remember to get the sin/cos ratios correct when you calculate the displacement.

Was the 4-year old kid comment necessary?

-Mezz
For airplanes you cannot store your camera orientation with angles, you need to use either vectors or quaternions. Since I haven''t bothered to learn about quaternions yet I will tell you how to do it with vectors.

You need three vectors that are orthogonal to each other and of unit length. These three vectors show in which direction the planes rear (z), up (y) and right (x) is pointing.

When you pitch the plane it should rotate about the x vector, you do this by rotating the z and y vectors around the x vector. When you roll the plane rotate the x and y vectors around the z vector.

Because of numerical errors in floating point operations you will have to re-orthogonalize and re-normalize the vectors from time to time, that is done by first taking the cross product of the y and z vectors to get the x vector and then take cross product of the new x and old z to get y vector. Finish the recalibration by normalizing the vectors.

When you render the plane you need to build the rotation matrix by hand and then sending it to OpenGL with glMultMatrix() or glLoadMatrix().

Here''s a couple of links to my page that describes how the world matrix, view matrix and rotation matrix is constructed:

- rotation
- world
- view

Keep in mind that these matrices are for use with Direct3D, you need to transpose them first to use them in OpenGL.

- WitchLord

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Thanks for the link, i''ll try that. =)
Ries

This topic is closed to new replies.

Advertisement