use of com.jme3.cinematic.events.CinematicEvent in project jmonkeyengine by jMonkeyEngine.
the class Cinematic method initialize.
/**
* used internally
*
* @param stateManager the state manager
* @param app the application
*/
public void initialize(AppStateManager stateManager, Application app) {
initEvent(app, this);
for (CinematicEvent cinematicEvent : cinematicEvents) {
cinematicEvent.initEvent(app, this);
}
initialized = true;
}
use of com.jme3.cinematic.events.CinematicEvent in project jmonkeyengine by jMonkeyEngine.
the class Cinematic method onStop.
/**
* called internally
*/
@Override
public void onStop() {
time = 0;
lastFetchedKeyFrame = -1;
for (int i = 0; i < cinematicEvents.size(); i++) {
CinematicEvent ce = cinematicEvents.get(i);
ce.setTime(0);
ce.forceStop();
}
setEnableCurrentCam(false);
}
use of com.jme3.cinematic.events.CinematicEvent in project jmonkeyengine by jMonkeyEngine.
the class Cinematic method setTime.
/**
* This is used internally but can be called to shuffle through the
* cinematic.
*
* @param time the time to shuffle to.
*/
@Override
public void setTime(float time) {
//stopping all events
onStop();
super.setTime(time);
int keyFrameIndex = timeLine.getKeyFrameIndexFromTime(time);
//then computing timeOffset for each event
for (int i = 0; i <= keyFrameIndex; i++) {
KeyFrame keyFrame = timeLine.get(i);
if (keyFrame != null) {
for (CinematicEvent ce : keyFrame.getCinematicEvents()) {
float t = this.time - timeLine.getKeyFrameTime(keyFrame);
if (t >= 0 && (t <= ce.getInitialDuration() || ce.getLoopMode() != LoopMode.DontLoop)) {
ce.play();
}
ce.setTime(t);
}
}
}
lastFetchedKeyFrame = keyFrameIndex;
if (playState != PlayState.Playing) {
pause();
}
}
use of com.jme3.cinematic.events.CinematicEvent in project jmonkeyengine by jMonkeyEngine.
the class Cinematic method fitDuration.
/**
* fits the duration of the cinematic to the duration of all its child
* cinematic events
*/
public void fitDuration() {
KeyFrame kf = timeLine.getKeyFrameAtIndex(timeLine.getLastKeyFrameIndex());
float d = 0;
for (int i = 0; i < kf.getCinematicEvents().size(); i++) {
CinematicEvent ce = kf.getCinematicEvents().get(i);
float dur = timeLine.getKeyFrameTime(kf) + ce.getDuration() * ce.getSpeed();
if (d < dur) {
d = dur;
}
}
initialDuration = d;
}
use of com.jme3.cinematic.events.CinematicEvent in project jmonkeyengine by jMonkeyEngine.
the class Cinematic method onUpdate.
/**
* used internally, don't call this directly.
*
* @param tpf
*/
@Override
public void onUpdate(float tpf) {
int keyFrameIndex = timeLine.getKeyFrameIndexFromTime(time);
//iterate to make sure every key frame is triggered
for (int i = lastFetchedKeyFrame + 1; i <= keyFrameIndex; i++) {
KeyFrame keyFrame = timeLine.get(i);
if (keyFrame != null) {
keyFrame.trigger();
}
}
for (int i = 0; i < cinematicEvents.size(); i++) {
CinematicEvent ce = cinematicEvents.get(i);
ce.internalUpdate(tpf);
}
lastFetchedKeyFrame = keyFrameIndex;
}
Aggregations