ufk

SkeletonDebugger trial

ufk
Jul 10th, 2012
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.33 KB | None | 0 0
  1. package com.xpogames.movinghand;
  2.  
  3. import com.jme3.animation.AnimChannel;
  4. import com.jme3.animation.AnimControl;
  5. import com.jme3.app.SimpleApplication;
  6. import com.jme3.font.BitmapText;
  7. import com.jme3.light.DirectionalLight;
  8. import com.jme3.material.Material;
  9. import com.jme3.math.ColorRGBA;
  10. import com.jme3.math.Vector3f;
  11. import com.jme3.scene.Spatial;
  12. import com.jme3.scene.debug.SkeletonDebugger;
  13.  
  14. /**
  15.  *
  16.  * @author ufk
  17.  */
  18. public class MovingHand extends SimpleApplication {
  19.    
  20.   public static void main(String[] args){
  21.         MovingHand app = new MovingHand();
  22.         app.start(); // start the game
  23.     }
  24.  
  25.     @Override
  26.     public void simpleInitApp() {
  27.     Spatial hand = assetManager.loadModel("Models/Worm/worm.j3o");
  28.         Material mat_default = new Material(
  29.             assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
  30.         hand.setMaterial(mat_default);
  31.         rootNode.attachChild(hand);
  32.         hand.rotate(0,1f,1f);
  33.         final AnimControl control = hand.getControl(AnimControl.class);
  34.        
  35.         final AnimChannel channel = control.createChannel();
  36.         final SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton", control.getSkeleton());
  37.         final Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
  38.         mat.setColor("Color", ColorRGBA.Green);
  39.         mat.getAdditionalRenderState().setDepthTest(false);
  40.         skeletonDebug.setMaterial(mat);
  41.         rootNode.attachChild(skeletonDebug);
  42.         // Create a wall with a simple texture from test_data
  43.         // Display a line of text with a default font
  44.         guiNode.detachAllChildren();
  45.         guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
  46.         BitmapText helloText = new BitmapText(guiFont, false);
  47.         helloText.setSize(guiFont.getCharSet().getRenderedSize());
  48.         helloText.setText("Hello World - " + (control == null ? "is null" : "is not null"));
  49.         helloText.setLocalTranslation(300, helloText.getLineHeight(), 0);
  50.         guiNode.attachChild(helloText);
  51.  
  52.         // Load a model from test_data (OgreXML + material + texture)
  53.         // You must add a light to make the model visible
  54.         DirectionalLight sun = new DirectionalLight();
  55.         sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));
  56.         rootNode.addLight(sun);
  57.    }    
  58. }
Advertisement
Add Comment
Please, Sign In to add comment