Cinematic, fixed time seeking when having several SpatialAnimation with a speed > 1

fixed an issue in soundTrack crashing when time was < 0
properly implemented GuiTrack stop() method

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9239 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 13 years ago
parent 191bd21b40
commit 8eae2cfd8a
  1. 14
      engine/src/core/com/jme3/animation/AnimChannel.java
  2. 16
      engine/src/core/com/jme3/cinematic/Cinematic.java
  3. 4
      engine/src/core/com/jme3/cinematic/events/AbstractCinematicEvent.java
  4. 12
      engine/src/core/com/jme3/cinematic/events/AnimationTrack.java
  5. 5
      engine/src/core/com/jme3/cinematic/events/SoundTrack.java
  6. 11
      engine/src/niftygui/com/jme3/cinematic/events/GuiTrack.java
  7. 2
      engine/test-data/Interface/Nifty/CinematicTest.xml

@ -317,6 +317,20 @@ public final class AnimChannel {
return affectedBones;
}
public void reset(boolean rewind){
if(rewind){
setTime(0);
if(control.getSkeleton()!=null){
control.getSkeleton().resetAndUpdate();
}else{
TempVars vars = TempVars.get();
update(0, vars);
vars.release();
}
}
animation = null;
}
void update(float tpf, TempVars vars) {
if (animation == null)
return;

@ -218,24 +218,28 @@ public class Cinematic extends AbstractCinematicEvent implements AppState {
@Override
public void setTime(float time) {
super.setTime(time);
int keyFrameIndex = timeLine.getKeyFrameIndexFromTime(time);
//stopping all events
for (CinematicEvent ce : cinematicEvents) {
ce.stop();
}
//triggering all the event from start to "time"
//then computing timeOffset for each event
for (int i = 0; i <= keyFrameIndex; i++) {
KeyFrame keyFrame = timeLine.get(i);
for (KeyFrame keyFrame : timeLine.values()) {
//KeyFrame keyFrame = timeLine.get(timeLine.keySet());
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(time - timeLine.getKeyFrameTime(keyFrame));
ce.setTime(t);
}
}
}
}
if (playState != PlayState.Playing) {
pause();
}
// step();
}
public KeyFrame addCinematicEvent(float timeStamp, CinematicEvent cinematicEvent) {

@ -122,8 +122,6 @@ public abstract class AbstractCinematicEvent implements CinematicEvent {
public void internalUpdate(float tpf) {
if (playState == PlayState.Playing) {
time = time + (tpf * speed);
//time = elapsedTimePause + (timer.getTimeInSeconds() - start) * speed;
onUpdate(tpf);
if (time >= initialDuration && loopMode == loopMode.DontLoop) {
stop();
@ -311,7 +309,7 @@ public abstract class AbstractCinematicEvent implements CinematicEvent {
* @param time the time to fast forward to
*/
public void setTime(float time) {
this.time = time / speed;
this.time = time ;
}
public float getTime() {

@ -109,14 +109,14 @@ public class AnimationTrack extends AbstractCinematicEvent {
public void setTime(float time) {
super.setTime(time);
float t = time;
if(loopMode == loopMode.Loop){
if (loopMode == loopMode.Loop) {
t = t % channel.getAnimMaxTime();
}
if(loopMode == loopMode.Cycle){
float parity = (float)Math.ceil(time / channel.getAnimMaxTime());
if(parity >0 && parity%2 ==0){
if (loopMode == loopMode.Cycle) {
float parity = (float) Math.ceil(time / channel.getAnimMaxTime());
if (parity > 0 && parity % 2 == 0) {
t = channel.getAnimMaxTime() - t % channel.getAnimMaxTime();
}else{
} else {
t = t % channel.getAnimMaxTime();
}
@ -142,8 +142,8 @@ public class AnimationTrack extends AbstractCinematicEvent {
@Override
public void onStop() {
channel.getControl().setEnabled(false);
channel.setTime(0);
channel.reset(false);
}
@Override

@ -116,11 +116,12 @@ public class SoundTrack extends AbstractCinematicEvent {
public void setTime(float time) {
super.setTime(time);
//can occur on rewind
if (time < 0) {
if (time < 0f) {
stop();
}
}else{
audioNode.setTimeOffset(time);
}
}
@Override
public void onPlay() {

@ -32,13 +32,13 @@
package com.jme3.cinematic.events;
import com.jme3.animation.LoopMode;
import com.jme3.app.Application;
import com.jme3.cinematic.Cinematic;
import com.jme3.export.InputCapsule;
import com.jme3.export.JmeExporter;
import com.jme3.export.JmeImporter;
import com.jme3.export.OutputCapsule;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.screen.NullScreen;
import de.lessvoid.nifty.screen.Screen;
import java.io.IOException;
/**
@ -78,13 +78,14 @@ public class GuiTrack extends AbstractCinematicEvent {
@Override
public void onPlay() {
System.out.println("screen should be "+screen);
System.out.println("screen should be " + screen);
nifty.gotoScreen(screen);
}
@Override
public void onStop() {
nifty.gotoScreen("");
public void onStop() { if (!(nifty.getCurrentScreen() instanceof NullScreen)) {
nifty.getCurrentScreen().endScreen(null);
}
}
@Override

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<nifty>
<screen id="start" controller="jme3test.niftygui.TestNiftyGui">
<screen id="start" >
<layer id="layer" backgroundColor="#0000" childLayout="center">
<panel id="panel" width="100%" height="100%" backgroundColor="#0000" childLayout="center" visibleToMouse="true" >
<text id="text" font="aurulent-sans-16.fnt" color="#000f" text="" align="center" valign="bottom" />

Loading…
Cancel
Save