I know this is a simple question.
I need to put the camera in a specific location (x,y,z) looking at the vector direction (x,y,z).
I have been trying to have a general code creating the quaternions from scratch with the regular functions (not using those numbers with decimals) but always ended up in something else.
It could be starting again from the origin (always moving not relative - better always from the origin).
if someone can tell me where to check this code or have some ideas i will appreciate it.
No.
My problem is that rotating the camera is not exactly the same as an object. Because after I try to move it, the camara is repositioned again looking at (may be) the initial vector when it started.
Possibly, I am doing something wrong and I am missing a concept here.
It is not clear to me as well if the lookat is relative (rotating as if the origin is the camera) or not relative (moving always from the origin).
Simply I got lost always in 2 moves rotating and translating. I got close but not exactly what I want.
Thanks, I will check quaternion function.
What I am trying to do is simple. I have 4 viewport, each one is looking the same object located in the origin. This object is let’s say size from -4 to +4 in every axis, hence I put the camera in 4 different points.
For example, camera in (0,10,0) looking down. Camera (10,10,10) looking 45 degree to the origin.
They are most of the time pointing to the origin from different position.
I forgot to say as well that this is another issue. If I put the camera in (0,10,0) looking down, I need to make sure, for example, that the axis positive X be to my right side. I am getting X positive to the left and i cannot make it to the right after that. This is another issue, it is not only translation and lookat. It is as well to make sure the X axis is by will in one side. That is the reason I said moving the camera is not the same as an object.
no sure if i have answered you question, but If I can put the camera in whatever axis and/or 45 degrees looking the origin will help me a lot (45 degrees I meant = Constant * (+/- 1, +/- 1, +/-1).
And that’s the part I found confusing before because they are no different mathematically.
I’m still not clear on what you are trying to do. Are you trying to move the cameras or change their direction? How will you know how much to do one or the other?
Just forget my comment If you believe it is wrong (may be from my perspective camera is watching and object is observed).
I just need something like:
Move camera to (X,Y,Z) looking to point (X1,Y2,Z2) that can be the origin. Keeping in mind which axis will be to the right and left. For example if I am looking down from (0,1,0) I would like X to the right or left for example. I guess this is only 90,180,270 degrees more in Y axis, but It has been hard to me to figure it out.
You can control this with the up vector in the lookAt() call.
It takes at least two vectors to define an orientation precisely for the reason you state. Looking down 0, -1, 0 is ambiguous without knowing which ‘up’ should be. If up is 0, 0, 1 that’s going to be different than if up was 0, 0, -1 or 1, 0, 0. They will all give you a different right/left.
Thank You, I got it finally. The problem was exactly the up vector as you said. I was using Y, hence target and Y are in 0 or 180 degrees. I have used Z axis (0,0,-1) with the code below and i have now X axis on the right side.
cam3.setViewPort(0f, .5f, .5f, 1f);
cam3.setLocation(new Vector3f(0.0f,9.0f, 0.0f)); //From Axis y
Vector3f Target = new Vector3f(0,0,0); // origin
Vector3f rotatearoundup = new Vector3f(0,0,-1); // -Z
cam3.lookAt(Target,rotatearoundup);