Moving the camera in a 3D space when camera is rotated (using Wikipedia Definition of 3D Projection)

StackOverflow https://stackoverflow.com/questions/5384640

Question

I wonder if someone could tell me how to make it possible to move a camera in a 3D space when the camera is rotated.

I am working on my own 3D engine (nothing fancy) and I can move the camera forward backward left right up down, thats all good. However when I rotate the camera, it doesnt move in the direction that the camera is directed to.

Here is a picture that should help you understand what I mean:

http://www.xaid.se/camrot.jpg

Does anybody know how to make this work?

(If you're interested in what I'm working on, visit this site)

Was it helpful?

Solution

i'm not sure if i really get what you mean, but your problem looks like you want to move along the direction of the camera instead along one (main-)axis? therefore my solution would be to store a vector which keeps the direction the camera is looking, and update this vector everytime you rotate the camera. now you can use your direction vector for the forward movement. position + vector*stepsize. hope that helps a little bit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top