Hello guys,
I´m facing a problem about the best way to rotate a camera around one object. Before had the idea to post here, I checked out the post “Camera woes.” from madjack and I analyzed the TestLightRadius example.
My goal is just to rotate the camera facing always one object. So, when I keep A key pressed, for example, the camera rotates to left, D key instead of A key its rotates to right side. It´s sounds pretty simple, but it´s burning my mind away!
The first picture shows up how the problem is today from perception:
This picture shows up how my intention about the cameras behavior should be.
http://img.photobucket.com/albums/v413/Grinvon/cam_issues02.png
I don´t realize if chase camera could be a good point at all. I had tried using Quaterion:
[java] //turn the waypoints to left side
Quaternion right = new Quaternion();
right.fromAngleAxis( - (FastMath.HALF_PI / 30) * tpf * 64, Vector3f.UNIT_Y);
Vector3f rotationResult = right.mult(cam.getLocation());
cam.setLocation(rotationResult);
cam.lookAt(central.getLocalTranslation(), new Vector3f(0, 1, 0));[/java]
and using cos and sin, like as the following example:
[java] //turn the waypoints to left side
angle += tpf;
angle %= FastMath.TWO_PI;
cam.setLocation(new Vector3f(FastMath.cos(angle) * 9f, 7, FastMath.sin(angle) * 9f));
cam.lookAt(central.getLocalTranslation(), new Vector3f(0, 1, 0));
[/java]
But the problem still remains, I think as the second picture figures out the problem can be solved. Maybe put the focused object exactly in the middle of camera circle I can rotate and facing the camera as desired with precision.
I know where the object are, but I´m missing something…
Any hints will be very welcome. Thanks in advance.