- used back system timer for cinematics, whatever it is :D
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8453 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
d1a515f878
commit
e9556fad0a
@ -40,6 +40,7 @@ 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 com.jme3.system.NanoTimer;
|
import com.jme3.system.NanoTimer;
|
||||||
|
import com.jme3.system.Timer;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -58,8 +59,8 @@ public abstract class AbstractCinematicEvent implements CinematicEvent {
|
|||||||
protected float initialDuration = 10;
|
protected float initialDuration = 10;
|
||||||
protected LoopMode loopMode = LoopMode.DontLoop;
|
protected LoopMode loopMode = LoopMode.DontLoop;
|
||||||
protected float time = 0;
|
protected float time = 0;
|
||||||
//nano timer for precisely computing the elapsed time
|
protected Timer timer;
|
||||||
protected NanoTimer timer;
|
protected float start = 0;
|
||||||
/**
|
/**
|
||||||
* the last time the event was paused
|
* the last time the event was paused
|
||||||
*/
|
*/
|
||||||
@ -108,9 +109,11 @@ public abstract class AbstractCinematicEvent implements CinematicEvent {
|
|||||||
onPlay();
|
onPlay();
|
||||||
playState = PlayState.Playing;
|
playState = PlayState.Playing;
|
||||||
if (timer == null) {
|
if (timer == null) {
|
||||||
|
//only when used as a control
|
||||||
timer = new NanoTimer();
|
timer = new NanoTimer();
|
||||||
}
|
}
|
||||||
timer.reset();
|
start = timer.getTimeInSeconds();
|
||||||
|
//timer.reset();
|
||||||
if (listeners != null) {
|
if (listeners != null) {
|
||||||
for (int i = 0; i < listeners.size(); i++) {
|
for (int i = 0; i < listeners.size(); i++) {
|
||||||
CinematicEventListener cel = listeners.get(i);
|
CinematicEventListener cel = listeners.get(i);
|
||||||
@ -130,7 +133,7 @@ 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 = (elapsedTimePause + timer.getTimeInSeconds()) * speed;
|
time = (elapsedTimePause + timer.getTimeInSeconds() - start) * speed;
|
||||||
|
|
||||||
onUpdate(tpf);
|
onUpdate(tpf);
|
||||||
if (time >= initialDuration && loopMode == loopMode.DontLoop) {
|
if (time >= initialDuration && loopMode == loopMode.DontLoop) {
|
||||||
@ -287,7 +290,8 @@ public abstract class AbstractCinematicEvent implements CinematicEvent {
|
|||||||
* @param cinematic
|
* @param cinematic
|
||||||
*/
|
*/
|
||||||
public void initEvent(Application app, Cinematic cinematic) {
|
public void initEvent(Application app, Cinematic cinematic) {
|
||||||
timer = new NanoTimer();
|
timer = app.getContext().getTimer();
|
||||||
|
//timer = new NanoTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +46,6 @@ import com.jme3.renderer.RenderManager;
|
|||||||
import com.jme3.renderer.ViewPort;
|
import com.jme3.renderer.ViewPort;
|
||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
import com.jme3.scene.control.Control;
|
import com.jme3.scene.control.Control;
|
||||||
import com.jme3.system.NanoTimer;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -175,7 +174,7 @@ public class MotionTrack extends AbstractCinematicEvent implements Control {
|
|||||||
public void initEvent(Application app, Cinematic cinematic) {
|
public void initEvent(Application app, Cinematic cinematic) {
|
||||||
super.initEvent(app, cinematic);
|
super.initEvent(app, cinematic);
|
||||||
isControl = false;
|
isControl = false;
|
||||||
timer = null;
|
// timer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpdate(float tpf) {
|
public void onUpdate(float tpf) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user