public class FocusCamera
extends java.lang.Object
implements com.jme3.input.controls.ActionListener, com.jme3.input.controls.AnalogListener, com.jme3.scene.control.Control
Modifier and Type | Field and Description |
---|---|
protected com.jme3.renderer.Camera |
cam |
protected boolean |
canRotate |
protected static java.lang.String |
ChaseCamDown |
protected static java.lang.String |
ChaseCamMoveLeft |
protected static java.lang.String |
ChaseCamMoveRight |
protected static java.lang.String |
ChaseCamToggleRotate |
protected static java.lang.String |
ChaseCamUp |
protected static java.lang.String |
ChaseCamZoomIn |
protected static java.lang.String |
ChaseCamZoomOut |
protected boolean |
chasing |
protected float |
chasingSensitivity |
protected float |
distance |
protected float |
distanceLerpFactor |
protected boolean |
dragToRotate |
protected boolean |
enabled |
protected com.jme3.math.Vector3f |
initialUpVec |
protected com.jme3.input.InputManager |
inputManager |
protected boolean |
invertXaxis |
protected boolean |
invertYaxis |
protected boolean |
leftClickRotate |
protected com.jme3.math.Vector3f |
lookAtOffset |
protected float |
maxDistance |
protected float |
maxVerticalRotation |
protected float |
minDistance |
protected float |
minVerticalRotation |
protected float |
offsetDistance |
protected com.jme3.math.Vector3f |
pos |
protected float |
previousTargetRotation |
protected com.jme3.math.Vector3f |
prevPos |
protected boolean |
rightClickRotate |
protected boolean |
rotating |
protected float |
rotation |
protected float |
rotationLerpFactor |
protected float |
rotationSensitivity |
protected float |
rotationSpeed |
protected boolean |
smoothMotion |
protected com.jme3.scene.Spatial |
target |
protected com.jme3.math.Vector3f |
targetDir |
protected float |
targetDistance |
protected com.jme3.math.Vector3f |
targetLocation |
protected boolean |
targetMoves |
protected float |
targetRotation |
protected float |
targetVRotation |
protected com.jme3.math.Vector3f |
temp |
protected boolean |
trailing |
protected boolean |
trailingEnabled |
protected float |
trailingLerpFactor |
protected float |
trailingRotationInertia |
protected float |
trailingSensitivity |
protected boolean |
veryCloseRotation |
protected boolean |
vRotating |
protected float |
vRotation |
protected float |
vRotationLerpFactor |
protected boolean |
zoomin |
protected boolean |
zooming |
protected float |
zoomSensitivity |
protected float |
zoomSpeed |
Constructor and Description |
---|
FocusCamera(com.jme3.renderer.Camera cam)
Constructs the chase camera
if you use this constructor you have to attach the cam later to a spatial
doing spatial.addControl(chaseCamera);
|
FocusCamera(com.jme3.renderer.Camera cam,
com.jme3.input.InputManager inputManager)
Constructs the chase camera, and registers inputs
if you use this constructor you have to attach the cam later to a spatial
doing spatial.addControl(chaseCamera);
|
FocusCamera(com.jme3.renderer.Camera cam,
com.jme3.scene.Spatial target)
Constructs the chase camera
|
FocusCamera(com.jme3.renderer.Camera cam,
com.jme3.scene.Spatial target,
com.jme3.input.InputManager inputManager)
Constructs the chase camera, and registers inputs
|
Modifier and Type | Method and Description |
---|---|
com.jme3.scene.control.Control |
cloneForSpatial(com.jme3.scene.Spatial spatial)
clone this camera for a spatial
|
protected void |
computePosition() |
float |
getChasingSensitivity()
returns the chasing sensitivity
|
float |
getDistanceToTarget()
return the current distance from the camera to the target
|
boolean |
getDownRotateOnCloseViewOnly() |
float |
getHorizontalRotation()
returns the current horizontal rotation around the target in radians
|
com.jme3.math.Vector3f |
getLookAtOffset()
returns the offset from the target's position where the camera looks at
|
float |
getMaxDistance()
Returns the max zoom distance of the camera (default is 40)
|
float |
getMaxVerticalRotation() |
float |
getMinDistance()
Returns the min zoom distance of the camera (default is 1)
|
float |
getMinVerticalRotation() |
float |
getRotationSensitivity()
Returns the rotation sensitivity
|
float |
getTrailingRotationInertia()
returns the trailing rotation inertia
|
float |
getTrailingSensitivity()
returns the trailing sensitivity
|
com.jme3.math.Vector3f |
getUpVector()
Returns the up vector of the camera used for the lookAt on the target
|
float |
getVerticalRotation()
returns the current vertical rotation around the target in radians.
|
float |
getZoomSensitivity()
returns the zoom sensitivity
|
float |
getZoomSpeed() |
boolean |
isDragToRotate() |
boolean |
isEnabled()
Return the enabled/disabled state of the camera
|
boolean |
isSmoothMotion() |
boolean |
isTrailingEnabled()
returns true if the trailing is enabled
|
void |
onAction(java.lang.String name,
boolean keyPressed,
float tpf) |
void |
onAnalog(java.lang.String name,
float value,
float tpf) |
void |
read(com.jme3.export.JmeImporter im)
Read the camera
|
void |
registerWithInput(com.jme3.input.InputManager inputManager)
Registers inputs with the input manager
|
void |
render(com.jme3.renderer.RenderManager rm,
com.jme3.renderer.ViewPort vp)
renders the camera control, should only be used internally
|
protected void |
rotateCamera(float value) |
void |
setChasingSensitivity(float chasingSensitivity)
Sets the chasing sensitivity, the lower the value the slower the camera will follow the target when it moves
default is 5
Only has an effect if smoothMotion is set to true and trailing is enabled
|
void |
setDefaultDistance(float defaultDistance)
Sets the default distance at start of applicaiton
|
void |
setDefaultHorizontalRotation(float angleInRad)
sets the default horizontal rotation in radian of the camera at start of the application
|
void |
setDefaultVerticalRotation(float angleInRad)
sets the default vertical rotation in radian of the camera at start of the application
|
void |
setDownRotateOnCloseViewOnly(boolean rotateOnlyWhenClose) |
void |
setDragToRotate(boolean dragToRotate) |
void |
setEnabled(boolean enabled)
Enable or disable the camera
|
void |
setInvertHorizontalAxis(boolean invertXaxis)
invert the Horizontal axis movement of the mouse
|
void |
setInvertVerticalAxis(boolean invertYaxis)
invert the vertical axis movement of the mouse
|
void |
setLookAtOffset(com.jme3.math.Vector3f lookAtOffset)
Sets the offset from the target's position where the camera looks at
|
void |
setMaxDistance(float maxDistance)
Sets the max zoom distance of the camera (default is 40)
|
void |
setMaxVerticalRotation(float maxVerticalRotation)
Sets the maximal vertical rotation angle in radian of the camera around the target.
|
void |
setMinDistance(float minDistance)
Sets the min zoom distance of the camera (default is 1)
|
void |
setMinVerticalRotation(float minHeight)
Sets the minimal vertical rotation angle in radian of the camera around the target default is 0;
|
void |
setRotationSensitivity(float rotationSensitivity)
Sets the rotation sensitivity, the lower the value the slower the camera will rotates around the target when draging with the mouse
default is 5, values over 5 should have no effect.
|
void |
setSmoothMotion(boolean smoothMotion)
Enables smooth motion for this chase camera
|
void |
setSpatial(com.jme3.scene.Spatial spatial)
Sets the spacial for the camera control, should only be used internally
|
void |
setToggleRotationTrigger(com.jme3.input.controls.Trigger... triggers)
Sets custom triggers for toggleing the rotation of the cam
deafult are
new MouseButtonTrigger(MouseInput.BUTTON_LEFT) left mouse button
new MouseButtonTrigger(MouseInput.BUTTON_RIGHT) right mouse button
|
void |
setTrailingEnabled(boolean trailingEnabled)
Enable the camera trailing : The camera smoothly go in the targets trail when it moves.
|
void |
setTrailingRotationInertia(float trailingRotationInertia)
Sets the trailing rotation inertia : default is 0.1.
|
void |
setTrailingSensitivity(float trailingSensitivity)
Only has an effect if smoothMotion is set to true and trailing is enabled
Sets the trailing sensitivity, the lower the value, the slower the camera will go in the target trail when it moves.
|
void |
setUpVector(com.jme3.math.Vector3f up)
Sets the up vector of the camera used for the lookAt on the target
|
void |
setZoomInTrigger(com.jme3.input.controls.Trigger... triggers)
Sets custom triggers for zomming in the cam
default is
new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true) mouse wheel up
|
void |
setZoomOutTrigger(com.jme3.input.controls.Trigger... triggers)
Sets custom triggers for zomming out the cam
default is
new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false) mouse wheel down
|
void |
setZoomSensitivity(float zoomSensitivity)
Sets the zoom sensitivity, the lower the value, the slower the camera will zoom in and out.
|
void |
setZoomSpeed(float zoomSpeed) |
void |
update(float tpf)
update the camera control, should only be used internally
|
protected void |
updateCamera(float tpf)
Updates the camera, should only be called internally
|
protected void |
vRotateCamera(float value) |
void |
write(com.jme3.export.JmeExporter ex)
Write the camera
|
protected void |
zoomCamera(float value) |
protected com.jme3.scene.Spatial target
protected float minVerticalRotation
protected float maxVerticalRotation
protected float minDistance
protected float maxDistance
protected float distance
protected float zoomSpeed
protected float rotationSpeed
protected float rotation
protected float trailingRotationInertia
protected float zoomSensitivity
protected float rotationSensitivity
protected float chasingSensitivity
protected float trailingSensitivity
protected float vRotation
protected boolean smoothMotion
protected boolean trailingEnabled
protected float rotationLerpFactor
protected float trailingLerpFactor
protected boolean rotating
protected boolean vRotating
protected float targetRotation
protected com.jme3.input.InputManager inputManager
protected com.jme3.math.Vector3f initialUpVec
protected float targetVRotation
protected float vRotationLerpFactor
protected float targetDistance
protected float distanceLerpFactor
protected boolean zooming
protected boolean trailing
protected boolean chasing
protected boolean veryCloseRotation
protected boolean canRotate
protected float offsetDistance
protected com.jme3.math.Vector3f prevPos
protected boolean targetMoves
protected boolean enabled
protected com.jme3.renderer.Camera cam
protected final com.jme3.math.Vector3f targetDir
protected float previousTargetRotation
protected final com.jme3.math.Vector3f pos
protected com.jme3.math.Vector3f targetLocation
protected boolean dragToRotate
protected com.jme3.math.Vector3f lookAtOffset
protected boolean leftClickRotate
protected boolean rightClickRotate
protected com.jme3.math.Vector3f temp
protected boolean invertYaxis
protected boolean invertXaxis
protected static final java.lang.String ChaseCamDown
protected static final java.lang.String ChaseCamUp
protected static final java.lang.String ChaseCamZoomIn
protected static final java.lang.String ChaseCamZoomOut
protected static final java.lang.String ChaseCamMoveLeft
protected static final java.lang.String ChaseCamMoveRight
protected static final java.lang.String ChaseCamToggleRotate
protected boolean zoomin
public FocusCamera(com.jme3.renderer.Camera cam, com.jme3.scene.Spatial target)
cam
- the application cameratarget
- the spatial to followpublic FocusCamera(com.jme3.renderer.Camera cam)
cam
- the application camerapublic FocusCamera(com.jme3.renderer.Camera cam, com.jme3.input.InputManager inputManager)
cam
- the application camerainputManager
- the inputManager of the application to register inputspublic FocusCamera(com.jme3.renderer.Camera cam, com.jme3.scene.Spatial target, com.jme3.input.InputManager inputManager)
cam
- the application cameratarget
- the spatial to followinputManager
- the inputManager of the application to register inputspublic void onAction(java.lang.String name, boolean keyPressed, float tpf)
onAction
in interface com.jme3.input.controls.ActionListener
public void onAnalog(java.lang.String name, float value, float tpf)
onAnalog
in interface com.jme3.input.controls.AnalogListener
public final void registerWithInput(com.jme3.input.InputManager inputManager)
inputManager
- public void setToggleRotationTrigger(com.jme3.input.controls.Trigger... triggers)
triggers
- public void setZoomInTrigger(com.jme3.input.controls.Trigger... triggers)
triggers
- public void setZoomOutTrigger(com.jme3.input.controls.Trigger... triggers)
triggers
- protected void computePosition()
protected void rotateCamera(float value)
protected void zoomCamera(float value)
protected void vRotateCamera(float value)
protected void updateCamera(float tpf)
public boolean isEnabled()
public void setEnabled(boolean enabled)
enabled
- true to enablepublic float getMaxDistance()
public void setMaxDistance(float maxDistance)
maxDistance
- public float getMinDistance()
public void setMinDistance(float minDistance)
public com.jme3.scene.control.Control cloneForSpatial(com.jme3.scene.Spatial spatial)
cloneForSpatial
in interface com.jme3.scene.control.Control
spatial
- public void setSpatial(com.jme3.scene.Spatial spatial)
setSpatial
in interface com.jme3.scene.control.Control
spatial
- public void update(float tpf)
update
in interface com.jme3.scene.control.Control
tpf
- public void render(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp)
render
in interface com.jme3.scene.control.Control
rm
- vp
- public void write(com.jme3.export.JmeExporter ex) throws java.io.IOException
write
in interface com.jme3.export.Savable
ex
- the exporterjava.io.IOException
public void read(com.jme3.export.JmeImporter im) throws java.io.IOException
read
in interface com.jme3.export.Savable
im
- java.io.IOException
public float getMaxVerticalRotation()
public void setMaxVerticalRotation(float maxVerticalRotation)
maxVerticalRotation
- public float getMinVerticalRotation()
public void setMinVerticalRotation(float minHeight)
minHeight
- public boolean isSmoothMotion()
public void setSmoothMotion(boolean smoothMotion)
smoothMotion
- public float getChasingSensitivity()
public void setChasingSensitivity(float chasingSensitivity)
chasingSensitivity
- public float getRotationSensitivity()
public void setRotationSensitivity(float rotationSensitivity)
rotationSensitivity
- public boolean isTrailingEnabled()
public void setTrailingEnabled(boolean trailingEnabled)
trailingEnabled
- public float getTrailingRotationInertia()
public void setTrailingRotationInertia(float trailingRotationInertia)
trailingRotationInertia
- public float getTrailingSensitivity()
public void setTrailingSensitivity(float trailingSensitivity)
trailingSensitivity
- public float getZoomSensitivity()
public void setZoomSensitivity(float zoomSensitivity)
zoomSensitivity
- public void setDefaultDistance(float defaultDistance)
defaultDistance
- public void setDefaultHorizontalRotation(float angleInRad)
angleInRad
- public void setDefaultVerticalRotation(float angleInRad)
angleInRad
- public boolean isDragToRotate()
FlyByCamera.setDragToRotate(boolean)
public void setDragToRotate(boolean dragToRotate)
dragToRotate
- 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.public void setDownRotateOnCloseViewOnly(boolean rotateOnlyWhenClose)
rotateOnlyWhenClose
- When this flag is set to false the chase
camera will always rotate around its spatial independently of their
distance to one another. If set to true, the chase camera will only
be allowed to rotated below the "horizon" when the distance is smaller
than minDistance + 1.0f (when fully zoomed-in).public boolean getDownRotateOnCloseViewOnly()
public float getDistanceToTarget()
public float getHorizontalRotation()
public float getVerticalRotation()
public com.jme3.math.Vector3f getLookAtOffset()
public void setLookAtOffset(com.jme3.math.Vector3f lookAtOffset)
lookAtOffset
- public void setUpVector(com.jme3.math.Vector3f up)
up
- public com.jme3.math.Vector3f getUpVector()
public void setInvertVerticalAxis(boolean invertYaxis)
invertYaxis
- public void setInvertHorizontalAxis(boolean invertXaxis)
invertXaxis
- public float getZoomSpeed()
public void setZoomSpeed(float zoomSpeed)
zoomSpeed
- the zoomSpeed to set