Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

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: 140

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?

#2 EmployeeNumber8   Crossbones+   -  Reputation: 1039

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