Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Moving Backwards - OpenGL


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Captacha   Members   -  Reputation: 141

Like
0Likes
Like

Posted 12 August 2012 - 12:43 PM

I'm using this algorithim to move the camera fowards:
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;

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?

Sponsor:

#2 EmployeeNumber8   Crossbones+   -  Reputation: 1103

Like
1Likes
Like

Posted 12 August 2012 - 05:11 PM

You just have to multiply the amount that you're moving by -1. It looks like your tmp 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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS