I thought you could meet the problem is to know roughly where it can come.
the code is a bit long which is why I have not posted, but here
:
here the objects : http://demo.ovh.eu/fr/58281026a2cf4b999fea64133414b6a5/
[java]
package animation;
import com.jme3.app.SimpleApplication;
import com.jme3.asset.plugins.FileLocator;
import com.jme3.cinematic.MotionPath;
import com.jme3.cinematic.events.MotionEvent;
import com.jme3.input.ChaseCamera;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.AnalogListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.light.AmbientLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.scene.CameraNode;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.CameraControl.ControlDirection;
import com.jme3.scene.shape.Quad;
import com.jme3.system.AppSettings;
import com.jme3.system.JmeCanvasContext;
import com.jme3.util.BufferUtils;
public class Scene extends SimpleApplication {
private AppSettings LiveviewSettings;
private Node metroNode;
private CameraNode camNode ;
boolean playing = false;
private MotionPath path;
private Spatial metro;
private MotionEvent motionControlcam;
private MotionEvent motionControl ;
static JmeCanvasContext ctx;
private Spatial tunnel;
private Node tunnelNode;
private ChaseCamera chaser;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////// Accesseur mutateur
public JmeCanvasContext getCtx() {
return ctx;
}
public void setCtx(JmeCanvasContext ctx) {
Scene.ctx = ctx;
}
public Spatial getMetro() {
return metro;
}
public void setMetro(Spatial metro) {
this.metro = metro;
}
public AppSettings getLiveviewSettings() {
return LiveviewSettings;
}
public void setLiveviewSettings(AppSettings liveviewSettings) {
LiveviewSettings = liveviewSettings;
}
////////////////////////////////////////////////////////////////////////////////////////////
public void animetro(Boolean value){
System.out.println(“mvt”);
if (value == true){
motionControl.play();
/* while ( metroNode.getWorldTranslation().toString().equals("(30.0, 0.0, -35.0)") )
{
try {
motionControl.wait(2000);
} catch (InterruptedException ex) {
Logger.getLogger(SceneMetro.class.getName()).log(Level.SEVERE, null, ex);
}
} */
}
if (value == false){
motionControl.stop();
}
}
@Override
public void simpleInitApp() {
//BufferUtils.setTrackDirectMemoryEnabled(true);
// Definition du Path Asset : le repertoire ou se trouvent les resources 3D
String assetPath = “D:\Users\h\workspace\Import3D\assets”;
this.assetManager.registerLocator(assetPath, FileLocator.class);
// load metro
metro = assetManager.loadModel("Models\\cube\\test4.j3o");
metro.scale(1f, 1f, 1f);
metro.rotate(0.0f, 0.0f, 0.0f);
metro.setLocalTranslation(0.0f, 0.0f, 0.0f);
// load tunnel
/*
tunnel = assetManager.loadModel(“Models\metro\metro scene test.j3o”);
tunnel.scale(20f, 20f, 20f);
tunnel.rotate(0.0f, 0.0f, 0.0f);
tunnel.setLocalTranslation(0.0f, -2f, 0.0f);
// creation de node to attach the carremobile and the camera node
tunnelNode = new Node(“tunnelNode”);
tunnelNode.attachChild(tunnel);
rootNode.attachChild(tunnelNode);
/
metroNode = new Node(“metronode”);
metroNode.attachChild(metro);
rootNode.attachChild(metroNode);
/
// load carrefixe
Spatial carrefixe = assetManager.loadModel(“Models\cube\test4.j3o”);
carrefixe.scale(1f, 1f, 1f);
carrefixe.rotate(0.0f, 0.0f, 0.0f);
carrefixe.setLocalTranslation(0.0f, 0.0f, 5.0f);
// creation de node to attach the carrefixe
rootNode.attachChild(carrefixe);*/
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
Geometry ground = new Geometry("ground", new Quad(150, 150));
ground.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
ground.setLocalTranslation(-50, 0, 50);
ground.setMaterial(mat);
rootNode.attachChild(ground);
// Light
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White.mult(1f));
rootNode.addLight(al);
/*
DirectionalLight sun = new DirectionalLight();
sun.setDirection(new Vector3f(-1f, -1f, -1.0f));
rootNode.addLight(sun);
*/
// flyCam.setDragToRotate(true);
//disable the default 1st-person flyCam
flyCam.setEnabled(false);
path = new MotionPath();
path.addWayPoint(new Vector3f(-50, 0, 0));
path.addWayPoint(new Vector3f(-35, 0, 0));
path.addWayPoint(new Vector3f(0, 0, 10));
path.addWayPoint(new Vector3f(20, 0, -20));
path.addWayPoint(new Vector3f(30, 0, -35));
//path.addListener(listenerPoint);
path.addWayPoint(new Vector3f(50, 0, -40));
path.addWayPoint(new Vector3f(80, 0, -40));
path.addWayPoint(new Vector3f(20, 0, -80));
path.setCycle(true);
path.enableDebugShape(assetManager, rootNode);
path.setCurveTension(0.5f);
// camera chase
// cam.setLocation(new Vector3f(8.4399185f, 11.189463f, 14.267577f));
chaser = new ChaseCamera(cam, metro);
chaser.setUpVector(new Vector3f(0f, 1f, 0f));
chaser.setMaxDistance(100);
chaser.setEnabled(true);
chaser.registerWithInput(inputManager);
/*
//creating the camera Node
camNode = new CameraNode(“CamNode”, cam);
//Setting the direction to Spatial to camera, this means the camera will copy the movements of the Node
camNode.setControlDir(ControlDirection.SpatialToCamera);
//attaching the camNode
metroNode.attachChild(camNode);
//setting the local translation of the cam node to move it away from the teanNode a bit
camNode.setLocalTranslation(new Vector3f(-10, 5, 0));
//setting the camNode to look at the carreNode
//camNode.lookAt(metroNode.getLocalTranslation(), new Vector3f(0, 1, 0));
camNode.lookAt(metroNode.getWorldTranslation(), new Vector3f(0, 1, 0));
*/
motionControl = new MotionEvent(metroNode,path);
motionControl.setDirectionType(MotionEvent.Direction.PathAndRotation);
motionControl.setRotation(new Quaternion().fromAngleNormalAxis(-FastMath.HALF_PI, Vector3f.UNIT_Y));
motionControl.setInitialDuration(10f);
motionControl.setSpeed(1f);
/* motionControlcam = new MotionEvent(camNode,path);
motionControlcam.setDirectionType(MotionEvent.Direction.PathAndRotation);
// motionControlcam.setRotation(new Quaternion().fromAngleNormalAxis(-FastMath.HALF_PI, Vector3f.UNIT_Y));
motionControlcam.setInitialDuration(10f);
motionControlcam.setSpeed(2f);*/
/*
flyCam.setEnabled(false);
ChaseCamera chaser = new ChaseCamera(cam, teapot);
// motionControl.setSpeed(-3f);
// motionControl.setLoopMode(LoopMode.Loop);
// path.setCycle(true);
// chaser.setEnabled(false);
chaser.registerWithInput(inputManager);
*/
System.out.println(“Vertices cube” + metro.getTriangleCount());
System.out.println("Vertices cubeNode " + metroNode.getVertexCount());
System.out.println(“Vertices plan” + ground.getVertexCount());
// System.out.println(“Vertices plan” + groundNode.getVertexCount());
// System.out.println("Vertices tunnel " + tunnel.getVertexCount());
// System.out.println("Vertices tunnelNode " + tunnelNode.getVertexCount());
System.out.println("Vertices rootNode " + rootNode.getVertexCount());
System.out.println("triangles rootNode " + rootNode.getTriangleCount());
setupKeys();
}
private void setupKeys() {
inputManager.addMapping("Lefts", new KeyTrigger(KeyInput.KEY_LEFT));
inputManager.addMapping("Rights", new KeyTrigger(KeyInput.KEY_RIGHT));
inputManager.addMapping("Ups", new KeyTrigger(KeyInput.KEY_UP));
inputManager.addMapping("Downs", new KeyTrigger(KeyInput.KEY_DOWN));
inputManager.addMapping("Camera", new KeyTrigger(KeyInput.KEY_C));
inputManager.addMapping("play_stop", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addMapping("question", new KeyTrigger(KeyInput.KEY_Q));
inputManager.addMapping("delete", new KeyTrigger(KeyInput.KEY_M));
inputManager.addListener(actionListener, new String[]{"play_stop", "delete"});
inputManager.addListener(analogListener, new String[]{"Ups","Rights","Lefts","Downs","question"});
}
private ActionListener actionListener = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("play_stop") && keyPressed) {
if (playing) {
playing = false;
animetro( false);
} else {
playing = true;
animetro( true);
}
}
if (name.equals("delete") && keyPressed) {
/* getMonliveview().destroy();
getMonliveview().stop();*/
}
}
};
private AnalogListener analogListener = new AnalogListener() {
public void onAnalog(String name, float value, float tpf) {
if (name.equals("Ups")) {
metroNode.move(-0.05f, 0f, 0f);
}
if (name.equals("Downs")) {
metroNode.move(0.05f, 0f, 0f);
}
if (name.equals("Rights")) {
// metroNode.move(0f, 0f, -0.05f);
metroNode.rotate(0, 0.01f, 0);
}
if (name.equals("Lefts")) {
//metroNode.move(0f, 0f, 0.05f);
metroNode.rotate(0, -0.01f, 0);
}
if (name.equals("question")) {
System.out.println("reperetranslation"+""+metroNode.getWorldTranslation().toString());
System.out.println(MotionEvent.Direction.PathAndRotation);
}
}
};
}
[/java]
[java]
import java.awt.Dimension;
import com.jme3.system.AppSettings;
import com.jme3.system.JmeCanvasContext;
public class GameCanvas {
private Scene myScene;
private AppSettings sceneSettings;
private Dimension dim;
public GameCanvas () {
this.myScene = new Scene();
this.sceneSettings=(new AppSettings(false));
this.sceneSettings.setResolution(600, 300);
this.sceneSettings.setFullscreen(false);
this.sceneSettings.setVSync(false);
this.sceneSettings.setTitle("Liveview");
this.sceneSettings.setUseInput(true);
this.sceneSettings.setFrameRate(0);
this.sceneSettings.setSamples(0);
this.sceneSettings.setRenderer("LWJGL-OpenGL2");
this.sceneSettings.setAudioRenderer(null);
this.myScene.setSettings(this.sceneSettings);
this.myScene.setDisplayFps(true);
this.myScene.setDisplayStatView(true);
this.myScene.setShowSettings(false);
this.myScene.createCanvas();
this.myScene.setCtx((JmeCanvasContext) this.myScene.getContext());
this.myScene.getCtx().setSystemListener(this.myScene);
this.dim = new Dimension(800, 400);
this.myScene.getCtx().getCanvas().setPreferredSize(dim);
this.myScene.startCanvas();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////// Accesseur mutateur
public Scene getScene() {
return myScene;
}
public void setScene(Scene Scene) {
this.myScene = Scene;
}
public AppSettings getSceneSettings() {
return sceneSettings;
}
public void setSceneSettings(AppSettings mySceneSettings) {
this.sceneSettings = mySceneSettings;
}
public Dimension getDim() {
return dim;
}
public void setDim(Dimension myDim ) {
this.dim = myDim;
}
////////////////////////////////////////////////////////////////////////////////////////////
}
[/java]
[java]
package animation;
import animation.*;
import java.awt.FlowLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
public class Software {
public JDialog dialog;
String name;
int x,y;
private static GameCanvas anim;
private JTabbedPane tbpSessions;
private JPanel panel1;
private JPanel panel2;
private JPanel panel3;
public JDialog getDialog() {
return dialog;
}
public void setDialog(JDialog dialog) {
this.dialog = dialog;
}
public JPanel getPanel() {
return panel1;
}
public void setPanel(JPanel panel) {
this.panel1 = panel;
}
Software (String name, int x, int y ){
this.name=name;
this.x=x;
this.y=y;
dialog= new JDialog();
dialog.setTitle(name);
dialog.setSize(x, y);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
panel2 = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 5));
panel3 = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 5));
panel1 = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 5));
// panel.add(new JButton("Some Swing Component"));
dialog.setLocationRelativeTo(null);
// dialog.add(panel);
dialog.setVisible(true);
tbpSessions = new JTabbedPane();
tbpSessions.addTab("tab1", panel1);
tbpSessions.addTab("tab2", panel2);
tbpSessions.addTab("tab3", panel3);
dialog.add(tbpSessions);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
anim.getScene().destroy();
anim.getScene().stop();
}
});
}
public static void main(String[] args) throws InterruptedException {
anim = new GameCanvas();
Software test = new Software("d1" ,1000,700);
test.panel1.add(anim.getScene().getCtx().getCanvas());
}
}
[/java]