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
This commit is contained in:
parent
191bd21b40
commit
8eae2cfd8a
@ -317,6 +317,20 @@ public final class AnimChannel {
|
|||||||
return affectedBones;
|
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) {
|
void update(float tpf, TempVars vars) {
|
||||||
if (animation == null)
|
if (animation == null)
|
||||||
return;
|
return;
|
||||||
|
@ -218,24 +218,28 @@ public class Cinematic extends AbstractCinematicEvent implements AppState {
|
|||||||
@Override
|
@Override
|
||||||
public void setTime(float time) {
|
public void setTime(float time) {
|
||||||
super.setTime(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"
|
//triggering all the event from start to "time"
|
||||||
//then computing timeOffset for each event
|
//then computing timeOffset for each event
|
||||||
for (int i = 0; i <= keyFrameIndex; i++) {
|
for (KeyFrame keyFrame : timeLine.values()) {
|
||||||
KeyFrame keyFrame = timeLine.get(i);
|
//KeyFrame keyFrame = timeLine.get(timeLine.keySet());
|
||||||
if (keyFrame != null) {
|
if (keyFrame != null) {
|
||||||
for (CinematicEvent ce : keyFrame.getCinematicEvents()) {
|
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.play();
|
||||||
ce.setTime(time - timeLine.getKeyFrameTime(keyFrame));
|
ce.setTime(t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (playState != PlayState.Playing) {
|
if (playState != PlayState.Playing) {
|
||||||
pause();
|
pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
// step();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyFrame addCinematicEvent(float timeStamp, CinematicEvent cinematicEvent) {
|
public KeyFrame addCinematicEvent(float timeStamp, CinematicEvent cinematicEvent) {
|
||||||
|
@ -122,8 +122,6 @@ public abstract class AbstractCinematicEvent implements CinematicEvent {
|
|||||||
public void internalUpdate(float tpf) {
|
public void internalUpdate(float tpf) {
|
||||||
if (playState == PlayState.Playing) {
|
if (playState == PlayState.Playing) {
|
||||||
time = time + (tpf * speed);
|
time = time + (tpf * speed);
|
||||||
//time = elapsedTimePause + (timer.getTimeInSeconds() - start) * speed;
|
|
||||||
|
|
||||||
onUpdate(tpf);
|
onUpdate(tpf);
|
||||||
if (time >= initialDuration && loopMode == loopMode.DontLoop) {
|
if (time >= initialDuration && loopMode == loopMode.DontLoop) {
|
||||||
stop();
|
stop();
|
||||||
@ -311,7 +309,7 @@ public abstract class AbstractCinematicEvent implements CinematicEvent {
|
|||||||
* @param time the time to fast forward to
|
* @param time the time to fast forward to
|
||||||
*/
|
*/
|
||||||
public void setTime(float time) {
|
public void setTime(float time) {
|
||||||
this.time = time / speed;
|
this.time = time ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getTime() {
|
public float getTime() {
|
||||||
|
@ -109,14 +109,14 @@ public class AnimationTrack extends AbstractCinematicEvent {
|
|||||||
public void setTime(float time) {
|
public void setTime(float time) {
|
||||||
super.setTime(time);
|
super.setTime(time);
|
||||||
float t = time;
|
float t = time;
|
||||||
if(loopMode == loopMode.Loop){
|
if (loopMode == loopMode.Loop) {
|
||||||
t = t % channel.getAnimMaxTime();
|
t = t % channel.getAnimMaxTime();
|
||||||
}
|
}
|
||||||
if(loopMode == loopMode.Cycle){
|
if (loopMode == loopMode.Cycle) {
|
||||||
float parity = (float)Math.ceil(time / channel.getAnimMaxTime());
|
float parity = (float) Math.ceil(time / channel.getAnimMaxTime());
|
||||||
if(parity >0 && parity%2 ==0){
|
if (parity > 0 && parity % 2 == 0) {
|
||||||
t = channel.getAnimMaxTime() - t % channel.getAnimMaxTime();
|
t = channel.getAnimMaxTime() - t % channel.getAnimMaxTime();
|
||||||
}else{
|
} else {
|
||||||
t = t % channel.getAnimMaxTime();
|
t = t % channel.getAnimMaxTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,8 +142,8 @@ public class AnimationTrack extends AbstractCinematicEvent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
channel.getControl().setEnabled(false);
|
|
||||||
channel.setTime(0);
|
channel.setTime(0);
|
||||||
|
channel.reset(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -116,11 +116,12 @@ public class SoundTrack extends AbstractCinematicEvent {
|
|||||||
public void setTime(float time) {
|
public void setTime(float time) {
|
||||||
super.setTime(time);
|
super.setTime(time);
|
||||||
//can occur on rewind
|
//can occur on rewind
|
||||||
if (time < 0) {
|
if (time < 0f) {
|
||||||
stop();
|
stop();
|
||||||
}
|
}else{
|
||||||
audioNode.setTimeOffset(time);
|
audioNode.setTimeOffset(time);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlay() {
|
public void onPlay() {
|
||||||
|
@ -32,13 +32,13 @@
|
|||||||
package com.jme3.cinematic.events;
|
package com.jme3.cinematic.events;
|
||||||
|
|
||||||
import com.jme3.animation.LoopMode;
|
import com.jme3.animation.LoopMode;
|
||||||
import com.jme3.app.Application;
|
|
||||||
import com.jme3.cinematic.Cinematic;
|
|
||||||
import com.jme3.export.InputCapsule;
|
import com.jme3.export.InputCapsule;
|
||||||
import com.jme3.export.JmeExporter;
|
import com.jme3.export.JmeExporter;
|
||||||
import com.jme3.export.JmeImporter;
|
import com.jme3.export.JmeImporter;
|
||||||
import com.jme3.export.OutputCapsule;
|
import com.jme3.export.OutputCapsule;
|
||||||
import de.lessvoid.nifty.Nifty;
|
import de.lessvoid.nifty.Nifty;
|
||||||
|
import de.lessvoid.nifty.screen.NullScreen;
|
||||||
|
import de.lessvoid.nifty.screen.Screen;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,13 +78,14 @@ public class GuiTrack extends AbstractCinematicEvent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlay() {
|
public void onPlay() {
|
||||||
System.out.println("screen should be "+screen);
|
System.out.println("screen should be " + screen);
|
||||||
nifty.gotoScreen(screen);
|
nifty.gotoScreen(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() { if (!(nifty.getCurrentScreen() instanceof NullScreen)) {
|
||||||
nifty.gotoScreen("");
|
nifty.getCurrentScreen().endScreen(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<nifty>
|
<nifty>
|
||||||
<screen id="start" controller="jme3test.niftygui.TestNiftyGui">
|
<screen id="start" >
|
||||||
<layer id="layer" backgroundColor="#0000" childLayout="center">
|
<layer id="layer" backgroundColor="#0000" childLayout="center">
|
||||||
<panel id="panel" width="100%" height="100%" backgroundColor="#0000" childLayout="center" visibleToMouse="true" >
|
<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" />
|
<text id="text" font="aurulent-sans-16.fnt" color="#000f" text="" align="center" valign="bottom" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user