3333
3434import com .jme3 .anim .AnimComposer ;
3535import com .jme3 .anim .SkinningControl ;
36+ import com .jme3 .app .DetailedProfilerState ;
3637import com .jme3 .app .SimpleApplication ;
3738import com .jme3 .font .BitmapText ;
3839import com .jme3 .input .KeyInput ;
3940import com .jme3 .input .controls .ActionListener ;
4041import com .jme3 .input .controls .KeyTrigger ;
4142import com .jme3 .light .DirectionalLight ;
4243import com .jme3 .math .*;
44+ import com .jme3 .scene .Node ;
4345import com .jme3 .scene .Spatial ;
4446
4547import java .util .ArrayList ;
@@ -50,7 +52,7 @@ public class TestHWSkinning extends SimpleApplication implements ActionListener{
5052
5153 // private AnimComposer composer;
5254 private String [] animNames = {"Dodge" , "Walk" , "pull" , "push" };
53- private final static int SIZE = 40 ;
55+ private final static int SIZE = 60 ;
5456 private boolean hwSkinningEnable = true ;
5557 private List <SkinningControl > skControls = new ArrayList <SkinningControl >();
5658 private BitmapText hwsText ;
@@ -65,8 +67,8 @@ public void simpleInitApp() {
6567 flyCam .setMoveSpeed (10f );
6668 flyCam .setDragToRotate (true );
6769 setPauseOnLostFocus (false );
68- cam .setLocation (new Vector3f (24.746134f , 13.081396f , 32.72753f ));
69- cam .setRotation (new Quaternion (-0.06867662f , 0.92435044f , -0.19981281f , -0.31770203f ));
70+ cam .setLocation (new Vector3f (38.76639f , 14.744472f , 45.097454f ));
71+ cam .setRotation (new Quaternion (-0.06086266f , 0.92303723f , -0.1639443f , -0.34266636f ));
7072
7173 makeHudText ();
7274
@@ -75,23 +77,38 @@ public void simpleInitApp() {
7577 dl .setColor (new ColorRGBA (1f , 1f , 1f , 1.0f ));
7678 rootNode .addLight (dl );
7779
80+ Spatial models [] = new Spatial [4 ];
81+ for (int i = 0 ; i < 4 ; i ++) {
82+ models [i ] =loadModel (i );
83+ }
84+
7885 for (int i = 0 ; i < SIZE ; i ++) {
7986 for (int j = 0 ; j < SIZE ; j ++) {
80- Spatial model = (Spatial ) assetManager .loadModel ("Models/Oto/Oto.mesh.xml" );
81- model .setLocalScale (0.1f );
82- model .setLocalTranslation (i - SIZE / 2 , 0 , j - SIZE / 2 );
83- AnimComposer composer = model .getControl (AnimComposer .class );
84-
85- composer .setCurrentAction (animNames [(i + j ) % 4 ]);
86- SkinningControl skinningControl = model .getControl (SkinningControl .class );
87- skinningControl .setHardwareSkinningPreferred (hwSkinningEnable );
88- skControls .add (skinningControl );
89- rootNode .attachChild (model );
87+ Node model = (Node )models [(i + j ) % 4 ];
88+ Spatial s = model .getChild (0 ).clone ();
89+ model .attachChild (s );
90+ float x = (float )(i - SIZE / 2 ) / 0.1f ;
91+ float z = (float )(j - SIZE / 2 ) / 0.1f ;
92+ s .setLocalTranslation (x , 0 , z );
9093 }
9194 }
9295
9396 inputManager .addListener (this , "toggleHWS" );
9497 inputManager .addMapping ("toggleHWS" , new KeyTrigger (KeyInput .KEY_SPACE ));
98+
99+ }
100+
101+ private Spatial loadModel (int i ) {
102+ Spatial model = assetManager .loadModel ("Models/Oto/Oto.mesh.xml" );
103+ model .setLocalScale (0.1f );
104+ AnimComposer composer = model .getControl (AnimComposer .class );
105+
106+ composer .setCurrentAction (animNames [i ]);
107+ SkinningControl skinningControl = model .getControl (SkinningControl .class );
108+ skinningControl .setHardwareSkinningPreferred (hwSkinningEnable );
109+ skControls .add (skinningControl );
110+ rootNode .attachChild (model );
111+ return model ;
95112 }
96113
97114 @ Override
0 commit comments