Search in sources :

Example 1 with CinematicEvent

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;
}
Also used : AbstractCinematicEvent(com.jme3.cinematic.events.AbstractCinematicEvent) CinematicEvent(com.jme3.cinematic.events.CinematicEvent)

Example 2 with CinematicEvent

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);
}
Also used : AbstractCinematicEvent(com.jme3.cinematic.events.AbstractCinematicEvent) CinematicEvent(com.jme3.cinematic.events.CinematicEvent)

Example 3 with CinematicEvent

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();
    }
}
Also used : AbstractCinematicEvent(com.jme3.cinematic.events.AbstractCinematicEvent) CinematicEvent(com.jme3.cinematic.events.CinematicEvent)

Example 4 with CinematicEvent

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;
}
Also used : AbstractCinematicEvent(com.jme3.cinematic.events.AbstractCinematicEvent) CinematicEvent(com.jme3.cinematic.events.CinematicEvent)

Example 5 with CinematicEvent

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;
}
Also used : AbstractCinematicEvent(com.jme3.cinematic.events.AbstractCinematicEvent) CinematicEvent(com.jme3.cinematic.events.CinematicEvent)

Aggregations

AbstractCinematicEvent (com.jme3.cinematic.events.AbstractCinematicEvent)6 CinematicEvent (com.jme3.cinematic.events.CinematicEvent)6 AnimControl (com.jme3.animation.AnimControl)1 AnimationFactory (com.jme3.animation.AnimationFactory)1 Cinematic (com.jme3.cinematic.Cinematic)1 BitmapText (com.jme3.font.BitmapText)1 ChaseCamera (com.jme3.input.ChaseCamera)1 Vector3f (com.jme3.math.Vector3f)1 NiftyJmeDisplay (com.jme3.niftygui.NiftyJmeDisplay)1 Nifty (de.lessvoid.nifty.Nifty)1