A track and path camera to obeys key trigger

I´m trying to implement camera to focus on an object fixed at screen. I did it using Track Control and Path. So, I create a path, add viewpoints and use a track to follows the path.



The path built is a circle and it involves the fixed object, the track runs in a constant loop. However I don´t want to runs the track as constant loop I wonder to camera´s goes from a specific waypoint to another one. Controlling it from inputManager.



How to handle it even it uses track control play event?



Is this the best way? I mean use path and track to build a camera to surrounding an object?



Maybe path and track camera is only for animation!



Thanks in advance, any suggestion will be very welcome.



Sorry about my english! Hope be clear.

you can add a MotionPathListener to your path and the onWayPointReach(MotionTrack motionControl,int wayPointIndex); method will be triggered each time you reach a waypoint.

There you can call the method stop() of the motiontrack.

I did something alike, nehon, but the problem is to handle the director (right and left). I cannot flag this automatically, so If right side is trigger, I just invert the directon of waypoints remove all previous waypoint and add it again in an opposite direction.



I didn´t find any way to make it works.



I coded something like that:



[java] if (name.equals("cam_left")) {

//turn the waypoints to left side

stopMove();

path.clearWayPoints();

path.addWayPoint(new Vector3f(0 + pathLocation, 5, -8 + pathLocation));

path.addWayPoint(new Vector3f(-8 + pathLocation, 5, 0 + pathLocation));

path.addWayPoint(new Vector3f(0 + pathLocation, 5, 8 + pathLocation));

path.addWayPoint(new Vector3f(8 + pathLocation, 5, 0 + pathLocation));

playMove();

} else if (name.equals("cam_right")) {

//turn the waypoints to right side

stopMove();

path.clearWayPoints();

path.addWayPoint(new Vector3f(8 + pathLocation, 5, 0 + pathLocation));

path.addWayPoint(new Vector3f(0 + pathLocation, 5, 8 + pathLocation));

path.addWayPoint(new Vector3f(-8 + pathLocation, 5, 0 + pathLocation));

path.addWayPoint(new Vector3f(0 + pathLocation, 5, -8 + pathLocation));

playMove();

}[/java]



Thanks for the answer