apps.mt3dmaps.orbittest
Class CameraFocusInputAction

java.lang.Object
  extended by com.jme.input.action.InputAction
      extended by apps.mt3dmaps.orbittest.CameraFocusInputAction
All Implemented Interfaces:
com.jme.input.action.InputActionInterface

public class CameraFocusInputAction
extends com.jme.input.action.InputAction

Uses the mouse to select a scene object, and smoothly move the camera towards the selected object focusing at its center. This is used with the OrbitAction.

Author:
Andrew Carter

Nested Class Summary
 class CameraFocusInputAction.CameraController
          Controller used in conjuction with the Orbit handler to smoothly move the camera towards a scene object.
 
Constructor Summary
CameraFocusInputAction(com.jme.renderer.Camera camera, OrbitAction orbit)
          Constructor.
 
Method Summary
 CameraFocusInputAction.CameraController getController()
          Returns the camera controller that is used to focus the camera on a specific object in the scene.
 boolean isEnabled()
          Returns true if this input action is enabled.
 void moveCameraToSpatial(com.jme.scene.Spatial spatial)
          Calculates the distance from the object the camera will move to, and initializes and starts the camera controller to move towards the given spatial.
 void performAction(com.jme.input.action.InputActionEvent evt)
          Perform action.
 com.jme.scene.Geometry pickGeometry(com.jme.math.Vector2f screenPos)
          Performs a mouse pick in the scene with supplied screen coordinates of the mouse.
 void setEnabled(boolean enabled)
          Enable or disable this input action.
 void setNode(com.jme.scene.Node node)
          Set the node that is used when picking in the scene.
 
Methods inherited from class com.jme.input.action.InputAction
getSpeed, setSpeed
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CameraFocusInputAction

public CameraFocusInputAction(com.jme.renderer.Camera camera,
                              OrbitAction orbit)
Constructor.

Parameters:
camera - the camera
orbit - the orbit
Method Detail

getController

public CameraFocusInputAction.CameraController getController()
Returns the camera controller that is used to focus the camera on a specific object in the scene.

Returns:
CameraController

isEnabled

public boolean isEnabled()
Returns true if this input action is enabled.

Returns:
true, if is enabled

moveCameraToSpatial

public void moveCameraToSpatial(com.jme.scene.Spatial spatial)
Calculates the distance from the object the camera will move to, and initializes and starts the camera controller to move towards the given spatial.

Parameters:
spatial - the spatial

performAction

public void performAction(com.jme.input.action.InputActionEvent evt)
Perform action.

Parameters:
evt - the evt
See Also:
InputActionInterface.performAction(com.jme.input.action.InputActionEvent)

pickGeometry

public com.jme.scene.Geometry pickGeometry(com.jme.math.Vector2f screenPos)
Performs a mouse pick in the scene with supplied screen coordinates of the mouse. The screen coordinates are converted into a ray in the scene and used for triangle accuracy picking. The geometry closest to the camera is returned.

Parameters:
screenPos - Screen coordinate of the mouse cursor
Returns:
The geometry nearest the camera that was picked, or null

setEnabled

public void setEnabled(boolean enabled)
Enable or disable this input action.

Parameters:
enabled - the new enabled

setNode

public void setNode(com.jme.scene.Node node)
Set the node that is used when picking in the scene.

Parameters:
node - the new node