31
Support / plz help with Camera rotation aligned with orbiting object.
« on: June 17, 2007, 12:13:05 am »
Hi,
I wanted to help visualize my camera movements / rotations as I was getting some strange results.
I have made a simple applet (source link included at the bottom) which has a small cube orbiting a larger cube. the cube movements are manually controlled by pressing the arrow keys and you can toggle the camera by pressing 1 for follow mode 2 for free float and R to reset the cam to it's original position.
The little cube rotates around the cube if you press UP and DOWN. If you press 1 to set the camera to follow behind the little cube, the rendering seems to mess up (inversed).
I've been searching on the forums for reference to this problem but I can't seem to figure out how to fix it.
This seemed my best bet: http://www.jpct.net/forum2/index.php/topic,641.0.html
but when i tried to use the invert3x3() it didn't seem to work.
I also tried the "follower" code with the same result: http://www.jpct.net/forum2/index.php/topic,616.msg3214.html#msg3214
If anyone can help out I'd appreciate it greatly.
Thanks:
cube rotation:
camera follow small cube:
TEMPORARY HOSTED APPLET:
http://154.5.173.123:8001/test/index.html
FULL SOURCE: (in case it might be useful to someone in the future)
http://154.5.173.123:8001/test/tester3d.java
I wanted to help visualize my camera movements / rotations as I was getting some strange results.
I have made a simple applet (source link included at the bottom) which has a small cube orbiting a larger cube. the cube movements are manually controlled by pressing the arrow keys and you can toggle the camera by pressing 1 for follow mode 2 for free float and R to reset the cam to it's original position.
The little cube rotates around the cube if you press UP and DOWN. If you press 1 to set the camera to follow behind the little cube, the rendering seems to mess up (inversed).
I've been searching on the forums for reference to this problem but I can't seem to figure out how to fix it.
This seemed my best bet: http://www.jpct.net/forum2/index.php/topic,641.0.html
but when i tried to use the invert3x3() it didn't seem to work.
I also tried the "follower" code with the same result: http://www.jpct.net/forum2/index.php/topic,616.msg3214.html#msg3214
If anyone can help out I'd appreciate it greatly.
Thanks:
cube rotation:
Code: [Select]
if(mvSpinLeft) // Cube2 orbit left
{
objCube2.rotateAxis(objCube2.getYAxis(), rotSpeed);
} // if
if(mvSpinRight) // Cube2 obrit right
{
objCube2.rotateAxis(objCube2.getYAxis(), -rotSpeed);
} // if
camera follow small cube:
Code: [Select]
if(modeFollow)
{
theCamera.setPositionToCenter(objCube2); // place camera inside cube2
theCamera.align(objCube2); // Copy the cube2 positive Z-axis.
theCamera.lookAt(objCube1.getTransformedCenter()); // look at cube 1 center.
theCamera.moveCamera(Camera.CAMERA_MOVEOUT, 50.0f); // put camera behind cube2 a little
// Problem is here?
} // if
TEMPORARY HOSTED APPLET:
http://154.5.173.123:8001/test/index.html
FULL SOURCE: (in case it might be useful to someone in the future)
http://154.5.173.123:8001/test/tester3d.java