1
Support / How to get the "up" - part of the camera?
« on: September 21, 2006, 05:29:37 pm »
Hi,
a camera in 3d space can be defined by position, direction and up (the orientation). I found no way to access this up information in JPCT, and this is especially missing in the camera.lookAt(obj) method.
I need this for implementing a camera that can be rotated around a given object with the mouse. I wrote the following code for rotating around a object at the x axis:
When I rotate around an object this way, the orientation flips around (upside-down) when I get close to a 180 degree rotation.
I think that this information is somehow stored in the camera.getBack() rotation matrix, but the math part of my has been shrunken since school :oops:
By the way, did anyone use quaternions? I found some nice articles in the web about this, but I don't know how to integrate this with JPCT right know, I think there wait a lot of little traps like the column-or-row matrix question and such things when converting those examples from DirectX to the java JPCT world.
Thanks for any help
Sebastian[/code][/quote]
a camera in 3d space can be defined by position, direction and up (the orientation). I found no way to access this up information in JPCT, and this is especially missing in the camera.lookAt(obj) method.
I need this for implementing a camera that can be rotated around a given object with the mouse. I wrote the following code for rotating around a object at the x axis:
Code: [Select]
SimpleVector obj = object.getTransformedCenter();
SimpleVector cam = camera.getPosition();
SimpleVector v = cam.calcSub(obj);
Matrix m = new Matrix();
m.rotateX(dx);
v.matMul(m);
v.add(obj);
camera.setPosition(v);
camera.lookAt(obj);
When I rotate around an object this way, the orientation flips around (upside-down) when I get close to a 180 degree rotation.
I think that this information is somehow stored in the camera.getBack() rotation matrix, but the math part of my has been shrunken since school :oops:
By the way, did anyone use quaternions? I found some nice articles in the web about this, but I don't know how to integrate this with JPCT right know, I think there wait a lot of little traps like the column-or-row matrix question and such things when converting those examples from DirectX to the java JPCT world.
Thanks for any help
Sebastian[/code][/quote]