Class OrbitCamControl

java.lang.Object
com.ardor3d.input.control.OrbitCamControl

public class OrbitCamControl extends Object

Orbital type Camera controller. Basically, this class references a camera and provides methods for moving that camera around a target position or spatial using spherical polar coordinates.

To use, create a new instance of OrbitCamController. Update the controller in your update loop.

Example: Creates a new control, adds mouse triggers to a Logical Layer, and sets the default location (15 units away, 0 degrees ascent, 0 degrees azimuth).

 // ... in init
 control = new OrbitCamControl(myCamera, targetLocation);
 control.setupMouseTriggers(myLogicalLayer, true);
 control.setSphereCoords(15, 0, 0);

 // ...in update loop
 control.update(timer.getTimePerFrame());
 
  • Field Details

    • ABSOLUTE_MAXASCENT

      public static final double ABSOLUTE_MAXASCENT
      Our absolute min/max ascent (pitch) angle, in radians. This is set at 89.95 degrees to prevent the camera's direction from becoming parallel to the world up vector.
      See Also:
    • _camera

      protected Camera _camera
      The camera we are modifying.
    • _worldUpVec

      protected Vector3 _worldUpVec
    • _sphereCoords

      protected Vector3 _sphereCoords
    • _camPosition

      protected Vector3 _camPosition
    • _lookAtPoint

      protected Vector3 _lookAtPoint
    • _lookAtSpatial

      protected Spatial _lookAtSpatial
    • _targetType

      protected OrbitCamControl.TargetType _targetType
    • _invertedX

      protected boolean _invertedX
    • _invertedY

      protected boolean _invertedY
    • _invertedWheel

      protected boolean _invertedWheel
    • _zoomSpeed

      protected double _zoomSpeed
    • _baseDistance

      protected double _baseDistance
    • _minZoomDistance

      protected double _minZoomDistance
    • _maxZoomDistance

      protected double _maxZoomDistance
    • _minAscent

      protected double _minAscent
    • _maxAscent

      protected double _maxAscent
    • _xSpeed

      protected double _xSpeed
    • _ySpeed

      protected double _ySpeed
    • _dirty

      protected boolean _dirty
    • _mouseTrigger

      protected InputTrigger _mouseTrigger
  • Constructor Details

    • OrbitCamControl

      public OrbitCamControl(Camera cam, ReadOnlyVector3 target)
      Construct a new orbit controller
      Parameters:
      cam - the camera to control
      target - a world location to lock our sights on.
    • OrbitCamControl

      public OrbitCamControl(Camera cam, Spatial target)
      Construct a new orbit controller
      Parameters:
      cam - the camera to control
      target - a spatial whose world location we'll lock our sights on.
  • Method Details

    • getCamera

      public Camera getCamera()
    • setCamera

      public void setCamera(Camera camera)
    • getWorldUpVec

      public ReadOnlyVector3 getWorldUpVec()
    • setWorldUpVec

      public void setWorldUpVec(ReadOnlyVector3 worldUpVec)
    • setInvertedWheel

      public void setInvertedWheel(boolean invertedWheel)
    • isInvertedWheel

      public boolean isInvertedWheel()
    • setInvertedX

      public void setInvertedX(boolean invertedX)
    • isInvertedX

      public boolean isInvertedX()
    • setInvertedY

      public void setInvertedY(boolean invertedY)
    • isInvertedY

      public boolean isInvertedY()
    • getLookAtPoint

      public Vector3 getLookAtPoint()
    • setLookAtPoint

      public void setLookAtPoint(Vector3 point)
      Sets a specific world location for the camera to point at and circle around.
      Parameters:
      point - the point to look at
    • getLookAtSpatial

      public Spatial getLookAtSpatial()
    • setLookAtSpatial

      public void setLookAtSpatial(Spatial spatial)
      Sets a spatial to look at. We'll use the world transform of the spatial, so its transform needs to be up to date.
      Parameters:
      spatial - the spatial to look at
    • getTargetType

      public OrbitCamControl.TargetType getTargetType()
    • getZoomSpeed

      public double getZoomSpeed()
    • setZoomSpeed

      public void setZoomSpeed(double zoomSpeed)
    • getBaseDistance

      public double getBaseDistance()
    • setBaseDistance

      public void setBaseDistance(double baseDistance)
    • getMaxAscent

      public double getMaxAscent()
    • setMaxAscent

      public void setMaxAscent(double maxAscent)
    • getMinAscent

      public double getMinAscent()
    • setMinAscent

      public void setMinAscent(double minAscent)
    • getMaxZoomDistance

      public double getMaxZoomDistance()
    • setMaxZoomDistance

      public void setMaxZoomDistance(double maxZoomDistance)
    • getMinZoomDistance

      public double getMinZoomDistance()
    • setMinZoomDistance

      public void setMinZoomDistance(double minZoomDistance)
    • getXSpeed

      public double getXSpeed()
    • setXSpeed

      public void setXSpeed(double speed)
    • getYSpeed

      public double getYSpeed()
    • setYSpeed

      public void setYSpeed(double speed)
    • setSphereCoords

      public void setSphereCoords(ReadOnlyVector3 sphereCoords)
    • setSphereCoords

      public void setSphereCoords(double x, double y, double z)
    • updateTargetPos

      protected void updateTargetPos()
    • makeDirty

      public void makeDirty()
    • zoom

      public void zoom(double percent)
      Zoom camera in/out from the target point.
      Parameters:
      percent - a value applied to the baseDistance to determine how far in/out to zoom. Inverted if isInvertedWheel() is true.
    • move

      public void move(double xDif, double yDif)
      Parameters:
      xDif - a value applied to the azimuth value of our spherical coordinates. Inverted if isInvertedX() is true.
      yDif - a value applied to the theta value of our spherical coordinates. Inverted if isInvertedY() is true.
    • update

      public void update(double time)
      Update the position of the Camera controlled by this object.
      Parameters:
      time - a delta time, in seconds. Not used currently, but might be useful for doing "ease-in" of camera movements.
    • setupMouseTriggers

      public void setupMouseTriggers(LogicalLayer layer, boolean dragOnly)