use of com.jme3.cinematic.Cinematic in project jmonkeyengine by jMonkeyEngine.
the class AnimationEvent method read.
@Override
public void read(JmeImporter im) throws IOException {
super.read(im);
InputCapsule ic = im.getCapsule(this);
if (im.getFormatVersion() == 0) {
modelName = ic.readString("modelName", "");
}
//FIXME always the same issue, because of the clonning of assets, this won't work
//we have to somehow store userdata in the spatial and then recurse the
//scene sub scenegraph to find the correct instance of the model
//This brings a reflaxion about the cinematic being an appstate,
//shouldn't it be a control over the scene
// this would allow to use the cloneForSpatial method and automatically
//rebind cloned references of original objects.
//for now as nobody probably ever saved a cinematic, this is not a critical issue
model = (Spatial) ic.readSavable("model", null);
animationName = ic.readString("animationName", "");
blendTime = ic.readFloat("blendTime", 0f);
channelIndex = ic.readInt("channelIndex", 0);
}
use of com.jme3.cinematic.Cinematic in project jmonkeyengine by jMonkeyEngine.
the class Cinematic method bindCamera.
/**
* Binds a camera to this cinematic, tagged by a unique name. This methods
* creates and returns a CameraNode for the cam and attach it to the scene.
* The control direction is set to SpatialToCamera. This camera Node can
* then be used in other events to handle the camera movements during the
* playback
*
* @param cameraName the unique tag the camera should have
* @param cam the scene camera.
* @return the created CameraNode.
*/
public CameraNode bindCamera(String cameraName, Camera cam) {
if (cameras.containsKey(cameraName)) {
throw new IllegalArgumentException("Camera " + cameraName + " is already binded to this cinematic");
}
CameraNode node = new CameraNode(cameraName, cam);
node.setControlDir(ControlDirection.SpatialToCamera);
node.getControl(CameraControl.class).setEnabled(false);
cameras.put(cameraName, node);
scene.attachChild(node);
return node;
}
use of com.jme3.cinematic.Cinematic in project jmonkeyengine by jMonkeyEngine.
the class Cinematic method setTime.
/**
* This is used internally but can be called to shuffle through the
* cinematic.
*
* @param time the time to shuffle to.
*/
@Override
public void setTime(float time) {
//stopping all events
onStop();
super.setTime(time);
int keyFrameIndex = timeLine.getKeyFrameIndexFromTime(time);
//then computing timeOffset for each event
for (int i = 0; i <= keyFrameIndex; i++) {
KeyFrame keyFrame = timeLine.get(i);
if (keyFrame != null) {
for (CinematicEvent ce : keyFrame.getCinematicEvents()) {
float t = this.time - timeLine.getKeyFrameTime(keyFrame);
if (t >= 0 && (t <= ce.getInitialDuration() || ce.getLoopMode() != LoopMode.DontLoop)) {
ce.play();
}
ce.setTime(t);
}
}
}
lastFetchedKeyFrame = keyFrameIndex;
if (playState != PlayState.Playing) {
pause();
}
}
use of com.jme3.cinematic.Cinematic in project jmonkeyengine by jMonkeyEngine.
the class Cinematic method fitDuration.
/**
* fits the duration of the cinematic to the duration of all its child
* cinematic events
*/
public void fitDuration() {
KeyFrame kf = timeLine.getKeyFrameAtIndex(timeLine.getLastKeyFrameIndex());
float d = 0;
for (int i = 0; i < kf.getCinematicEvents().size(); i++) {
CinematicEvent ce = kf.getCinematicEvents().get(i);
float dur = timeLine.getKeyFrameTime(kf) + ce.getDuration() * ce.getSpeed();
if (d < dur) {
d = dur;
}
}
initialDuration = d;
}
use of com.jme3.cinematic.Cinematic in project jmonkeyengine by jMonkeyEngine.
the class Cinematic method setSpeed.
/**
* sets the speed of the cinematic. Note that it will set the speed of all
* events in the cinematic. 1 is normal speed. use 0.5f to make the
* cinematic twice slower, use 2 to make it twice faster
*
* @param speed the speed
*/
@Override
public void setSpeed(float speed) {
super.setSpeed(speed);
for (int i = 0; i < cinematicEvents.size(); i++) {
CinematicEvent ce = cinematicEvents.get(i);
ce.setSpeed(speed);
}
}
Aggregations