When I add two new waypoints to my motionpath there’s also drawed a new line to the starting point(see the picture). I don’t want this line to be drawed. I only want a line between the two waypoints underneath the crane. My first thought was the problem had to do with setCycle, but in both methods setCylce is false, so it’s something else. My car also starts at the last added point how can I change this?
Method for drawing the main path:
public void drive(AssetManager assetManager, Node rootNode, Node guiNode,FlyByCamera flyCam,final Camera cam){
pathagv = new MotionPath();
pathagv.addWayPoint(new Vector3f(560,7,-1500));
pathagv.addWayPoint(new Vector3f(560,7,-1560));
pathagv.addWayPoint(new Vector3f(-560,7,-1560));
pathagv.addWayPoint(new Vector3f(-560,7,1470));
pathagv.addWayPoint(new Vector3f(560,7,1470));
pathagv.addWayPoint(new Vector3f(560,7,-1500));
pathagv.enableDebugShape(assetManager, rootNode);
pathagv.setCurveTension(0f);
motionControl = new MotionEvent(agv,pathagv);
motionControl.setDirectionType(MotionEvent.Direction.PathAndRotation);
motionControl.setRotation(new Quaternion().fromAngleNormalAxis(-FastMath.HALF_PI, Vector3f.UNIT_Y));
motionControl.setInitialDuration(50f);
motionControl.setSpeed(1f);
guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
final BitmapText wayPointsText = new BitmapText(guiFont, false);
wayPointsText.setSize(guiFont.getCharSet().getRenderedSize());
guiNode.attachChild(wayPointsText);
pathagv.addListener(new MotionPathListener() {
public void onWayPointReach(MotionEvent control, int wayPointIndex) {
if (pathagv.getNbWayPoints() == wayPointIndex ) {
wayPointsText.setText(control.getSpatial().getName() + "Finished!!! ");
} else {
wayPointsText.setText(/*control.getSpatial().getName() +*/ " Reached way point " + wayPointIndex);
}
wayPointsText.setLocalTranslation((cam.getWidth() - wayPointsText.getLineWidth()) / 2, cam.getHeight(), 0);
}
});
flyCam.setEnabled(true);
// chaser = new ChaseCamera(cam,agv);
motionControl.setSpeed(-3f);
motionControl.setLoopMode(LoopMode.Loop);
pathagv.setCycle(false);
// chaser.setEnabled(false);
// chaser.registerWithInput(inputManager);
// initInputs(inputManager);
}
Method to add two new points
[code]
public void addAgvParkings(){
parking1 = new Vector3f (535,7,1465);
parking2 = new Vector3f (535,7,1475);
pathagv.addWayPoint(parking1);
pathagv.addWayPoint(parking2);
pathagv.setCycle(false);
}