Package com.ardor3d.input.control
Class OrbitCamControl
java.lang.Object
com.ardor3d.input.control.OrbitCamControl
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());
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected double
protected Camera
The camera we are modifying.protected Vector3
protected boolean
protected boolean
protected boolean
protected boolean
protected Vector3
protected Spatial
protected double
protected double
protected double
protected double
protected InputTrigger
protected Vector3
protected OrbitCamControl.TargetType
protected Vector3
protected double
protected double
protected double
static final double
Our absolute min/max ascent (pitch) angle, in radians. -
Constructor Summary
ConstructorDescriptionOrbitCamControl
(Camera cam, ReadOnlyVector3 target) Construct a new orbit controllerOrbitCamControl
(Camera cam, Spatial target) Construct a new orbit controller -
Method Summary
Modifier and TypeMethodDescriptiondouble
double
double
double
double
double
double
double
boolean
boolean
boolean
void
void
move
(double xDif, double yDif) void
setBaseDistance
(double baseDistance) void
void
setInvertedWheel
(boolean invertedWheel) void
setInvertedX
(boolean invertedX) void
setInvertedY
(boolean invertedY) void
setLookAtPoint
(Vector3 point) Sets a specific world location for the camera to point at and circle around.void
setLookAtSpatial
(Spatial spatial) Sets a spatial to look at.void
setMaxAscent
(double maxAscent) void
setMaxZoomDistance
(double maxZoomDistance) void
setMinAscent
(double minAscent) void
setMinZoomDistance
(double minZoomDistance) void
setSphereCoords
(double x, double y, double z) void
setSphereCoords
(ReadOnlyVector3 sphereCoords) void
setupMouseTriggers
(LogicalLayer layer, boolean dragOnly) void
setWorldUpVec
(ReadOnlyVector3 worldUpVec) void
setXSpeed
(double speed) void
setYSpeed
(double speed) void
setZoomSpeed
(double zoomSpeed) void
update
(double time) Update the position of the Camera controlled by this object.protected void
void
zoom
(double percent) Zoom camera in/out from the target point.
-
Field Details
-
ABSOLUTE_MAXASCENT
public static final double ABSOLUTE_MAXASCENTOur 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
The camera we are modifying. -
_worldUpVec
-
_sphereCoords
-
_camPosition
-
_lookAtPoint
-
_lookAtSpatial
-
_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
-
-
Constructor Details
-
OrbitCamControl
Construct a new orbit controller- Parameters:
cam
- the camera to controltarget
- a world location to lock our sights on.
-
OrbitCamControl
Construct a new orbit controller- Parameters:
cam
- the camera to controltarget
- a spatial whose world location we'll lock our sights on.
-
-
Method Details
-
getCamera
-
setCamera
-
getWorldUpVec
-
setWorldUpVec
-
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
-
setLookAtPoint
Sets a specific world location for the camera to point at and circle around.- Parameters:
point
- the point to look at
-
getLookAtSpatial
-
setLookAtSpatial
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
-
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
-
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 ifisInvertedWheel()
is true.
-
move
public void move(double xDif, double yDif) - Parameters:
xDif
- a value applied to the azimuth value of our spherical coordinates. Inverted ifisInvertedX()
is true.yDif
- a value applied to the theta value of our spherical coordinates. Inverted ifisInvertedY()
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
-