Skip to content

Commit b65e49d

Browse files
committed
Idle first ClipAction, Continue second only after 1st run
1 parent 4610505 commit b65e49d

File tree

1 file changed

+22
-4
lines changed
  • app/src/main/java/com/scrappers/dbtraining/mainScreens/prefaceScreen/renderer/animationWrapper

1 file changed

+22
-4
lines changed

app/src/main/java/com/scrappers/dbtraining/mainScreens/prefaceScreen/renderer/animationWrapper/BlendableAnimation.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
import com.jme3.anim.util.HasLocalTransform;
1717
import com.jme3.app.Application;
1818
import com.jme3.app.state.BaseAppState;
19+
import com.jme3.cinematic.Cinematic;
20+
import com.jme3.cinematic.events.AnimEvent;
21+
import com.jme3.cinematic.events.AnimationEvent;
22+
import com.jme3.cinematic.events.CinematicEvent;
23+
import com.jme3.math.FastMath;
1924
import com.jme3.math.Quaternion;
2025
import com.jme3.math.Transform;
2126
import com.jme3.math.Vector3f;
@@ -36,9 +41,11 @@ public class BlendableAnimation extends BaseAppState implements BlendSpace {
3641
private final Spatial dataBaseStack;
3742
//create a global AnimComposer Control instance
3843
private AnimComposer animComposer;
44+
private LinearBlendSpace linearBlendSpace;
3945
private ClipAction capRotationClip;
4046
private BlendAction blendAction;
4147
private BaseAction baseAction;
48+
private float count = 0;
4249
public BlendableAnimation(final String id, final Spatial dataBaseStack){
4350
super(id);
4451
this.dataBaseStack=dataBaseStack;
@@ -91,12 +98,16 @@ protected void initialize(Application app) {
9198
capRotationClip.setLength(10f);
9299
capRotationClip.setTransitionLength(10f);
93100
//9)feed the BlendableActions to a single BlendAction
94-
blendAction=new BlendAction(new LinearBlendSpace(5,10), bottleTractionClip, capRotationClip);
101+
float minValueOfBlendSlider = 6;
102+
float maxValueOfBlendSlider = 12;
103+
linearBlendSpace = new LinearBlendSpace(minValueOfBlendSlider, maxValueOfBlendSlider);
104+
linearBlendSpace.setValue(FastMath.interpolateLinear(0.5f, 6, 12));
105+
blendAction=new BlendAction(linearBlendSpace, capRotationClip, bottleTractionClip);
95106
baseAction=new BaseAction(Tweens.sequence(capRotationClip, blendAction));
96107
baseAction.setLength(10f);
97108
baseAction.setSpeed(2f);
98109
//10)add that BlendAction to the AnimComposer using addAction(...)
99-
animComposer.addAction("SimulateBottleFall", baseAction);
110+
animComposer.addAction("SimulateBottleFall", blendAction);
100111
animComposer.makeLayer(LayerBuilder.LAYER_BLENDABLE_ANIM, new ArmatureMask());
101112

102113
}
@@ -124,6 +135,14 @@ protected void onDisable() {
124135
}
125136
}
126137

138+
@Override
139+
public void update(float tpf) {
140+
count += tpf;
141+
if(count > blendAction.getLength()){
142+
linearBlendSpace.setValue(FastMath.interpolateLinear(1, 6, 12));
143+
}
144+
}
145+
127146
/**
128147
* additional method for additional settings to set during the instantiation of #{@link BlendAction} instance
129148
* this method gets called inside the Constructor of #{@link BlendAction#BlendAction(BlendSpace, BlendableAction...)} when the BlendAction instance gets instantiated\.
@@ -175,8 +194,7 @@ public void setBlendAction(BlendAction action) {
175194
*/
176195
@Override
177196
public float getWeight() {
178-
capRotationClip.setCollectTransformDelegate(blendAction);
179-
return 1.5f;
197+
return 1;
180198
}
181199

182200
/**

0 commit comments

Comments
 (0)