use of com.jme3.cinematic.events.AnimationEvent in project jmonkeyengine by jMonkeyEngine.
the class TestCinematic method simpleInitApp.
@Override
public void simpleInitApp() {
//just some text
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(getAssetManager(), getInputManager(), getAudioRenderer(), getGuiViewPort());
Nifty nifty;
nifty = niftyDisplay.getNifty();
nifty.fromXmlWithoutStartScreen("Interface/Nifty/CinematicTest.xml");
getGuiViewPort().addProcessor(niftyDisplay);
guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
final BitmapText text = new BitmapText(guiFont, false);
text.setSize(guiFont.getCharSet().getRenderedSize());
text.setText("Press enter to play/pause cinematic");
text.setLocalTranslation((cam.getWidth() - text.getLineWidth()) / 2, cam.getHeight(), 0);
guiNode.attachChild(text);
createScene();
cinematic = new Cinematic(rootNode, 20);
stateManager.attach(cinematic);
createCameraMotion();
//creating spatial animation for the teapot
AnimationFactory factory = new AnimationFactory(20, "teapotAnim");
factory.addTimeTranslation(0, new Vector3f(10, 0, 10));
factory.addTimeTranslation(20, new Vector3f(10, 0, -10));
factory.addTimeScale(10, new Vector3f(4, 4, 4));
factory.addTimeScale(20, new Vector3f(1, 1, 1));
factory.addTimeRotationAngles(20, 0, 4 * FastMath.TWO_PI, 0);
AnimControl control = new AnimControl();
control.addAnim(factory.buildAnimation());
teapot.addControl(control);
//fade in
cinematic.addCinematicEvent(0, new FadeEvent(true));
// cinematic.activateCamera(0, "aroundCam");
cinematic.addCinematicEvent(0, new AnimationEvent(teapot, "teapotAnim", LoopMode.DontLoop));
cinematic.addCinematicEvent(0, cameraMotionEvent);
cinematic.addCinematicEvent(0, new SoundEvent("Sound/Environment/Nature.ogg", LoopMode.Loop));
cinematic.addCinematicEvent(3f, new SoundEvent("Sound/Effects/kick.wav"));
cinematic.addCinematicEvent(3, new SubtitleTrack(nifty, "start", 3, "jMonkey engine really kicks A..."));
cinematic.addCinematicEvent(5.1f, new SoundEvent("Sound/Effects/Beep.ogg", 1));
cinematic.addCinematicEvent(2, new AnimationEvent(model, "Walk", LoopMode.Loop));
cinematic.activateCamera(0, "topView");
// cinematic.activateCamera(10, "aroundCam");
//fade out
cinematic.addCinematicEvent(19, new FadeEvent(false));
// cinematic.addCinematicEvent(19, new AbstractCinematicEvent() {
//
// @Override
// public void onPlay() {
// fade.setDuration(1f / cinematic.getSpeed());
// fade.fadeOut();
//
// }
//
// @Override
// public void onUpdate(float tpf) {
// }
//
// @Override
// public void onStop() {
// }
//
// @Override
// public void onPause() {
// }
// });
cinematic.addListener(new CinematicEventListener() {
public void onPlay(CinematicEvent cinematic) {
chaseCam.setEnabled(false);
System.out.println("play");
}
public void onPause(CinematicEvent cinematic) {
System.out.println("pause");
}
public void onStop(CinematicEvent cinematic) {
chaseCam.setEnabled(true);
fade.setValue(1);
System.out.println("stop");
}
});
//cinematic.setSpeed(2);
flyCam.setEnabled(false);
chaseCam = new ChaseCamera(cam, model, inputManager);
initInputs();
}
use of com.jme3.cinematic.events.AnimationEvent in project jmonkeyengine by jMonkeyEngine.
the class TestJaime method setupCinematic.
public void setupCinematic(final Node jaime) {
cinematic = new Cinematic(rootNode, 60);
stateManager.attach(cinematic);
jaime.move(0, 0, -3);
AnimationFactory af = new AnimationFactory(0.7f, "JumpForward");
af.addTimeTranslation(0, new Vector3f(0, 0, -3));
af.addTimeTranslation(0.35f, new Vector3f(0, 1, -1.5f));
af.addTimeTranslation(0.7f, new Vector3f(0, 0, 0));
jaime.getControl(AnimControl.class).addAnim(af.buildAnimation());
cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "Idle", 3, LoopMode.DontLoop));
float jumpStart = cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "JumpStart", LoopMode.DontLoop));
cinematic.addCinematicEvent(jumpStart + 0.2f, new AnimationEvent(jaime, "JumpForward", LoopMode.DontLoop, 1));
cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "JumpEnd", LoopMode.DontLoop));
cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "Punches", LoopMode.DontLoop));
cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "SideKick", LoopMode.DontLoop));
float camStart = cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "Taunt", LoopMode.DontLoop));
cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "Idle", 1, LoopMode.DontLoop));
cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "Wave", LoopMode.DontLoop));
cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "Idle", LoopMode.DontLoop));
CameraNode camNode = cinematic.bindCamera("cam", cam);
camNode.setLocalTranslation(new Vector3f(1.1f, 1.2f, 2.9f));
camNode.lookAt(new Vector3f(0, 0.5f, 0), Vector3f.UNIT_Y);
MotionPath path = new MotionPath();
path.addWayPoint(new Vector3f(1.1f, 1.2f, 2.9f));
path.addWayPoint(new Vector3f(0f, 1.2f, 3.0f));
path.addWayPoint(new Vector3f(-1.1f, 1.2f, 2.9f));
path.enableDebugShape(assetManager, rootNode);
path.setCurveTension(0.8f);
MotionEvent camMotion = new MotionEvent(camNode, path, 6);
camMotion.setDirectionType(MotionEvent.Direction.LookAt);
camMotion.setLookAt(new Vector3f(0, 0.5f, 0), Vector3f.UNIT_Y);
cinematic.addCinematicEvent(camStart, camMotion);
cinematic.activateCamera(0, "cam");
cinematic.fitDuration();
cinematic.setSpeed(1.2f);
cinematic.setLoopMode(LoopMode.Loop);
cinematic.play();
}
use of com.jme3.cinematic.events.AnimationEvent in project jmonkeyengine by jMonkeyEngine.
the class CinematicTest method clearAnimationEvent.
/**
* No ClassCastException when clear() a Cinematic with AnimationEvent
*/
@Test
public void clearAnimationEvent() {
Cinematic sut = new Cinematic();
Node model = new Node("model");
AnimControl ac = new AnimControl();
ac.addAnim(new Animation("animName", 1.0f));
model.addControl(ac);
sut.enqueueCinematicEvent(new AnimationEvent(model, "animName"));
sut.initialize(null, null);
sut.clear();
}
Aggregations