Migrate TestSkeletonControlRefresh to new anim system (#1334)
* Migrate TestSkeletonControlRefresh to new anim system Migrate SkeletonControl to new SkinningControl * Update TestSkeletonControlRefresh.java * Update TestSkeletonControlRefresh.java * Update TestSkeletonControlRefresh.java * Update TestSkeletonControlRefresh.java * Update TestSkeletonControlRefresh.java * Update TestSkeletonControlRefresh.java * Update TestSkeletonControlRefresh.java * Eleminate inner class * Update TestSkeletonControlRefresh.java * Update TestSkeletonControlRefresh.java
This commit is contained in:
parent
26f393d09c
commit
b92e7a0abe
@ -37,7 +37,12 @@ package jme3test.model.anim;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import com.jme3.animation.*;
|
import com.jme3.anim.AnimClip;
|
||||||
|
import com.jme3.anim.AnimComposer;
|
||||||
|
import com.jme3.anim.SkinningControl;
|
||||||
|
import com.jme3.anim.tween.Tweens;
|
||||||
|
import com.jme3.anim.tween.action.Action;
|
||||||
|
import com.jme3.anim.tween.action.BaseAction;
|
||||||
import com.jme3.app.SimpleApplication;
|
import com.jme3.app.SimpleApplication;
|
||||||
import com.jme3.asset.TextureKey;
|
import com.jme3.asset.TextureKey;
|
||||||
import com.jme3.font.BitmapText;
|
import com.jme3.font.BitmapText;
|
||||||
@ -58,15 +63,12 @@ import com.jme3.shadow.DirectionalLightShadowFilter;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
//TODO rework this Test when the new animation system is done.
|
|
||||||
public class TestSkeletonControlRefresh extends SimpleApplication implements ActionListener{
|
public class TestSkeletonControlRefresh extends SimpleApplication implements ActionListener{
|
||||||
|
|
||||||
private AnimChannel channel;
|
private AnimComposer animComposer;
|
||||||
private AnimControl control;
|
|
||||||
private String[] animNames = {"Dodge", "Walk", "pull", "push"};
|
|
||||||
private final static int SIZE = 10;
|
private final static int SIZE = 10;
|
||||||
private boolean hwSkinningEnable = true;
|
private boolean hwSkinningEnable = true;
|
||||||
private List<SkeletonControl> skControls = new ArrayList<SkeletonControl>();
|
private List<SkinningControl> skinningControls = new ArrayList<>();
|
||||||
private BitmapText hwsText;
|
private BitmapText hwsText;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -92,22 +94,24 @@ public class TestSkeletonControlRefresh extends SimpleApplication implements Act
|
|||||||
|
|
||||||
for (int i = 0; i < SIZE; i++) {
|
for (int i = 0; i < SIZE; i++) {
|
||||||
for (int j = 0; j < SIZE; j++) {
|
for (int j = 0; j < SIZE; j++) {
|
||||||
Spatial model = assetManager.loadModel("Models/Oto/OtoOldAnim.j3o");
|
Spatial model = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
|
||||||
//setting a different material
|
//setting a different material
|
||||||
model.setMaterial(m.clone());
|
model.setMaterial(m.clone());
|
||||||
model.setLocalScale(0.1f);
|
model.setLocalScale(0.1f);
|
||||||
model.setLocalTranslation(i - SIZE / 2, 0, j - SIZE / 2);
|
model.setLocalTranslation(i - SIZE / 2, 0, j - SIZE / 2);
|
||||||
control = model.getControl(AnimControl.class);
|
|
||||||
|
|
||||||
channel = control.createChannel();
|
animComposer = model.getControl(AnimComposer.class);
|
||||||
channel.setAnim(animNames[(i + j) % 4]);
|
for (AnimClip animClip : animComposer.getAnimClips()) {
|
||||||
channel.setLoopMode(LoopMode.DontLoop);
|
Action action = animComposer.action(animClip.getName());
|
||||||
SkeletonControl skeletonControl = model.getControl(SkeletonControl.class);
|
animComposer.addAction(animClip.getName(), new BaseAction(
|
||||||
|
Tweens.sequence(action, Tweens.callMethod(animComposer, "removeCurrentAction", AnimComposer.DEFAULT_LAYER))));
|
||||||
|
}
|
||||||
|
animComposer.setCurrentAction(new ArrayList<>(animComposer.getAnimClips()).get((i + j) % 4).getName());
|
||||||
|
|
||||||
|
SkinningControl skinningControl = model.getControl(SkinningControl.class);
|
||||||
|
skinningControl.setHardwareSkinningPreferred(hwSkinningEnable);
|
||||||
|
skinningControls.add(skinningControl);
|
||||||
|
|
||||||
//This is a workaround the issue. this call will make the SkeletonControl gather the targets again.
|
|
||||||
//skeletonControl.setSpatial(model);
|
|
||||||
skeletonControl.setHardwareSkinningPreferred(hwSkinningEnable);
|
|
||||||
skControls.add(skeletonControl);
|
|
||||||
rootNode.attachChild(model);
|
rootNode.attachChild(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,10 +157,10 @@ public class TestSkeletonControlRefresh extends SimpleApplication implements Act
|
|||||||
public void onAction(String name, boolean isPressed, float tpf) {
|
public void onAction(String name, boolean isPressed, float tpf) {
|
||||||
if(isPressed && name.equals("toggleHWS")){
|
if(isPressed && name.equals("toggleHWS")){
|
||||||
hwSkinningEnable = !hwSkinningEnable;
|
hwSkinningEnable = !hwSkinningEnable;
|
||||||
for (SkeletonControl skControl : skControls) {
|
for (SkinningControl sc : skinningControls) {
|
||||||
skControl.setHardwareSkinningPreferred(hwSkinningEnable);
|
sc.setHardwareSkinningPreferred(hwSkinningEnable);
|
||||||
hwsText.setText("HWS : "+ hwSkinningEnable);
|
|
||||||
}
|
}
|
||||||
|
hwsText.setText("HWS : "+ hwSkinningEnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user