I want follow an object with my camera. I use the ChaseCamera and everything works fine. But I can not set the Position of my camera only distance is allowed.
Next I want set the lookAt direction of my camera. The last step is the rotation center of my object.
Rotation center means this point where the node rotates around.
As to the center that the ChaseCam follows, thats the center of the spatial you give to it. Add a node (or a hierarchy of nodes with your model to have one node at the position you deem correct.
Otherwise you have three options:
a) move the camera
b) let the ChaseCam move the camera
c) have your own control move the camera
Among these options c) can also be a control that extends ChaseCam and adds your own code to alter its behavior.
As to the center that the ChaseCam follows, thats the center of the spatial you give to it. Add a node (or a hierarchy of nodes) with your model to have one node at the position you deem correct.
Ok. I have set the node in the desired position. For example “new Vector3f(0,0.5f,0)”
Now the position of my camera should be “new Vector3f(1,1,1)”.
How can I set the position of my camera. Is it possible or I have to calculate the rotation angle.
I need the zooming behavior and the rotation behavior. This works great with ChaseCam.
But I need an initial view on my model. After that the user can rotate and zoom the model in front of my camera. But not the postion or rotation angle of my model should not be changed only the camera position.
Ok. I try to write my own.
May be someone can help me with the math?
I want rotate one point around another point. Like a clock.
More details:
private void rotateCamera(float value) {
// the parameter value comes from the movement of my mouse. This value
// should be move the camera around a Vector rotationCenter
}
public class TestChaseCamera extends SimpleApplication {
@Override
public void simpleInitApp() {
Sphere sphereX = new Sphere(20, 50, 0.5f);
Geometry gX = new Geometry("SX", sphereX);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Red);
gX.setMaterial(mat);
gX.setLocalTranslation(Vector3f.ZERO);
rootNode.attachChild(gX);
ChaseCamera cc = new ChaseCamera(cam,gX, inputManager);
cam.setLocation(Vector3f.UNIT_XYZ.mult(3));
}
public static void main(String args[]) {
new TestChaseCamera().start();
}
}
But the Position of the camera is not 3,3,3, else “Camera Position: (17.320509, 10.0, 0.0)”.
If I could set the initial position of the camera, this is the best solution.