[Solved]SpatialToCamera and camerarotation

Hey ho,



this is my camera-setting:



[java] camNode = new CameraNode("Camera Node", cam);



camNode.setControlDir(ControlDirection.SpatialToCamera);





spaceNode.attachChild(camNode);





camNode.setLocalTranslation(new Vector3f(-10, 5f, -40));



camNode.lookAt(spaceShuttle.getLocalTranslation(), Vector3f.UNIT_Y);[/java]



Now i want to allow camera rotation around my object…How could i solve it:cry:?



thanks barak

This should help you out: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:intermediate:math

It is a cheat sheet with examples on how to rotate around a point.

Yeah thats quite obvious … But how could i enable the rotation from mouseinput in my camerasettings ?



[java]//A rotation around this up axis towards this direction

Quaternion q = new Quaternion();

q.lookAt(v,up)[/java]

look at ChaseCam, it rotates around an object and follows it

3 Likes

don’t get me wrong but since your a member for ~4hours I assume you’re new to JMonkey. There is a camera that does almost exactly what you want (if I understand you right). try:



[java]ChaseCamera chaseCam = new ChaseCamera(cam, YourSpatial, inputManager);

chaseCam.setEnabled(true);[/java]



if you want a static distance to the object set:



[java] chaseCam.setMinDistance(50);

chaseCam.setMaxDistance(50);

chaseCam.setDefaultDistance(50);[/java]



(setting the max and min distance to the same value will obviously cause the camera to be fixed to that distance. You can also make the angle static this way if needed.)



to read more about chaseCam see:

http://www.jmonkeyengine.com/doc/com/jme/input/ChaseCamera.html







Edit: seems like Sploreg was faster :smiley:

3 Likes

yeah I am newbie ! Thanks a lot you´re great!

1 Like