Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Moving Backwards - OpenGL

4: Adsense

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   

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?

#2 EmployeeNumber8   Members   

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.