Anyone can teach me what are a CAM’s : Left Up Direction vectors ?
Are these three vectors must be orthogonal ?
If i used cam.getUp cam.getLeft cam.getDirecton , did i get a normalized vector?
BTW I’m working on a cam control (move rotate raise ) parallel to the x-y plane.
The direction vector is the central axis of the camera’s view. If you put your mouse dead center in the camera’s view and shoot a ray into the scene, that ray will travel along the camera’s direction vector. In other words, it’s the center of your field of view.
The left and up vectors are used to orient the camera’s local coordinate space. If something is expressed in screen space coordinates, they determine how it appears relative to the view. In jME, left is -X and up is +Y.
Logically, if you consider the camera in world space then the left, up, and direction vectors appear to be orthogonal BUT they are not because the left and up vectors are not in world space. If you do a cross product with them, in general you will not get the direction vector. In world space the cross product will look like the direction vector (or the negative of the direction vector) but the coordinate components won’t be at all the same because they’re in a different coordinate system (the camera’s local coordinates).
I’m not sure if jME keeps these normalized or not. In general, if your calculations require normalized vectors I’d suggest always normalizing a vector before you use it for two reasons: (a) it’s more robust - if someone comes along and changes a normalized vector in the engine to an unnormalized vector (on purpose or via a bug), your code remains unaffected, and (b) it makes your intent in your code clear - you have permanently indicated in your code that your calculation requires vectors to be normalized, and if you or other developers go back and visit that section again they will immediately see that you thought the vectors should be normalized, which can go a long way towards clearing up confusion if someone isn’t sure what a calculation should be doing.
One more question :
What if I input Up-Left-Direction vectors that they are not orthogonal ?
for example :
Up: 0,0,1
Left-1,0,0
Direction: 1,1,1 (not orthognonal to UP-Left plane)
You’re right in that by the usual dot-product-is-zero metric, those vectors are not orthogonal. However… they are orthogonal in a sense because they are in separate spaces. The direction vector is in world space, but the up and left vectors are in camera space (in fact, they define the orientation of camera space - a left vector of (-1, 0, 0) means that moving one unit in the -X direction moves left across the camera’s view). Here’s the gotcha… since the direction vector determines where the camera is looking in the world, it must be orthogonal to the camera’s viewing plane. If you transformed it into camera space, it would lie along the camera’s forward axis and thus, when dotted with the up and left vectors, would have a dot product of zero (truly orthogonal in the mathematical sense). Vector spaces are a bit hard to wrap your head around at first, but once you get used to using this stuff it will become second nature quickly.