Sign in to follow this  

Moving Backwards - OpenGL

This topic is 1983 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'm using this algorithim to move the camera fowards:
[CODE]
switch(event.key.keysym.sym)
{
case SDLK_w:
Vector tmp;
tmp.x = view.x - main.x;
tmp.y = view.y - main.y;
tmp.z = view.z - main.z;
view.x = tmp.x + view.x;
view.z = tmp.z + view.z;
main.x = tmp.x + main.x;
main.z = tmp.z + main.z;
break;
[/CODE]

I tried adding * -1 to the end of Lines 8-11, but I didn't work, how can I get the camera to move backwards?

Share this post


Link to post
Share on other sites
You just have to multiply the amount that you're moving by -1. It looks like your [b]tmp[/b] vector is the amount of the movement? Multiply tmp by -1. You may even want to normalize it first, so the camera always moves by 1 unit, making it a smooth movement. You can then scale the vector to move the camera faster or slower.

Hope this helps.

Share this post


Link to post
Share on other sites

This topic is 1983 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this