I'm creating a program that has a 3D view. The 3D world uses three vectors (X,Y,Z). Now, the way the camera works is by having two points, the focal point and the camera. The camera is set to look at the focal point at all times.
I want it so when my users press D
, the camera and focal point should move to the right
relative to their current position. (A = Left
, W = Forward
, S = Backword
)
Imagine you are holding a long stick with a ball on the end. You would be the camera and the ball would be the focal point. Now, no matter what direction you face (assuming you keep the stick straight out), moving "right", the focal point will move the same distance as you do, while, to you, you are moving to the right. Looking up will also have the stick point up. Basically, the ball goes where ever you are looking.
Givens:
I know the XYZ position of both the Camera and the Focal Point.
Now, assuming I want to add, say 2, to the position of both objects to move them right
, how would I do this?
I started doing something odd with slope and stuff but it didn't end up working like I wanted. Basically, I was trying to find the slope that would create a perpendicular line, etc.
Anyways, this may sound like something that would end up in GameDev or something but I just need the math for it. The only reason why I can't wrap my head around it is because I'm dealing in 3D instead of 2D (like I've been learning in school).