com.jme3.cinematic.events
Class MotionTrack

java.lang.Object
  extended by com.jme3.cinematic.events.AbstractCinematicEvent
      extended by com.jme3.cinematic.events.MotionTrack
All Implemented Interfaces:
CinematicEvent, Savable, Control

public class MotionTrack
extends AbstractCinematicEvent
implements Control

A MotionTrack is a control over the spatial that manage the position and direction of the spatial while following a motion Path You must first create a MotionPath and then create a MotionTrack to associate a spatial and the path.


Nested Class Summary
static class MotionTrack.Direction
          Enum for the different type of target direction behavior
 
Field Summary
protected  float currentValue
           
protected  int currentWayPoint
           
protected  Vector3f direction
           
protected  MotionTrack.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
           
 
Fields inherited from class com.jme3.cinematic.events.AbstractCinematicEvent
initialDuration, listeners, loopMode, playState, resuming, speed, time
 
Constructor Summary
MotionTrack()
          Create MotionTrack, when using this constructor don't forget to assign spatial and path
MotionTrack(Spatial spatial, MotionPath path)
          Creates a MotionPath for the given spatial on the given motion path
MotionTrack(Spatial spatial, MotionPath path, float initialDuration)
          Creates a MotionPath for the given spatial on the given motion path
MotionTrack(Spatial spatial, MotionPath path, float initialDuration, LoopMode loopMode)
          Creates a MotionPath for the given spatial on the given motion path
MotionTrack(Spatial spatial, MotionPath path, LoopMode loopMode)
          Creates a MotionPath for the given spatial on the given motion path
 
Method Summary
 Control cloneForSpatial(Spatial spatial)
          Clone this control for the given spatial
 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
 MotionTrack.Direction getDirectionType()
          returns the direction type of the target
 MotionPath getPath()
          retun 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 (should be called internally only)
 void internalUpdate(float tpf)
          should be used internally only
 boolean isEnabled()
           
 boolean needsDirection()
          this method is meant to be called by the motion path only
 void onPause()
          place here the code you want to execute when the event is paused
 void onPlay()
          Place here the code you want to execute when the event is started
 void onStop()
          Place here the code you want to execute when the event is stoped.
 void onUpdate(float tpf)
          Place here the code you want to execute on update (only called when the event is playing)
 void read(JmeImporter im)
          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 This method is used by the motion path.
 void setDirectionType(MotionTrack.Direction directionType)
          Sets the direction type of the target On each update the direction given to the target can have different behavior See the Direction Enum for explanations
 void setEnabled(boolean enabled)
           
 void setLookAt(Vector3f lookAt, Vector3f upVector)
          Set the lookAt for the target This can be used only if direction Type is Direction.LookAt
 void setPath(MotionPath path)
          Sets the motion path to follow
 void setRotation(Quaternion rotation)
          sets the rotation of the target This can be used only if direction Type is Direction.PathAndRotation or Direction.Rotation With PathAndRotation the target will face the direction of the path multiplied by the given Quaternion.
 void setSpatial(Spatial spatial)
           
 void setTime(float time)
          When this method is invoked, the event should fast forward to the given time according tim 0 is the start of the event.
 void update(float tpf)
          Updates the control.
 void write(JmeExporter ex)
          for serialization only
 
Methods inherited from class com.jme3.cinematic.events.AbstractCinematicEvent
addListener, getDuration, getInitialDuration, getLoopMode, getPlayState, getSpeed, getTime, pause, play, removeListener, setInitialDuration, setLoopMode, setSpeed, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

spatial

protected Spatial spatial

currentWayPoint

protected int currentWayPoint

currentValue

protected float currentValue

direction

protected Vector3f direction

lookAt

protected Vector3f lookAt

upVector

protected Vector3f upVector

rotation

protected Quaternion rotation

directionType

protected MotionTrack.Direction directionType

path

protected MotionPath path

traveledDistance

protected float traveledDistance
the distance traveled by the spatial on the path

Constructor Detail

MotionTrack

public MotionTrack()
Create MotionTrack, when using this constructor don't forget to assign spatial and path


MotionTrack

public MotionTrack(Spatial spatial,
                   MotionPath path)
Creates a MotionPath for the given spatial on the given motion path

Parameters:
spatial -
path -

MotionTrack

public MotionTrack(Spatial spatial,
                   MotionPath path,
                   float initialDuration)
Creates a MotionPath for the given spatial on the given motion path

Parameters:
spatial -
path -

MotionTrack

public MotionTrack(Spatial spatial,
                   MotionPath path,
                   LoopMode loopMode)
Creates a MotionPath for the given spatial on the given motion path

Parameters:
spatial -
path -

MotionTrack

public MotionTrack(Spatial spatial,
                   MotionPath path,
                   float initialDuration,
                   LoopMode loopMode)
Creates a MotionPath for the given spatial on the given motion path

Parameters:
spatial -
path -
Method Detail

update

public void update(float tpf)
Description copied from interface: Control
Updates the control. This should not be called from user code.

Specified by:
update in interface Control
Parameters:
tpf - Time per frame.

