Class WalkCamera

  • All Implemented Interfaces:
    com.jme3.input.controls.ActionListener, com.jme3.input.controls.AnalogListener, com.jme3.input.controls.InputListener

    public class WalkCamera
    extends java.lang.Object
    implements com.jme3.input.controls.AnalogListener, com.jme3.input.controls.ActionListener
    A first person view camera controller. After creation, you must register the camera controller with the dispatcher using #registerWithDispatcher(). Controls: - Move the mouse to rotate the camera - Mouse wheel for zooming in or out - WASD keys for moving forward/backward and strafing - QZ keys raise or lower the camera
    • Constructor Summary

      Constructors 
      Constructor Description
      WalkCamera​(com.jme3.renderer.Camera cam)
      Creates a new WalkCamera to control the given Camera object and the HeightMap.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      float getMoveSpeed()
      Gets the move speed.
      float getRotationSpeed()
      Gets the move speed.
      boolean isDragToRotate()  
      boolean isEnabled()  
      void moveCamera​(float value, boolean sideways)  
      void onAction​(java.lang.String name, boolean value, float tpf)  
      void onAnalog​(java.lang.String name, float value, float tpf)  
      void registerWithInput​(com.jme3.input.InputManager inputManager)
      Registers the FlyByCamera to receive input events from the provided Dispatcher.
      void riseCamera​(float value)  
      void rotateCamera​(float value, com.jme3.math.Vector3f axis)  
      void setDragToRotate​(boolean dragToRotate)
      Set if drag to rotate mode is enabled.
      void setEnabled​(boolean enable)  
      void setMotionAllowedListener​(com.jme3.collision.MotionAllowedListener listener)  
      void setMoveSpeed​(float moveSpeed)
      Sets the move speed.
      void setRotationSpeed​(float rotationSpeed)
      Sets the rotation speed.
      void setUpVector​(com.jme3.math.Vector3f upVec)
      Sets the up vector that should be used for the camera.
      void unregisterInput()
      Registers the FlyByCamera to receive input events from the provided Dispatcher.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • cam

        public com.jme3.renderer.Camera cam
      • initialUpVec

        public com.jme3.math.Vector3f initialUpVec
      • rotationSpeed

        public float rotationSpeed
      • moveSpeed

        public float moveSpeed
      • motionAllowed

        public com.jme3.collision.MotionAllowedListener motionAllowed
      • enabled

        public boolean enabled
      • dragToRotate

        public boolean dragToRotate
      • canRotate

        public boolean canRotate
      • inputManager

        public com.jme3.input.InputManager inputManager
    • Constructor Detail

      • WalkCamera

        public WalkCamera​(com.jme3.renderer.Camera cam)
        Creates a new WalkCamera to control the given Camera object and the HeightMap.
        Parameters:
        cam -
    • Method Detail

      • setUpVector

        public void setUpVector​(com.jme3.math.Vector3f upVec)
        Sets the up vector that should be used for the camera.
        Parameters:
        upVec -
      • setMotionAllowedListener

        public void setMotionAllowedListener​(com.jme3.collision.MotionAllowedListener listener)
      • setMoveSpeed

        public void setMoveSpeed​(float moveSpeed)
        Sets the move speed. The speed is given in world units per second.
        Parameters:
        moveSpeed -
      • getMoveSpeed

        public float getMoveSpeed()
        Gets the move speed. The speed is given in world units per second.
        Returns:
        moveSpeed
      • setRotationSpeed

        public void setRotationSpeed​(float rotationSpeed)
        Sets the rotation speed.
        Parameters:
        rotationSpeed -
      • getRotationSpeed

        public float getRotationSpeed()
        Gets the move speed. The speed is given in world units per second.
        Returns:
        rotationSpeed
      • setEnabled

        public void setEnabled​(boolean enable)
        Parameters:
        enable - If false, the camera will ignore input.
      • isDragToRotate

        public boolean isDragToRotate()
        Returns:
        If drag to rotate feature is enabled.
        See Also:
        setDragToRotate(boolean)
      • setDragToRotate

        public void setDragToRotate​(boolean dragToRotate)
        Set if drag to rotate mode is enabled. When true, the user must hold the mouse button and drag over the screen to rotate the camera, and the cursor is visible until dragged. Otherwise, the cursor is invisible at all times and holding the mouse button is not needed to rotate the camera. This feature is disabled by default.
        Parameters:
        dragToRotate - True if drag to rotate mode is enabled.
      • registerWithInput

        public void registerWithInput​(com.jme3.input.InputManager inputManager)
        Registers the FlyByCamera to receive input events from the provided Dispatcher.
        Parameters:
        inputManager -
      • unregisterInput

        public void unregisterInput()
        Registers the FlyByCamera to receive input events from the provided Dispatcher.
        Parameters:
        inputManager -
      • rotateCamera

        public void rotateCamera​(float value,
                                 com.jme3.math.Vector3f axis)
      • riseCamera

        public void riseCamera​(float value)
      • moveCamera

        public void moveCamera​(float value,
                               boolean sideways)
      • onAnalog

        public void onAnalog​(java.lang.String name,
                             float value,
                             float tpf)
        Specified by:
        onAnalog in interface com.jme3.input.controls.AnalogListener
      • onAction

        public void onAction​(java.lang.String name,
                             boolean value,
                             float tpf)
        Specified by:
        onAction in interface com.jme3.input.controls.ActionListener