|
|
@ -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); |
|
|
|
|
|
|
|
|
|
|
|
animComposer = model.getControl(AnimComposer.class); |
|
|
|
channel = control.createChannel(); |
|
|
|
for (AnimClip animClip : animComposer.getAnimClips()) { |
|
|
|
channel.setAnim(animNames[(i + j) % 4]); |
|
|
|
Action action = animComposer.action(animClip.getName()); |
|
|
|
channel.setLoopMode(LoopMode.DontLoop); |
|
|
|
animComposer.addAction(animClip.getName(), new BaseAction( |
|
|
|
SkeletonControl skeletonControl = model.getControl(SkeletonControl.class); |
|
|
|
Tweens.sequence(action, Tweens.callMethod(animComposer, "removeCurrentAction", AnimComposer.DEFAULT_LAYER)))); |
|
|
|
|
|
|
|
} |
|
|
|
//This is a workaround the issue. this call will make the SkeletonControl gather the targets again.
|
|
|
|
animComposer.setCurrentAction(new ArrayList<>(animComposer.getAnimClips()).get((i + j) % 4).getName()); |
|
|
|
//skeletonControl.setSpatial(model);
|
|
|
|
|
|
|
|
skeletonControl.setHardwareSkinningPreferred(hwSkinningEnable); |
|
|
|
SkinningControl skinningControl = model.getControl(SkinningControl.class); |
|
|
|
skControls.add(skeletonControl); |
|
|
|
skinningControl.setHardwareSkinningPreferred(hwSkinningEnable); |
|
|
|
|
|
|
|
skinningControls.add(skinningControl); |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -168,4 +172,4 @@ public class TestSkeletonControlRefresh extends SimpleApplication implements Act |
|
|
|
hwsText.setLocalTranslation(0, cam.getHeight(), 0); |
|
|
|
hwsText.setLocalTranslation(0, cam.getHeight(), 0); |
|
|
|
guiNode.attachChild(hwsText); |
|
|
|
guiNode.attachChild(hwsText); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|