Cinematic motionEvent setTime bug

Hello,
it seems that there is a bug when using MotionEvents when not playing the cinematic but manually calling setTime.
The event reverts to the starting position once the time of the cinematic is greater than the initialduration of the MotionEvent.

On further investigation I found out that the spatial does not change the translation smoothly. While the output of spatial.getWorldTranslation() is like this:

(0.32764757, 0.5, 0.0)
(0.41019493, 0.5, 0.0)
(0.49423054, 0.5, 0.0)
(0.5762775, 0.5, 0.0)
(0.66033393, 0.5, 0.0)
(0.7427033, 0.5, 0.0)
(0.8274445, 0.5, 0.0)
(0.90997744, 0.5, 0.0)
(0.9932416, 0.5, 0.0)
(1.0802809, 0.5, 0.0)

when playing the cinematic; it is like this:

(8.1, 0.5, 0.0)
(0.0, 0.5, 0.0)
(0.0, 0.5, 0.0)
(8.125, 0.5, 0.0)
(0.0, 0.5, 0.0)
(0.0, 0.5, 0.0)
(8.175, 0.5, 0.0)
(0.0, 0.5, 0.0)
(0.0, 0.5, 0.0)
(8.200001, 0.5, 0.0)
(0.0, 0.5, 0.0)
(0.0, 0.5, 0.0)
(8.225, 0.5, 0.0)
(0.0, 0.5, 0.0)
(0.0, 0.5, 0.0)
(8.25, 0.5, 0.0)
(0.0, 0.5, 0.0)
(0.0, 0.5, 0.0)

when setting the time manually. (0, 0.5, 0) is the start WayPoint of the MotionEvent.

Is this a bug or am I doing something wrong?

Could you provide your testcase? (the one displaying the output)

Alright, the output seems to be due to my code as it does not appear in the test case. However, after the MotionEvent finished, the spatial gets back to the starting position and continues to follow the MotionPath then. This does not appear when I call cinematic.play(); then I get the expected behavior of the geometry following the MotionPath and stopping at the end of it. Once the cinematic is finished, the spatial is back at the starting position.

This is the test case:

package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.cinematic.Cinematic;
import com.jme3.cinematic.MotionPath;
import com.jme3.cinematic.events.MotionEvent;
import com.jme3.light.AmbientLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;

/**
 * test
 *
 * @author normenhansen
 */
public class Main extends SimpleApplication {

    private Geometry box;
    private Cinematic cinematic;
    private float time = 0;

    public static void main(String[] args) {
        Main app = new Main();
        app.start();
    }

    @Override
    public void simpleInitApp() {
        Box boxMesh = new Box(1f, 1f, 1f);
        box = new Geometry("Colored Box", boxMesh);
        Material boxMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
        boxMat.setBoolean("UseMaterialColors", true);
        boxMat.setColor("Ambient", ColorRGBA.Green);
        boxMat.setColor("Diffuse", ColorRGBA.Green);
        box.setMaterial(boxMat);
        rootNode.attachChild(box);

        AmbientLight ambient = new AmbientLight();
        ambient.setColor(ColorRGBA.White);
        rootNode.addLight(ambient);

        cinematic = new Cinematic();
        MotionPath path = new MotionPath();
        path.addWayPoint(new Vector3f(0, 0, 0));
        path.addWayPoint(new Vector3f(5, 0, 0));
        cinematic.addCinematicEvent(0, new MotionEvent(box, path, 3));
        cinematic.setInitialDuration(5);
        stateManager.attach(cinematic);
        //cinematic.play();
    }

    @Override
    public void simpleUpdate(float tpf) {
        time += tpf;
        cinematic.setTime(time);
    }

    @Override
    public void simpleRender(RenderManager rm) {
        //TODO: add render code
    }
}

I’m using 3.1 by the way.

Was the testcase useful? Did you find anything?

I’m sorry. unfortunately i cannot find some time to work on JME lately. You’ll have to be patient.

No problem haha I was just wondering if you had seen my post. Thank you for the effort you put into this project!