Package com.jme3.cinematic
Class Cinematic
java.lang.Object
com.jme3.cinematic.events.AbstractCinematicEvent
com.jme3.cinematic.Cinematic
- All Implemented Interfaces:
AppState
,CinematicEvent
,Savable
An appstate for composing and playing cutscenes in a game. The cinematic
schedules CinematicEvents over a timeline. Once the Cinematic created it has
to be attached to the stateManager.
You can add various CinematicEvents to a Cinematic, see package
com.jme3.cinematic.events
Two main methods can be used to add an event :
- See Also:
-
, that adds an event at the given time form the cinematic start.
that enqueue events one after the other according to their initialDuration A Cinematic has convenient methods to manage playback:
AbstractCinematicEvent.play()
AbstractCinematicEvent.pause()
A Cinematic is itself a CinematicEvent, meaning you can embed several cinematics. Embedded cinematics must not be added to the stateManager though. Cinematic can handle several points of view by creating camera nodes and activating them on schedule.
bindCamera(java.lang.String, com.jme3.renderer.Camera)
activateCamera(float, java.lang.String)
setActiveCamera(java.lang.String)
-
Field Summary
Fields inherited from class com.jme3.cinematic.events.AbstractCinematicEvent
initialDuration, listeners, loopMode, playState, resuming, speed, time
-
Constructor Summary
ModifierConstructorDescriptionprotected
Used for serialization creates a cinematic, don't use this constructor directlyCinematic
(float initialDuration) creates a cinematiccreates a cinematiccreates a cinematiccreates a cinematic -
Method Summary
Modifier and TypeMethodDescriptionvoid
activateCamera
(float timeStamp, String cameraName) schedule an event that will activate the camera at the given timeaddCinematicEvent
(float timeStamp, CinematicEvent cinematicEvent) Adds a cinematic event to this cinematic at the given timestamp.bindCamera
(String cameraName, Camera cam) Binds a camera to this Cinematic, tagged by a unique name.void
cleanup()
called internallyvoid
clear()
Remove all events from the Cinematic.void
dispose()
used internally to clean up the cinematic.float
enqueueCinematicEvent
(CinematicEvent cinematicEvent) Enqueue a cinematic event to a Cinematic.void
fits the duration of the cinematic to the duration of all its child cinematic eventsreturns a cameraNode given its namegetEventData
(String type, Object key) used internally return and event datagetId()
Returns the unique ID for this AppState or null if it has no unique ID.getScene()
return the scene where the cinematic occurvoid
initialize
(AppStateManager stateManager, Application app) used internallyboolean
return true if the cinematic appstate is enabled (the cinematic is playing)boolean
used internallyvoid
onPause()
called internallyvoid
onPlay()
called internallyvoid
onStop()
called internallyvoid
onUpdate
(float tpf) used internally, don't call this directly.void
called internallyvoid
putEventData
(String type, Object key, Object object) used internally put an eventdata in the cinematicvoid
read
(JmeImporter im) used internally for serializationboolean
removeCinematicEvent
(float timeStamp, CinematicEvent cinematicEvent) removes the first occurrence found of the given cinematicEvent for the given time stamp.boolean
removeCinematicEvent
(CinematicEvent cinematicEvent) removes the first occurrence found of the given cinematicEvent.boolean
removeCinematicEvent
(KeyFrame keyFrame, CinematicEvent cinematicEvent) removes the first occurrence found of the given cinematicEvent for the given keyFramevoid
removeEventData
(String type, Object key) Used internally remove an eventDatavoid
render
(RenderManager rm) called internallyvoid
setActiveCamera
(String cameraName) Sets the active camera instantly (use activateCamera if you want to schedule that event)void
setEnabled
(boolean enabled) passing true has the same effect as play() you should use play(), pause(), stop() to handle the cinematic playing state.protected void
Sets the unique ID of this app state.void
sets the scene to use for this cinematic it is expected that the scene is added before adding events to the cinematicvoid
setSpeed
(float speed) sets the speed of the cinematic.void
setTime
(float time) This is used internally but can be called to shuffle through the cinematic.void
stateAttached
(AppStateManager stateManager) called internallyvoid
stateDetached
(AppStateManager stateManager) called internallyvoid
update
(float tpf) called internally don't call it directly.void
write
(JmeExporter ex) used internally for serializationMethods inherited from class com.jme3.cinematic.events.AbstractCinematicEvent
addListener, forceStop, getDuration, getInitialDuration, getLoopMode, getPlayState, getSpeed, getTime, initEvent, internalUpdate, pause, play, removeListener, setInitialDuration, setLoopMode, stop
-
Field Details
-
timeLine
-
-
Constructor Details
-
Cinematic
protected Cinematic()Used for serialization creates a cinematic, don't use this constructor directly -
Cinematic
public Cinematic(float initialDuration) -
Cinematic
-
Cinematic
-
Cinematic
creates a cinematic- Parameters:
scene
- the scene in which the cinematic should take place
-
Cinematic
creates a cinematic- Parameters:
scene
- the scene in which the cinematic should take placeinitialDuration
- the duration of the cinematic (without considering the speed)
-
Cinematic
creates a cinematic- Parameters:
scene
- the scene in which the cinematic should take placeloopMode
- tells if this cinematic should be looped or not
-
Cinematic
creates a cinematic- Parameters:
scene
- the scene in which the cinematic should take placeinitialDuration
- the duration of the cinematic (without considering the speed)loopMode
- tells if this cinematic should be looped or not
-
-
Method Details
-
onPlay
public void onPlay()called internally- Specified by:
onPlay
in classAbstractCinematicEvent
-
onStop
public void onStop()called internally- Specified by:
onStop
in classAbstractCinematicEvent
-
onPause
public void onPause()called internally- Specified by:
onPause
in classAbstractCinematicEvent
-
write
used internally for serialization- Specified by:
write
in interfaceSavable
- Overrides:
write
in classAbstractCinematicEvent
- Parameters:
ex
- the exporter (not null)- Throws:
IOException
- from the exporter
-
read
used internally for serialization- Specified by:
read
in interfaceSavable
- Overrides:
read
in classAbstractCinematicEvent
- Parameters:
im
- the importer (not null)- Throws:
IOException
- from the importer
-
setSpeed
public void setSpeed(float speed) sets the speed of the cinematic. Note that it will set the speed of all events in the cinematic. 1 is normal speed. use 0.5f to make the cinematic twice slower, use 2 to make it twice faster- Specified by:
setSpeed
in interfaceCinematicEvent
- Overrides:
setSpeed
in classAbstractCinematicEvent
- Parameters:
speed
- the speed
-
initialize
used internally- Specified by:
initialize
in interfaceAppState
- Parameters:
stateManager
- the state managerapp
- the application
-
isInitialized
public boolean isInitialized()used internally- Specified by:
isInitialized
in interfaceAppState
- Returns:
- true if initialized, otherwise false
-
setId
Sets the unique ID of this app state. Note: that setting this while an app state is attached to the state manager will have no effect on ID-based lookups.- Parameters:
id
- the desired ID
-
getId
Description copied from interface:AppState
Returns the unique ID for this AppState or null if it has no unique ID. -
setEnabled
public void setEnabled(boolean enabled) passing true has the same effect as play() you should use play(), pause(), stop() to handle the cinematic playing state.- Specified by:
setEnabled
in interfaceAppState
- Parameters:
enabled
- true or false
-
isEnabled
public boolean isEnabled()return true if the cinematic appstate is enabled (the cinematic is playing) -
stateAttached
called internally- Specified by:
stateAttached
in interfaceAppState
- Parameters:
stateManager
- the state manager
-
stateDetached
called internally- Specified by:
stateDetached
in interfaceAppState
- Parameters:
stateManager
- the state manager
-
update
public void update(float tpf) called internally don't call it directly. -
onUpdate
public void onUpdate(float tpf) used internally, don't call this directly.- Specified by:
onUpdate
in classAbstractCinematicEvent
- Parameters:
tpf
- time per frame (in seconds)
-
setTime
public void setTime(float time) This is used internally but can be called to shuffle through the cinematic.- Specified by:
setTime
in interfaceCinematicEvent
- Overrides:
setTime
in classAbstractCinematicEvent
- Parameters:
time
- the time to shuffle to.
-
addCinematicEvent
Adds a cinematic event to this cinematic at the given timestamp. This operation returns a keyFrame- Parameters:
timeStamp
- the time when the event will start after the beginning of the cinematiccinematicEvent
- the cinematic event- Returns:
- the keyFrame for that event.
-
enqueueCinematicEvent
Enqueue a cinematic event to a Cinematic. This is handy when you want to chain events without knowing their durations.- Parameters:
cinematicEvent
- the cinematic event to enqueue- Returns:
- the timestamp the event was scheduled.
-
removeCinematicEvent
removes the first occurrence found of the given cinematicEvent.- Parameters:
cinematicEvent
- the cinematicEvent to remove- Returns:
- true if the element has been removed
-
removeCinematicEvent
removes the first occurrence found of the given cinematicEvent for the given time stamp.- Parameters:
timeStamp
- the timestamp when the cinematicEvent has been addedcinematicEvent
- the cinematicEvent to remove- Returns:
- true if the element has been removed
-
removeCinematicEvent
removes the first occurrence found of the given cinematicEvent for the given keyFrame- Parameters:
keyFrame
- the keyFrame returned by the addCinematicEvent method.cinematicEvent
- the cinematicEvent to remove- Returns:
- true if the element has been removed
-
render
called internally -
postRender
public void postRender()called internally- Specified by:
postRender
in interfaceAppState
- See Also:
-
cleanup
public void cleanup()called internally -
fitDuration
public void fitDuration()fits the duration of the cinematic to the duration of all its child cinematic events -
bindCamera
Binds a camera to this Cinematic, tagged by a unique name. This method creates and returns a CameraNode for the cam and attaches it to the scene. The control direction is set to SpatialToCamera. This camera Node can then be used in other events to handle the camera movements during playback.- Parameters:
cameraName
- the unique tag the camera should havecam
- the scene camera.- Returns:
- the created CameraNode.
-
getCamera
returns a cameraNode given its name- Parameters:
cameraName
- the camera name (as registered in Cinematic#bindCamera())- Returns:
- the cameraNode for this name
-
setActiveCamera
Sets the active camera instantly (use activateCamera if you want to schedule that event)- Parameters:
cameraName
- the camera name (as registered in Cinematic#bindCamera())
-
activateCamera
schedule an event that will activate the camera at the given time- Parameters:
timeStamp
- the time to activate the camcameraName
- the camera name (as registered in Cinematic#bindCamera())
-
putEventData
used internally put an eventdata in the cinematic- Parameters:
type
- the type of datakey
- the keyobject
- the data
-
getEventData
used internally return and event data- Parameters:
type
- the type of datakey
- the key- Returns:
- the pre-existing object, or null
-
removeEventData
Used internally remove an eventData- Parameters:
type
- the type of datakey
- the key of the data
-
setScene
sets the scene to use for this cinematic it is expected that the scene is added before adding events to the cinematic- Parameters:
scene
- the scene where the cinematic should take place.
-
getScene
return the scene where the cinematic occur- Returns:
- the scene
-
clear
public void clear()Remove all events from the Cinematic. -
dispose
public void dispose()used internally to clean up the cinematic. Called when the clear() method is called- Specified by:
dispose
in interfaceCinematicEvent
- Overrides:
dispose
in classAbstractCinematicEvent
-