Search in sources :

Example 1 with PlayState

use of com.jme3.cinematic.PlayState in project jmonkeyengine by jMonkeyEngine.

the class AbstractCinematicEvent method write.

/**
     * Used for serialization only.
     * @param ex exporter
     * @throws IOException 
     */
public void write(JmeExporter ex) throws IOException {
    OutputCapsule oc = ex.getCapsule(this);
    oc.write(playState, "playState", PlayState.Stopped);
    oc.write(speed, "speed", 1);
    oc.write(initialDuration, "initalDuration", 10);
    oc.write(loopMode, "loopMode", LoopMode.DontLoop);
}
Also used : OutputCapsule(com.jme3.export.OutputCapsule)

Example 2 with PlayState

use of com.jme3.cinematic.PlayState 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 3 with PlayState

use of com.jme3.cinematic.PlayState in project jmonkeyengine by jMonkeyEngine.

the class AbstractCinematicEvent method read.

/**
     * Used for serialization only.
     * @param im importer
     * @throws IOException 
     */
public void read(JmeImporter im) throws IOException {
    InputCapsule ic = im.getCapsule(this);
    playState = ic.readEnum("playState", PlayState.class, PlayState.Stopped);
    speed = ic.readFloat("speed", 1);
    initialDuration = ic.readFloat("initalDuration", 10);
    loopMode = ic.readEnum("loopMode", LoopMode.class, LoopMode.DontLoop);
}
Also used : LoopMode(com.jme3.animation.LoopMode) InputCapsule(com.jme3.export.InputCapsule) PlayState(com.jme3.cinematic.PlayState)

Aggregations

LoopMode (com.jme3.animation.LoopMode)1 PlayState (com.jme3.cinematic.PlayState)1 AbstractCinematicEvent (com.jme3.cinematic.events.AbstractCinematicEvent)1 CinematicEvent (com.jme3.cinematic.events.CinematicEvent)1 InputCapsule (com.jme3.export.InputCapsule)1 OutputCapsule (com.jme3.export.OutputCapsule)1