Search in sources :

Example 1 with Cinematic

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

the class AnimationEvent method read.

@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);
    if (im.getFormatVersion() == 0) {
        modelName = ic.readString("modelName", "");
    }
    //FIXME always the same issue, because of the clonning of assets, this won't work
    //we have to somehow store userdata in the spatial and then recurse the 
    //scene sub scenegraph to find the correct instance of the model
    //This brings a reflaxion about the cinematic being an appstate, 
    //shouldn't it be a control over the scene
    // this would allow to use the cloneForSpatial method and automatically 
    //rebind cloned references of original objects.
    //for now as nobody probably ever saved a cinematic, this is not a critical issue
    model = (Spatial) ic.readSavable("model", null);
    animationName = ic.readString("animationName", "");
    blendTime = ic.readFloat("blendTime", 0f);
    channelIndex = ic.readInt("channelIndex", 0);
}
Also used : InputCapsule(com.jme3.export.InputCapsule)

Example 2 with Cinematic

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

the class Cinematic method bindCamera.

/**
     * Binds a camera to this cinematic, tagged by a unique name. This methods
     * creates and returns a CameraNode for the cam and attach 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 the
     * playback
     *
     * @param cameraName the unique tag the camera should have
     * @param cam the scene camera.
     * @return the created CameraNode.
     */
public CameraNode bindCamera(String cameraName, Camera cam) {
    if (cameras.containsKey(cameraName)) {
        throw new IllegalArgumentException("Camera " + cameraName + " is already binded to this cinematic");
    }
    CameraNode node = new CameraNode(cameraName, cam);
    node.setControlDir(ControlDirection.SpatialToCamera);
    node.getControl(CameraControl.class).setEnabled(false);
    cameras.put(cameraName, node);
    scene.attachChild(node);
    return node;
}
Also used : CameraNode(com.jme3.scene.CameraNode) CameraControl(com.jme3.scene.control.CameraControl)

Example 3 with Cinematic

use of com.jme3.cinematic.Cinematic 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 Cinematic

use of com.jme3.cinematic.Cinematic 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 Cinematic

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

the class Cinematic method setSpeed.

/**
     * 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
     *
     * @param speed the speed
     */
@Override
public void setSpeed(float speed) {
    super.setSpeed(speed);
    for (int i = 0; i < cinematicEvents.size(); i++) {
        CinematicEvent ce = cinematicEvents.get(i);
        ce.setSpeed(speed);
    }
}
Also used : AbstractCinematicEvent(com.jme3.cinematic.events.AbstractCinematicEvent) CinematicEvent(com.jme3.cinematic.events.CinematicEvent)

Aggregations

AnimControl (com.jme3.animation.AnimControl)3 AbstractCinematicEvent (com.jme3.cinematic.events.AbstractCinematicEvent)3 CinematicEvent (com.jme3.cinematic.events.CinematicEvent)3 AnimationFactory (com.jme3.animation.AnimationFactory)2 Cinematic (com.jme3.cinematic.Cinematic)2 AnimationEvent (com.jme3.cinematic.events.AnimationEvent)2 Vector3f (com.jme3.math.Vector3f)2 CameraNode (com.jme3.scene.CameraNode)2 Animation (com.jme3.animation.Animation)1 AudioNode (com.jme3.audio.AudioNode)1 MotionPath (com.jme3.cinematic.MotionPath)1 MotionEvent (com.jme3.cinematic.events.MotionEvent)1 InputCapsule (com.jme3.export.InputCapsule)1 BitmapText (com.jme3.font.BitmapText)1 ChaseCamera (com.jme3.input.ChaseCamera)1 NiftyJmeDisplay (com.jme3.niftygui.NiftyJmeDisplay)1 Node (com.jme3.scene.Node)1 CameraControl (com.jme3.scene.control.CameraControl)1 Nifty (de.lessvoid.nifty.Nifty)1 Test (org.junit.Test)1