Hello, I would use to move my cinematic camera! But the problem is with the CamNode I can not well centered while moving my camera!
[java]cinematic = new Cinematic(rootNode, 5);
camNode2 = cinematic.bindCamera("topView", cam);
camNode2.setLocalTranslation(cam.getLocation());
camNode2.lookAt( Vector3f.UNIT_X,new Vector3f(1f, 1f, 1f));
cameraMotionTrack = new PositionTrack(camNode2,object.getLocalTranslation.add(0,100,100),5,LoopMode.Loop);
cinematic.addCinematicEvent(0, cameraMotionTrack);
stateManager.attach(cinematic);
cinematic.play();
cinematic.activateCamera(0, "topView");
cinematic.addListener(new CinematicEventListener(){
public void onPlay(CinematicEvent cinematic) {
}
public void onPause(CinematicEvent cinematic) {
}
public void onStop(CinematicEvent cinematic) {
camNode2.setEnabled(false);
}
}); [/java]
I do not want my camera running. I just want it moves from one point to another!
Thank you for your help in advance
camNode2.lookAt( Vector3f.UNIT_X,new Vector3f(1f, 1f, 1f));
^-- whats this supposed to do? Its wrong, I think you mix up the up-vector and the lookAt position. Even then I doubt your you want your up vector to point in the x direction.
I want my camera moves but keeping the direction
dretz said:
I want my camera moves but keeping the direction
es but what Normen is saying is that this
camNode2.lookAt( Vector3f.UNIT_X,new Vector3f(1f, 1f, 1f));
will yield unexpected results
try this
camNode2.lookAt(new Vector3f(1f, 1f, 1f), Vector3f.UNIT_Y);
Also for this consider using a MotionTrack instead of a PositionTrack. (see TestCameraMotionTrack)
yes but MotionTrack uses camNode also so we have camNode2.lookAt also
dretz said:
yes but MotionTrack uses camNode also :/ so we have camNode2.lookAt also
Yeah sorry I might have been misleading you, the MotionTrack part is not really related to your issue. I was saying that because PositionTrack is deprecated and might be removed later.
So, if i understand correctly your issue, you want to make some camera traveling with the camera always looking at the same target during it's movement.
What you need to do first is to create a MotionPath
MotionPath path = new MotionPath();
path.setPathSplineType(SplineType.Linear);
path.addWayPoint(new Vector3f(...your camera start position here ....));
path.addWayPoint(new Vector3f(...your camera end position here ....));
then create a motion track and set up the lookAt
cameraMotionTrack = new MotionTrack(camNode2, path);
cameraMotionTrack.setLookAt(yourTraget.getWorldTranslation(), Vector3f.UNIT_Y);
cameraMotionTrack.setDirectionType(MotionTrack.Direction.LookAt);
then set that up in the cinematic like you did
cinematic.addCinematicEvent(0, cameraMotionTrack);
cinematic.activateCamera(0, "topView");
stateManager.attach(cinematic);
...
cinematic.play();
After many tries and changes I finally found what I wanted! I do not know if I’m good enough to express
I post my code never know it but thank you for your help!
[java] cinematic = new Cinematic(rootNode, 5);
camNode2 = cinematic.bindCamera(“topView”, cam);
camNode2.setLocalTranslation(cam.getLocation());
camNode2.setLocalRotation(cam.getRotation());
cameraMotionTrack = new PositionTrack(camNode2, object.getLocalTranslation().add(50,55,105),5,LoopMode.DontLoop);
cinematic.addCinematicEvent(0, cameraMotionTrack);
stateManager.attach(cinematic);
cinematic.activateCamera(0, “topView”);
cinematic.addListener(new CinematicEventListener(){
public void onPlay(CinematicEvent cinematic) {
}
public void onPause(CinematicEvent cinematic) {
}
public void onStop(CinematicEvent cinematic) {
camNode2.setEnabled(false);
cinematic = null;
}
});
cinematic.play();[/java]
it remains for me to go on a MotionTrack (not too difficult)
As you can see I’ve completely stopped with the LookAt ^ ^
Thank you again!
well as long as it works and it’s doing what you want, it’s fine
sorry but I still have a problem! I just downloaded the new version of my cinematic Jme but does not work anymore … when I click either my objects move by teleporting or it does not move …
[java]for(int i = 0; i < objectSelect.size(); i++) // Bouge vaisseaux dans l’array Object
{
distance = (float) Math.sqrt((xDestination - objectSelect.get(i).getLocalTranslation().x)(xDestination-objectSelect.get(i).getLocalTranslation().x) + (zDestination - objectSelect.get(i).getLocalTranslation().z)(zDestination - objectSelect.get(i).getLocalTranslation().z));
objectSelect.get(i).lookAt(new Vector3f(xDestination,0,zDestination),new Vector3f(Vector3f.ZERO));
cinematic = new Cinematic(objectSelect.get(i), distance/10);
MotionPath path = new MotionPath();
path.setPathSplineType(SplineType.Linear);
path.addWayPoint(objectSelect.get(i).getLocalTranslation());
path.addWayPoint(new Vector3f(xDestination,0,zDestination + (i2)));
cameraMotionTrack = new MotionTrack(objectSelect.get(i), path);
cameraMotionTrack.setDirection(cam.getDirection());
cameraMotionTrack.setDirectionType(MotionTrack.Direction.LookAt);
cameraMotionTrack.setSpeed(30);
//cinematic.addCinematicEvent(0, new PositionTrack(objectSelect.get(i), new Vector3f(xDestination,0,zDestination + (i2)), distance/10, LoopMode.Loop));
cinematic.addCinematicEvent(0, cameraMotionTrack);
stateManager.attach(cinematic);
System.out.println(“aaa”);
cinematic.play();
}[/java]