/** * schedule an event that will activate the camera at the given time * * @param timeStamp the time to activate the cam * @param cameraName the camera name (as registered in * Cinematic#bindCamera()) */ public void activateCamera(final float timeStamp, final String cameraName) { addCinematicEvent(timeStamp, new CameraEvent(this, cameraName)); }
public void onAction(String name, boolean keyPressed, float tpf) { if (name.equals("togglePause") && keyPressed) { if (cinematic.getPlayState() == PlayState.Playing) { cinematic.pause(); time = cinematic.getTime(); } else { cinematic.play(); } } if (cinematic.getPlayState() != PlayState.Playing) { if (name.equals("navFwd") && keyPressed) { time += 0.25; FastMath.clamp(time, 0, cinematic.getInitialDuration()); cinematic.setTime(time); } if (name.equals("navBack") && keyPressed) { time -= 0.25; FastMath.clamp(time, 0, cinematic.getInitialDuration()); cinematic.setTime(time); } } } };
public void onAction(String name, boolean isPressed, float tpf) { if(name.equals("start") && isPressed){ if(cinematic.getPlayState() != PlayState.Playing){ cinematic.play(); }else{ cinematic.pause(); } } } }, "start");
@Override public void dispose() { super.dispose(); if (cinematic != null) { Object o = cinematic.getEventData(MODEL_CHANNELS, model); if (o != null) { Collection<AnimChannel> values = ((HashMap<Integer, AnimChannel>) o).values(); while (values.remove(channel)); if (values.isEmpty()) { cinematic.removeEventData(MODEL_CHANNELS, model); } } cinematic = null; channel = null; } } }
public void setupCinematic(final Node jaime) { cinematic = new Cinematic(rootNode, 60); stateManager.attach(cinematic); 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); 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();
this.cinematic = cinematic; if (channel == null) { Object s = cinematic.getEventData(MODEL_CHANNELS, model); if (s == null) { s = new HashMap<Integer, AnimChannel>(); ((HashMap<Integer, AnimChannel>)s).put(i, model.getControl(AnimControl.class).getChannel(i)); cinematic.putEventData(MODEL_CHANNELS, model, s); model = cinematic.getScene().getChild(modelName); if(cinematic.getScene() != null){ Spatial sceneModel = cinematic.getScene().getChild(model.getName()); if(sceneModel != null){ Node parent = sceneModel.getParent(); parent.attachChild(sceneModel); } else { cinematic.getScene().attachChild(model);
/** * 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(); } }
cinematic = new Cinematic(rootNode, 20); stateManager.attach(cinematic); cinematic.addCinematicEvent(0, new FadeEvent(true)); 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.addCinematicEvent(19, new FadeEvent(false)); cinematic.addListener(new CinematicEventListener() {
/** * passing true has the same effect as play() you should use play(), * pause(), stop() to handle the cinematic playing state. * * @param enabled true or false */ public void setEnabled(boolean enabled) { if (enabled) { play(); } }
/** * clear the cinematic of its events. */ public void clear() { dispose(); cinematicEvents.clear(); timeLine.clear(); if (eventsData != null) { eventsData.clear(); } }
/** * used internally put an eventdata in the cinematic * * @param type the type of data * @param key the key * @param object the data */ public void putEventData(String type, Object key, Object object) { Map<String, Map<Object, Object>> data = getEventsData(); Map<Object, Object> row = data.get(type); if (row == null) { row = new HashMap<Object, Object>(); } row.put(key, object); data.put(type, row); }
/** * used internally * * @param stateManager the state manager * @param app the application */ public void initialize(AppStateManager stateManager, Application app) { initEvent(app, this); for (CinematicEvent cinematicEvent : cinematicEvents) { cinematicEvent.initEvent(app, this); } if(!cameras.isEmpty()){ for(CameraNode n : cameras.values()){ n.setCamera(app.getCamera()); } } initialized = true; }
this.cinematic = cinematic; if (channel == null) { Object s = cinematic.getEventData(MODEL_CHANNELS, model); if (s == null) { s = new HashMap<Integer, AnimChannel>(); ((HashMap<Integer, AnimChannel>)s).put(i, model.getControl(AnimControl.class).getChannel(i)); cinematic.putEventData(MODEL_CHANNELS, model, s); model = cinematic.getScene().getChild(modelName); if(cinematic.getScene() != null){ Spatial sceneModel = cinematic.getScene().getChild(model.getName()); if(sceneModel != null){ Node parent = sceneModel.getParent(); parent.attachChild(sceneModel); } else { cinematic.getScene().attachChild(model);
@Override public void dispose() { super.dispose(); if (cinematic != null) { Object o = cinematic.getEventData(MODEL_CHANNELS, model); if (o != null) { Collection<AnimChannel> values = ((HashMap<Integer, AnimChannel>) o).values(); while (values.remove(channel)); if (values.isEmpty()) { cinematic.removeEventData(MODEL_CHANNELS, model); } } cinematic = null; channel = null; } } }
/** * passing true has the same effect as play() you should use play(), * pause(), stop() to handle the cinematic playing state. * * @param enabled true or false */ public void setEnabled(boolean enabled) { if (enabled) { play(); } }
/** * clear the cinematic of its events. */ public void clear() { dispose(); cinematicEvents.clear(); timeLine.clear(); if (eventsData != null) { eventsData.clear(); } }
/** * used internally put an eventdata in the cinematic * * @param type the type of data * @param key the key * @param object the data */ public void putEventData(String type, Object key, Object object) { Map<String, Map<Object, Object>> data = getEventsData(); Map<Object, Object> row = data.get(type); if (row == null) { row = new HashMap<Object, Object>(); } row.put(key, object); data.put(type, row); }