4

I am writing a program that is supposed to display 3D point clouds. For this purpose, I am using the jMonkeyEngine. Unfortunately, I do not like the default camera behavior of jMonkey. Especially the mouse dragging and mouse wheel do not really do what I want. What I want is them to behave like in the pcd viewer of the PointCloudLibrary.

  1. Mouse wheel: Should be faster, and the the effect of the turning directions should be switched.
  2. Mouse dragging: In jMonkey it seems like mouse dragging changes the camera viewing direction in the world. I am not sure what exactly happens in the pcd viewer, but I believe the camera is moved through the world while fixating the centroid of the displayed point cloud.

How can I change the behavior of the camera to fullfil my wishes? :)

user1809923
  • 1,235
  • 3
  • 12
  • 27

1 Answers1

1

1. In the simpleInit() method (where 100 is an abritrary number):

getFlyByCamera().setZoomSpeed(100);
getFlyByCamera().setDragToRotate(true);

Note, that zooming doesn't actually change the position of the camera, just the FOV.

2. The normal behavior of the camera is to rotate around its own axis. By offseting the location of the camera as well, the effect you want can be achieved. In simpleUpdate():

cam.setLocation(cam.getDirection().negate().multLocal(cam.getLocation().length()));

I consider the answer to the second question a bit of a quick hack. But it does the trick.

reden
  • 968
  • 7
  • 14