Sign in to follow this  
captacha

Moving Backwards - OpenGL

Recommended Posts

captacha    141
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
DangerDoom    1103
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

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