public class MotionEvent extends AbstractCinematicEvent implements Control, JmeCloneable
Modifier and Type | Class and Description |
---|---|
static class |
MotionEvent.Direction
Enum for the different type of target direction behavior.
|
Modifier and Type | Field and Description |
---|---|
protected float |
currentValue |
protected int |
currentWayPoint |
protected Vector3f |
direction |
protected MotionEvent.Direction |
directionType |
protected Vector3f |
lookAt |
protected MotionPath |
path |
protected Quaternion |
rotation |
protected Spatial |
spatial |
protected float |
traveledDistance
the distance traveled by the spatial on the path
|
protected Vector3f |
upVector |
initialDuration, listeners, loopMode, playState, resuming, speed, time
Constructor and Description |
---|
MotionEvent()
Create MotionEvent,
when using this constructor don't forget to assign spatial and path.
|
MotionEvent(Spatial spatial,
MotionPath path)
Creates a MotionPath for the given spatial on the given motion path.
|
MotionEvent(Spatial spatial,
MotionPath path,
float initialDuration)
Creates a MotionPath for the given spatial on the given motion path.
|
MotionEvent(Spatial spatial,
MotionPath path,
float initialDuration,
LoopMode loopMode)
Creates a MotionPath for the given spatial on the given motion path.
|
MotionEvent(Spatial spatial,
MotionPath path,
LoopMode loopMode)
Creates a MotionPath for the given spatial on the given motion path.
|
Modifier and Type | Method and Description |
---|---|
void |
cloneFields(Cloner cloner,
java.lang.Object original)
Implemented to perform deep cloning for this object, resolving
local cloned references using the specified cloner.
|
Control |
cloneForSpatial(Spatial spatial)
Deprecated.
|
float |
getCurrentValue()
This method is meant to be called by the motion path only.
|
int |
getCurrentWayPoint()
This method is meant to be called by the motion path only.
|
Vector3f |
getDirection()
Returns the direction the spatial is moving.
|
MotionEvent.Direction |
getDirectionType()
Returns the direction type of the target.
|
MotionPath |
getPath()
Return the motion path this control follows.
|
Quaternion |
getRotation()
Returns the rotation of the target.
|
Spatial |
getSpatial() |
float |
getTraveledDistance()
Return the distance traveled by the spatial on the path.
|
void |
initEvent(Application app,
Cinematic cinematic)
Initialize this event (called internally only).
|
void |
internalUpdate(float tpf)
Used internally only.
|
boolean |
isEnabled() |
java.lang.Object |
jmeClone()
Performs a regular shallow clone of the object.
|
boolean |
needsDirection()
This method is meant to be called by the motion path only.
|
void |
onPause()
Implement this method with code that you want to execute when the event is paused.
|
void |
onPlay()
Implement this method with code that you want to execute when the event is started.
|
void |
onStop()
Implement this method with code that you want to execute when the event is stopped.
|
void |
onUpdate(float tpf)
Implement this method with the code that you want to execute on update
(only called when the event is playing).
|
void |
read(JmeImporter im)
Used for serialization only.
|
void |
render(RenderManager rm,
ViewPort vp)
Should be called prior to queuing the spatial by the RenderManager.
|
void |
setCurrentValue(float currentValue)
This method is meant to be called by the motion path only.
|
void |
setCurrentWayPoint(int currentWayPoint)
This method is meant to be called by the motion path only.
|
void |
setDirection(Vector3f direction)
Sets the direction of the spatial, using the Y axis as the up vector.
|
void |
setDirection(Vector3f direction,
Vector3f upVector)
Sets the direction of the spatial with the given up vector.
|
void |
setDirectionType(MotionEvent.Direction directionType)
Sets the direction type of the target.
|
void |
setEnabled(boolean enabled) |
void |
setLookAt(Vector3f lookAt,
Vector3f upVector)
Set the lookAt for the target.
|
void |
setPath(MotionPath path)
Sets the motion path to follow.
|
void |
setRotation(Quaternion rotation)
Sets the rotation of the target.
|
void |
setSpatial(Spatial spatial) |
void |
setTime(float time)
Fast-forward the event to the given timestamp.
|
void |
update(float tpf)
Updates the control.
|
void |
write(JmeExporter ex)
Used for serialization only.
|
addListener, dispose, forceStop, getDuration, getInitialDuration, getLoopMode, getPlayState, getSpeed, getTime, pause, play, removeListener, setInitialDuration, setLoopMode, setSpeed, stop
protected Spatial spatial
protected int currentWayPoint
protected float currentValue
protected Vector3f direction
protected Vector3f lookAt
protected Vector3f upVector
protected Quaternion rotation
protected MotionEvent.Direction directionType
protected MotionPath path
protected float traveledDistance
public MotionEvent()
public MotionEvent(Spatial spatial, MotionPath path)
spatial
- the Spatial to move (not null)path
- the path to be taken (alias created)public MotionEvent(Spatial spatial, MotionPath path, float initialDuration)
spatial
- the Spatial to move (not null)path
- the path to be taken (alias created)initialDuration
- the desired duration (in seconds, default=10)public MotionEvent(Spatial spatial, MotionPath path, LoopMode loopMode)
spatial
- the Spatial to move (not null)path
- the path to be taken (alias created)loopMode
- (default=DontLoop)public MotionEvent(Spatial spatial, MotionPath path, float initialDuration, LoopMode loopMode)
spatial
- the Spatial to move (not null)path
- the path to be taken (alias created)initialDuration
- the desired duration (in seconds, default=10)loopMode
- (default=DontLoop)public void update(float tpf)
Control
public void internalUpdate(float tpf)
AbstractCinematicEvent
internalUpdate
in interface CinematicEvent
internalUpdate
in class AbstractCinematicEvent
tpf
- time per frame.public void initEvent(Application app, Cinematic cinematic)
AbstractCinematicEvent
initEvent
in interface CinematicEvent
initEvent
in class AbstractCinematicEvent
app
- ignoredcinematic
- ignoredpublic void setTime(float time)
AbstractCinematicEvent
setTime
in interface CinematicEvent
setTime
in class AbstractCinematicEvent
time
- the time to fast forward to.public void onUpdate(float tpf)
AbstractCinematicEvent
onUpdate
in class AbstractCinematicEvent
tpf
- time per framepublic void write(JmeExporter ex) throws java.io.IOException
AbstractCinematicEvent
write
in interface Savable
write
in class AbstractCinematicEvent
ex
- exporterjava.io.IOException
- from the exporterpublic void read(JmeImporter im) throws java.io.IOException
AbstractCinematicEvent
read
in interface Savable
read
in class AbstractCinematicEvent
im
- importerjava.io.IOException
- from the importerpublic boolean needsDirection()
@Deprecated public Control cloneForSpatial(Spatial spatial)
cloneForSpatial
in interface Control
spatial
- ignoredpublic java.lang.Object jmeClone()
JmeCloneable
This method is separate from the regular clone() method so that objects might still maintain their own regular java clone() semantics (perhaps even using Cloner for those methods). However, because Java's clone() has specific features in the sense of Object's clone() implementation, it's usually best to have some path for subclasses to bypass the public clone() method that might be cloning fields and instead get at the superclass protected clone() methods. For example, through super.jmeClone() or another protected clone method that some base class eventually calls super.clone() in.
jmeClone
in interface JmeCloneable
public void cloneFields(Cloner cloner, java.lang.Object original)
JmeCloneable
Note: during normal clone operations the original object will not be needed as the clone has already had all of the fields shallow copied.
cloneFields
in interface JmeCloneable
cloner
- The cloner that is performing the cloning operation. The
cloneFields method can call back into the cloner to make
clones of its subordinate fields.original
- The original object from which this object was cloned.
This is provided for the very rare case that this object needs
to refer to its original for some reason. In general, all of
the relevant values should have been transferred during the
shallow clone and this object need merely clone what it wants.public void onPlay()
AbstractCinematicEvent
onPlay
in class AbstractCinematicEvent
public void onStop()
AbstractCinematicEvent
onStop
in class AbstractCinematicEvent
public void onPause()
AbstractCinematicEvent
onPause
in class AbstractCinematicEvent
public float getCurrentValue()
public void setCurrentValue(float currentValue)
currentValue
- the desired valuepublic int getCurrentWayPoint()
public void setCurrentWayPoint(int currentWayPoint)
currentWayPoint
- the desired waypoint indexpublic Vector3f getDirection()
public void setDirection(Vector3f direction)
direction
- the desired forward direction (not null, unaffected)public void setDirection(Vector3f direction, Vector3f upVector)
direction
- the desired forward direction (not null, unaffected)upVector
- the up vector to consider for this direction.public MotionEvent.Direction getDirectionType()
public void setDirectionType(MotionEvent.Direction directionType)
directionType
- the direction type.public void setLookAt(Vector3f lookAt, Vector3f upVector)
lookAt
- the position to look at.upVector
- the up vector.public Quaternion getRotation()
public void setRotation(Quaternion rotation)
rotation
- the rotation quaternion.public MotionPath getPath()
public void setPath(MotionPath path)
path
- the desired path (alias created)public void setEnabled(boolean enabled)
public boolean isEnabled()
public void render(RenderManager rm, ViewPort vp)
Control
public void setSpatial(Spatial spatial)
setSpatial
in interface Control
spatial
- the spatial to be controlled. This should not be called
from user code.public Spatial getSpatial()
public float getTraveledDistance()