File tree 3 files changed +53
-3
lines changed
jme3-core/src/main/java/com/jme3
jme3-examples/src/main/java/jme3test/animation
3 files changed +53
-3
lines changed Original file line number Diff line number Diff line change @@ -456,6 +456,37 @@ public void setGlobalSpeed(float globalSpeed) {
456
456
this .globalSpeed = globalSpeed ;
457
457
}
458
458
459
+ /**
460
+ * Access the manager of the named layer.
461
+ *
462
+ * @param layerName the name of the layer to access
463
+ * @return the current manager (typically an AnimEvent) or null for none
464
+ */
465
+ public Object getLayerManager (String layerName ) {
466
+ Layer layer = layers .get (layerName );
467
+ if (layer == null ) {
468
+ throw new IllegalArgumentException ("Unknown layer " + layerName );
469
+ }
470
+
471
+ return layer .manager ;
472
+ }
473
+
474
+ /**
475
+ * Assign a manager to the named layer.
476
+ *
477
+ * @param layerName the name of the layer to modify
478
+ * @param manager the desired manager (typically an AnimEvent) or null for
479
+ * none
480
+ */
481
+ public void setLayerManager (String layerName , Object manager ) {
482
+ Layer layer = layers .get (layerName );
483
+ if (layer == null ) {
484
+ throw new IllegalArgumentException ("Unknown layer " + layerName );
485
+ }
486
+
487
+ layer .manager = manager ;
488
+ }
489
+
459
490
/**
460
491
* Create a shallow clone for the JME cloner.
461
492
*
@@ -539,6 +570,7 @@ private static class Layer implements JmeCloneable {
539
570
private Action currentAction ;
540
571
private AnimationMask mask ;
541
572
private double time ;
573
+ private Object manager ;
542
574
543
575
public Layer (AnimComposer ac ) {
544
576
this .ac = ac ;
Original file line number Diff line number Diff line change @@ -123,8 +123,11 @@ public void initEvent(Application app, Cinematic cinematic) {
123
123
public void onPause () {
124
124
logger .log (Level .SEVERE , "" );
125
125
126
- Action eventAction = composer .action (actionName );
127
- eventAction .setSpeed (0f );
126
+ Object layerManager = composer .getLayerManager (layerName );
127
+ if (layerManager == this ) {
128
+ Action eventAction = composer .action (actionName );
129
+ eventAction .setSpeed (0f );
130
+ }
128
131
}
129
132
130
133
/**
@@ -149,6 +152,7 @@ public void onPlay() {
149
152
composer .setTime (layerName , 0.0 );
150
153
}
151
154
eventAction .setSpeed (speed );
155
+ composer .setLayerManager (layerName , this );
152
156
}
153
157
154
158
/**
@@ -157,7 +161,12 @@ public void onPlay() {
157
161
@ Override
158
162
public void onStop () {
159
163
logger .log (Level .INFO , "" );
160
- composer .removeCurrentAction (layerName );
164
+
165
+ Object layerManager = composer .getLayerManager (layerName );
166
+ if (layerManager == this ) {
167
+ composer .removeCurrentAction (layerName );
168
+ composer .setLayerManager (layerName , null );
169
+ }
161
170
}
162
171
163
172
/**
Original file line number Diff line number Diff line change @@ -159,10 +159,19 @@ public void setupCinematic(final Node jaime) {
159
159
AnimClip forwardClip = af .buildAnimation (jaime );
160
160
AnimComposer composer = jaime .getControl (AnimComposer .class );
161
161
composer .addAnimClip (forwardClip );
162
+ /*
163
+ * Add a clip that warps the model to its starting position.
164
+ */
165
+ AnimFactory af2 = new AnimFactory (0.01f , "StartingPosition" , 30f );
166
+ af2 .addTimeTranslation (0f , new Vector3f (0f , 0f , -3f ));
167
+ AnimClip startClip = af2 .buildAnimation (jaime );
168
+ composer .addAnimClip (startClip );
162
169
163
170
composer .makeLayer ("SpatialLayer" , null );
164
171
String boneLayer = AnimComposer .DEFAULT_LAYER ;
165
172
173
+ cinematic .addCinematicEvent (0f ,
174
+ new AnimEvent (composer , "StartingPosition" , "SpatialLayer" ));
166
175
cinematic .enqueueCinematicEvent (
167
176
new AnimEvent (composer , "Idle" , boneLayer ));
168
177
float jumpStart = cinematic .enqueueCinematicEvent (
You can’t perform that action at this time.
0 commit comments