Jump to content
  • Advertisement

Archived

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

Acer722

OpenGL How to make and object move with the world. OpenGL

This topic is 6246 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

Today I was working on a flight simulator. I have added a bunch of features. Here are the keys: Up arrow : foreward Left Arrow : left Right Arrow : right Down Arrow : back A : tilt left S : tilt right Q : move up W : move down Page Up : tilt up Page Down tilt down It works really nicely but the problem is I want the camera to move with the airplane so that the airplane is 5 units out in front of the camera at all times. How do I do that?

Share this post


Link to post
Share on other sites
Advertisement
it would help to know what api ur using.

life is unfair, take advantage of it.
UNMB2 - if the link doesn''t work, try clicking it

Share this post


Link to post
Share on other sites
quote:
Original post by thuned
it would help to know what api ur using.



You mean you didnt read the topic of this thread?
It clearly says "OpenGL"

Share this post


Link to post
Share on other sites
Does anybody know how to move the camera with the object with object being a little bit ahead of the camera. Also how do minipulate one object, ie rotate or translate, while I the other object doesn''t move.

Share this post


Link to post
Share on other sites
A = airplanes position
D = direction airplane is looking
gluLookAt( A.x - D.x*zoom, A.y - D.y*zoom, A.z - D.z*zoom, A.x, A.y, A.z, 0,1,0 );

http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites
Yes I knw your supposed to apply this camera movement when the object moves but how do I do that. Also does anyone know how to move just one object but make the other object still.

Share this post


Link to post
Share on other sites
Well, I assume that you have the matrix of the viewpoint loaded into memory for this. But you can do something like this:

glPushMatrix();
glLoadIdentity();
glTranslatef(0, 0, -5);
DrawPlane();
glPopMatrix();

That will draw the airplane 5 units in front of you. If it doesn''t work, then you are probably doing things differently than me.

Share this post


Link to post
Share on other sites
I know that draw the plane five unuts ahead of me. Here parts of my code:

GLfloat zpos; // Z position

-----------------------------

glTranslatef(0.0f,0.0f,zpos);

-----------------------------

if (keys[VK_UP])
{
zpos-=1.0f;
}

That moves the ariplane one unit a head of the camera if you press space bar. How would I make both the camera and the plane move one unit ahead if I press the space bar? I have been trying eveything. Also lets say I have a run way. I if I were to press the spacebar the runway would move one unit with the plane. How do I get just the plane to move.

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!