Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Claus Hansen Ries

OpenGL Plane camera, opengl

This topic is 6723 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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" ???

Share this post

Link to post
Share on other sites
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"


Share this post

Link to post
Share on other sites
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

Share this post

Link to post
Share on other sites
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?


Share this post

Link to post
Share on other sites
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

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!