[Resolved] MotionControl: spatials slow down on curved paths

Hi,



I’m currently using the latest nightly and my spatials slow down for negotiate a (non smoothed) MotionPath turn while they didn’t act like this before.

Although this is a very useful feature I didn’t find how to disable this behavior.



Does somebody know?

up?

The speed should be constant.

you say it didn’t act like this before…but before what?

A test case could be handy

@nehon said:
you say it didn't act like this before.....but before what?


I would bet "before he updated". ;)
1 Like

Hi,



it didn’t act like this when I wasn’t using the nighlty.



I currently have a projet with default jme version in wich the speed is constant and the very same project running on nighlty in wich the spatial’s speed isn’t the same with staight lines and curves. Actually it act like homing missile.



I got troubles previously with MotionTrack::pause() method and you answered me that there were heavy changes in the latest SVN.

I thought that my new “issue” has a link with these changes.



I’ll send you a test case tonight.

Tonight!



[java]

package mygame;



import com.jme3.animation.LoopMode;

import com.jme3.app.SimpleApplication;

import com.jme3.cinematic.MotionPath;

import com.jme3.cinematic.events.MotionTrack;

import com.jme3.light.DirectionalLight;

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.Spatial;

import com.jme3.scene.shape.Box;

import com.jme3.system.AppSettings;



public class Main extends SimpleApplication {



DirectionalLight sun;



public static SimpleApplication sapp;



public static void main(String[] args) {

Main app = new Main();

sapp = (SimpleApplication) app;

AppSettings settings = new AppSettings(true);

settings.setFrameRate(60);

app.setSettings(settings);

app.start();

}







@Override

public void simpleInitApp() {

sun = new DirectionalLight();

sun.setDirection(new Vector3f(0,-1,0).normalizeLocal());

sun.setColor(ColorRGBA.White);

sapp.getRootNode().addLight(sun);



sapp.getCamera().lookAtDirection(new Vector3f(0,-1,0), new Vector3f(0,0,-1));

sapp.getCamera().setLocation(new Vector3f(0f,30f,0f));



Box box = new Box(Vector3f.ZERO, 1f,1f,1f);

Material mat = new Material(sapp.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");

mat.setColor("Color", ColorRGBA.Blue);

Spatial spatial = new Geometry("test", box);

spatial.setMaterial(mat);



sapp.getRootNode().attachChild(spatial);



MotionPath path = new MotionPath();

path.addWayPoint(new Vector3f(-10, 0, -10));

path.addWayPoint(new Vector3f(-10, 0, 10));

path.addWayPoint(new Vector3f(0, 0, -10));

path.addWayPoint(new Vector3f(0, 0, 10));

path.setCurveTension(0);

path.setCycle(true);



MotionTrack motionControl = new MotionTrack(spatial, path);

motionControl.setSpeed(2);

motionControl.setLoopMode(LoopMode.Loop);

motionControl.play();

}



@Override

public void simpleUpdate(float tpf) {



}



@Override

public void simpleRender(RenderManager rm) {

//TODO: add render code

}

}



[/java]

phew…This day was never ending… :wink:

ok i tested it…I guess the problem is that you use a catmull-rom interpolation and set the curve tension to 0, it looks like a linear path but you may have some “roundness” around the turns.

Is that for the example or do you really want a linear path? because you can set the path spline type to linear

[java]

path.setPathSplineType(SplineType.Linear);

[/java]

Perfect!



your line made it works like a charm.



Thanks a lot.