www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: rainfalls on November 17, 2013, 01:03:29 am

Title: Camera: moveCamera(int mode, float speed)
Post by: rainfalls on November 17, 2013, 01:03:29 am
Hi,

I had this code:

Code: [Select]
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:

Code: [Select]
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.
Title: Re: Camera: moveCamera(int mode, float speed)
Post by: EgonOlsen on November 17, 2013, 10:27:40 am
There's no way how this can happen except if

Title: Re: Camera: moveCamera(int mode, float speed)
Post by: rainfalls on November 17, 2013, 03:07:53 pm
The complete code is too long to post, the part related to Camera is:

Code: [Select]
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:

Code: [Select]
(
-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
)

Title: Re: Camera: moveCamera(int mode, float speed)
Post by: 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 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:


 ???
Title: Re: Camera: moveCamera(int mode, float speed)
Post by: rainfalls on November 17, 2013, 04:10:55 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
Title: Re: Camera: moveCamera(int mode, float speed)
Post by: EgonOlsen on November 17, 2013, 04:12:46 pm
Yes, sorry. I mean obj.getScale().
Title: Re: Camera: moveCamera(int mode, float speed)
Post by: rainfalls on November 17, 2013, 07:33:35 pm
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.