internalUpdate

public void internalUpdate(float tpf)
Description copied from class: AbstractCinematicEvent
should be used internally only

Specified by:
internalUpdate in interface CinematicEvent
Overrides:
internalUpdate in class AbstractCinematicEvent
Parameters:
tpf - time per frame

initEvent

public void initEvent(Application app,
                      Cinematic cinematic)
Description copied from class: AbstractCinematicEvent
initialize this event (should be called internally only)

Specified by:
initEvent in interface CinematicEvent
Overrides:
initEvent in class AbstractCinematicEvent
Parameters:
app - the application
cinematic - the cinematic

setTime

public void setTime(float time)
Description copied from class: AbstractCinematicEvent
When this method is invoked, the event should fast forward to the given time according tim 0 is the start of the event.

Specified by:
setTime in interface CinematicEvent
Overrides:
setTime in class AbstractCinematicEvent
Parameters:
time - the time to fast forward to

onUpdate

public void onUpdate(float tpf)
Description copied from class: AbstractCinematicEvent
Place here the code you want to execute on update (only called when the event is playing)

Specified by:
onUpdate in class AbstractCinematicEvent
Parameters:
tpf - time per frame

write

public void write(JmeExporter ex)
           throws java.io.IOException
Description copied from class: AbstractCinematicEvent
for serialization only

Specified by:
write in interface Savable
Overrides:
write in class AbstractCinematicEvent
Parameters:
ex - exporter
Throws:
java.io.IOException

read

public void read(JmeImporter im)
          throws java.io.IOException
Description copied from class: AbstractCinematicEvent
for serialization only

Specified by:
read in interface Savable
Overrides:
read in class AbstractCinematicEvent
Parameters:
im - importer
Throws:
java.io.IOException

needsDirection

public boolean needsDirection()
this method is meant to be called by the motion path only

Returns:

cloneForSpatial

public Control cloneForSpatial(Spatial spatial)
Clone this control for the given spatial

Specified by:
cloneForSpatial in interface Control
Parameters:
spatial -
Returns:

onPlay

public void onPlay()
Description copied from class: AbstractCinematicEvent
Place here the code you want to execute when the event is started

Specified by:
onPlay in class AbstractCinematicEvent

onStop

public void onStop()
Description copied from class: AbstractCinematicEvent
Place here the code you want to execute when the event is stoped.

Specified by:
onStop in class AbstractCinematicEvent

onPause

public void onPause()
Description copied from class: AbstractCinematicEvent
place here the code you want to execute when the event is paused

Specified by:
onPause in class AbstractCinematicEvent

getCurrentValue

public float getCurrentValue()
this method is meant to be called by the motion path only

Returns:

setCurrentValue

public void setCurrentValue(float currentValue)
this method is meant to be called by the motion path only


getCurrentWayPoint

public int getCurrentWayPoint()
this method is meant to be called by the motion path only

Returns:

setCurrentWayPoint

public void setCurrentWayPoint(int currentWayPoint)
this method is meant to be called by the motion path only


getDirection

public Vector3f getDirection()
returns the direction the spatial is moving

Returns:

setDirection

public void setDirection(Vector3f direction)
Sets the direction of the spatial This method is used by the motion path.

Parameters:
direction -

getDirectionType

public MotionTrack.Direction getDirectionType()
returns the direction type of the target

Returns:
the direction type

setDirectionType

public void setDirectionType(MotionTrack.Direction directionType)
Sets the direction type of the target On each update the direction given to the target can have different behavior See the Direction Enum for explanations

Parameters:
directionType - the direction type

setLookAt

public void setLookAt(Vector3f lookAt,
                      Vector3f upVector)
Set the lookAt for the target This can be used only if direction Type is Direction.LookAt

Parameters:
lookAt - the position to look at
upVector - the up vector

getRotation

public Quaternion getRotation()
returns the rotation of the target

Returns:
the rotation quaternion

setRotation

public void setRotation(Quaternion rotation)
sets the rotation of the target This can be used only if direction Type is Direction.PathAndRotation or Direction.Rotation With PathAndRotation the target will face the direction of the path multiplied by the given Quaternion. With Rotation the rotation of the target will be set with the given Quaternion.

Parameters:
rotation - the rotation quaternion

getPath

public MotionPath getPath()
retun the motion path this control follows

Returns:

setPath

public void setPath(MotionPath path)
Sets the motion path to follow

Parameters:
path -

setEnabled

public void setEnabled(boolean enabled)

isEnabled

public boolean isEnabled()

render

public void render(RenderManager rm,
                   ViewPort vp)
Description copied from interface: Control
Should be called prior to queuing the spatial by the RenderManager. This should not be called from user code.

Specified by:
render in interface Control

setSpatial

public void setSpatial(Spatial spatial)
Specified by:
setSpatial in interface Control
Parameters:
spatial - the spatial to be controlled. This should not be called from user code.

getSpatial

public Spatial getSpatial()

getTraveledDistance

public float getTraveledDistance()
return the distance traveled by the spatial on the path

Returns: