com.jme3.cinematic.events
Class AbstractCinematicEvent

java.lang.Object
  extended by com.jme3.cinematic.events.AbstractCinematicEvent
All Implemented Interfaces:
CinematicEvent, Savable
Direct Known Subclasses:
AnimationTrack, Cinematic, GuiTrack, MotionTrack, PositionTrack, RotationTrack, ScaleTrack, SoundTrack

public abstract class AbstractCinematicEvent
extends java.lang.Object
implements CinematicEvent

This calls contains basic behavior of a cinematic event every cinematic event must extend this class A cinematic event must be given an inital duration in seconds (duration of the event at speed = 1) (default is 10)


Field Summary
protected  float initialDuration
           
protected  java.util.List<CinematicEventListener> listeners
          the list of listeners
protected  LoopMode loopMode
           
protected  PlayState playState
           
protected  boolean resuming
           
protected  float speed
           
protected  float time
           
 
Constructor Summary
AbstractCinematicEvent()
          contruct a cinematic event
AbstractCinematicEvent(float initialDuration)
          contruct a cinematic event wwith the given initial duration
AbstractCinematicEvent(float initialDuration, LoopMode loopMode)
          contruct a cinematic event with the given loopMode and the given initialDuration
AbstractCinematicEvent(LoopMode loopMode)
          contruct a cinematic event with the given loopMode
 
Method Summary
 void addListener(CinematicEventListener listener)
          Add a CinematicEventListener to this event
 float getDuration()
          returns the actual duration of the animtion (initialDuration/speed)
 float getInitialDuration()
          returns the initial duration of the animation at speed = 1 in seconds.
 LoopMode getLoopMode()
          retursthe loopMode of the animation
 PlayState getPlayState()
          Returns the current playstate of the animation
 float getSpeed()
          returns the speed of the animation.
 float getTime()
          returns the current time of the cinematic event
 void initEvent(Application app, Cinematic cinematic)
          initialize this event (should be called internally only)
 void internalUpdate(float tpf)
          should be used internally only
abstract  void onPause()
          place here the code you want to execute when the event is paused
protected abstract  void onPlay()
          Place here the code you want to execute when the event is started
protected abstract  void onStop()
          Place here the code you want to execute when the event is stoped.
protected abstract  void onUpdate(float tpf)
          Place here the code you want to execute on update (only called when the event is playing)
 void pause()
          pause this event
 void play()
          Play this event
 void read(JmeImporter im)
          for serialization only
 void removeListener(CinematicEventListener listener)
          remove a CinematicEventListener from this event
 void setInitialDuration(float initialDuration)
          Sets the duration of the antionamtion at speed = 1 in seconds
 void setLoopMode(LoopMode loopMode)
          Sets the loopMode of the animation
 void setSpeed(float speed)
          Sets the speed of the animation.
 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 stop()
          stops the animation, next time play() is called the animation will start from the begining.
 void write(JmeExporter ex)
          for serialization only
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

playState

protected PlayState playState

speed

protected float speed

initialDuration

protected float initialDuration

loopMode

protected LoopMode loopMode

time

protected float time

resuming

protected boolean resuming

listeners

protected java.util.List<CinematicEventListener> listeners
the list of listeners

Constructor Detail

AbstractCinematicEvent

public AbstractCinematicEvent()
contruct a cinematic event


AbstractCinematicEvent

public AbstractCinematicEvent(float initialDuration)
contruct a cinematic event wwith the given initial duration

Parameters:
initialDuration -

AbstractCinematicEvent

public AbstractCinematicEvent(LoopMode loopMode)
contruct a cinematic event with the given loopMode

Parameters:
loopMode -

AbstractCinematicEvent

public AbstractCinematicEvent(float initialDuration,
                              LoopMode loopMode)
contruct a cinematic event with the given loopMode and the given initialDuration

Parameters:
initialDuration - the duration of the event at speed = 1
loopMode - the loop mode of the event
Method Detail

play

public void play()
Play this event

Specified by:
play in interface CinematicEvent

onPlay

protected abstract void onPlay()
Place here the code you want to execute when the event is started


internalUpdate

public void internalUpdate(float tpf)
should be used internally only

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

onUpdate

protected abstract void onUpdate(float tpf)
Place here the code you want to execute on update (only called when the event is playing)

Parameters:
tpf - time per frame

stop

public void stop()
stops the animation, next time play() is called the animation will start from the begining.

Specified by:
stop in interface CinematicEvent

onStop

protected abstract void onStop()
Place here the code you want to execute when the event is stoped.


pause

public void pause()
pause this event

Specified by:
pause in interface CinematicEvent

onPause

public abstract void onPause()
place here the code you want to execute when the event is paused


getDuration

public float getDuration()
returns the actual duration of the animtion (initialDuration/speed)

Specified by:
getDuration in interface CinematicEvent
Returns:

setSpeed

public void setSpeed(float speed)
Sets the speed of the animation. At speed = 1, the animation will last initialDuration seconds, At speed = 2 the animation will last initialDuraiton/2...

Specified by:
setSpeed in interface CinematicEvent
Parameters:
speed -

getSpeed

public float getSpeed()
returns the speed of the animation.

Specified by:
getSpeed in interface CinematicEvent
Returns:

getPlayState

public PlayState getPlayState()
Returns the current playstate of the animation

Specified by:
getPlayState in interface CinematicEvent
Returns:

getInitialDuration

public float getInitialDuration()
returns the initial duration of the animation at speed = 1 in seconds.

Specified by:
getInitialDuration in interface CinematicEvent
Returns:

setInitialDuration

public void setInitialDuration(float initialDuration)
Sets the duration of the antionamtion at speed = 1 in seconds

Specified by:
setInitialDuration in interface CinematicEvent
Parameters:
initialDuration -

getLoopMode

public LoopMode getLoopMode()
retursthe loopMode of the animation

Specified by:
getLoopMode in interface CinematicEvent
Returns:
See Also:
LoopMode

setLoopMode

public void setLoopMode(LoopMode loopMode)
Sets the loopMode of the animation

Specified by:
setLoopMode in interface CinematicEvent
Parameters:
loopMode -
See Also:
LoopMode

write

public void write(JmeExporter ex)
           throws java.io.IOException
for serialization only

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

read

public void read(JmeImporter im)
          throws java.io.IOException
for serialization only

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

initEvent

public void initEvent(Application app,
                      Cinematic cinematic)
initialize this event (should be called internally only)

Specified by:
initEvent in interface CinematicEvent
Parameters:
app -
cinematic -

addListener

public void addListener(CinematicEventListener listener)
Add a CinematicEventListener to this event

Parameters:
listener - CinematicEventListener

removeListener

public void removeListener(CinematicEventListener listener)
remove a CinematicEventListener from this event

Parameters:
listener - CinematicEventListener

setTime

public 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.

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

getTime

public float getTime()
Description copied from interface: CinematicEvent
returns the current time of the cinematic event

Specified by:
getTime in interface CinematicEvent
Returns:
the time