The jME3 Camera

Default Camera

The default com.jme3.renderer.Camera object is cam in com.jme3.app.Application.

The camera object is created with the following defaults:

MethodUsage
cam.getLocation(), setLocation()The camera position
cam.getRotation(), setRotation()The camera rotation
cam.getLeft(), setLeft()The left axis of the camera
cam.getUp(), setUp()The up axis of the camera, usually Vector3f(0,1,0)
cam.getDirection(), setDirection()The vector the camera is facing
cam.getAxes(), setAxes(left,up,dir)One accessor for the three properties left/up/direction.
cam.getFrame(), setFrame(loc,left,up,dir)One accessor for the four properties location/left/up/direction.
cam.resize(width, height, fixAspect)Resize an existing camera object while keeping all other settings. Set fixAspect to true to adjust the aspect ratio (?)
cam.setFrustum( near, far, left, right, top, bottom )The frustrum is defined by the near/far plane, left/rught plane, top/bottom plane (all distances as float values)
cam.setFrustumPerspective( fovY, aspect ratio, near, far)The frustrum is defined by view angle along the Y axis (in degrees), aspect ratio, and the near/far plane.
cam.lookAt(target,up)Turn the camera to look at Coordinate target, and rotate it around the up axis.
cam.setParallelProjection(false)Normal perspective
cam.setParallelProjection(true)Parallel projection perspective
cam.getScreenCoordinates()?

Tip: After you change view port, frustrum, or frame, call cam.update();

FlyBy Camera

The flyby camera is an extension of the default camera in com.jme3.app.SimpleApplication. It is preconfigured to respond to the WASD keys for walking forwards and backwards, and for strafing to the sides. Move the mouse to rotate the camera, scroll the mouse wheel for zooming in or out. The QZ keys raise or lower the camera.

MethodUsage
flyCam.setEnabled(true);Activate the flyby cam
flyCam.setMoveSpeed(10);Control the move speed
flyCam.setRotationSpeed(10);Control the rotation speed
flyCam.setDragToRotate(true)Must keep mouse button pressed to rotate camera. Used e.g. for Applets. if false, all mouse movement will be captured and interpreted as rotations.

Chase Camera

jME3 also supports a Chase Cam that can follow a moving target Spatial (com.jme3.input.ChaseCamera). Click and hold the mouse button to rotate around the target.

flyCam.setEnabled(false);
ChaseCamera chaseCam = new ChaseCamera(cam, target, inputManager);
MethodUsage
chaseCam.setSmoothMotion(true);Interpolates a smoother acceleration/deceleration when the camera moves.
chaseCam.setChasingSensitivity(5f)The lower the chasing sensitivity, the slower the camera will follow the target when it moves.
chaseCam.setTrailingSensitivity(0.5f)The lower the traling sensitivity, the slower the camera will begin to go after the target when it moves. Default is 0.5;
chaseCam.setRotationSensitivity(5f)The lower the sensitivity, the slower the camera will rotate around the target when the mosue is dragged. Default is 5.
chaseCam.setTrailingRotationInertia(0.1f)This prevents the camera to stop too abruptly when the target stops rotating before the camera has reached the target's trailing position. Default is 0.1f.
chaseCam.setDefaultDistance(40);The default distance to the target at the start of the application.
chaseCam.setMaxDistance(40);The maximum zoom distance. Default is 40f.
chaseCam.setMinDistance(1);The minimum zoom distance. Default is 1f.
chaseCam.setMinVerticalRotation(-FastMath.PI/2);The minimal vertical rotation angle of the camera around the target. Default is 0.
chaseCam.setDefaultVerticalRotation(-FastMath.PI/2);The default vertical rotation angle of the camera around the target at the start of the application.
chaseCam.setDefaultHorizontalRotation(-FastMath.PI/2);The default horizontal rotation angle of the camera around the target at the start of the application.
camera, documentation

view online version