Hi,
I had this code:
cam.setPosition(camLookat);
Logger.log("1 " + cam.getPosition());
cam.moveCamera(Camera.CAMERA_MOVEOUT, 5);
Logger.log("2 " + cam.getPosition());
And then I got the log:
1 (-10512.435,409.47632,1982.2085)
2 (-11233.428,366.8882,1982.152)
Why the distance between the two positions were much larger than 5?
In the javadoc, its written like this: "speed - the speed (positional change in units)". Any where I missed some hidden scaling factor?
Thanks.
There's no way how this can happen except if
- The code you posted is not the complete code that you are using.
- Your camera matrix is completely screwed somehow. Please print out camera.getBack() and post the result.
The complete code is too long to post, the part related to Camera is:
cam.align(obj); // align camera with an Object3D
cam.rotateCameraX(C.D90); // rotate view
cam.rotateCameraY(C.D90); // rotate view
cam.setPosition(camLookat); // set its position to a SimpleVector camLookat
cam.moveCamera(Camera.CAMERA_MOVERIGHT, offsetH); // move right
cam.moveCamera(Camera.CAMERA_MOVEUP, offsetV); // move up
cam.getPosition(offsetSV); // save the camera's position to a SimpleVector
cam.setPosition(camLookat); // reset its position to camLookat
Logger.log("1 " + cam.getPosition());
Logger.log(cam.getBack().toString());
cam.moveCamera(Camera.CAMERA_MOVEOUT, 5); // move out
Logger.log("2 " + cam.getPosition());
Logger.log(cam.getBack().toString());
The two lines logging cam.getBack() returned this same matrix which I don't understand its meaning:
(
-0.01639 8.512504 144.19896 0.0
-4.0E-6 -144.19896 8.512505 0.0
144.45 9.62E-4 0.016362 0.0
0.0 0.0 0.0 1.0
)
That matrix is complete nonsense. I wonder how you created it...which version of jPCT are you using? There was a problem with align() once, but it has been fixed over 3 years ago with 1.19!?
If you aren't using a version that old, could you please:
- print out cam.getBack(); before the align() call
- print out obj.getRotationMatrix(); before the align() call
- print out obj.getScale(); before the align() call
- print out cam.getBack(); after the align() call
???
Quote from: EgonOlsen on November 17, 2013, 03:42:12 PM
That matrix is complete nonsense. I wonder how you created it...which version of jPCT are you using? There was a problem - print out cam.getScale(); before the align() call
Did you mean obj.getScale()? I can't find Camera has this method.
And I'm using jpct version: jpct.1.27.2013.07.04
Yes, sorry. I mean obj.getScale().
Hi Egon,
Thanks for your suggestions. The camera problem did originate from the object's rotationMatrix which I read from my collada model. I added rotationMatrix.orthonormalize() and the camera worked properly.