Advertisement
Guest User

Untitled

a guest
Jun 1st, 2014
181
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import com.jme3.app.SimpleApplication;
  2. import com.jme3.bullet.BulletAppState;
  3. import com.jme3.bullet.control.RigidBodyControl;
  4. import com.jme3.bullet.util.CollisionShapeFactory;
  5. import com.jme3.material.Material;
  6. import com.jme3.math.ColorRGBA;
  7. import com.jme3.math.Vector3f;
  8. import com.jme3.scene.Geometry;
  9. import com.jme3.scene.shape.Box;
  10. import com.jme3.system.AppSettings;
  11.  
  12. public class CodeExample extends SimpleApplication{
  13.  
  14. public static void main(String[] args) {
  15. CodeExample ex = new CodeExample();
  16. AppSettings set = new AppSettings(true);
  17. set.setFrameRate(100);
  18.  
  19. ex.setSettings(set);
  20. ex.setShowSettings(false);
  21. ex.start();
  22. }
  23.  
  24. public void simpleInitApp() {
  25. BulletAppState bas = new BulletAppState();
  26. stateManager.attach(bas);
  27.  
  28. Geometry geom = new Geometry("body", new Box(1,1,1));
  29. geom.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"));
  30. geom.getMaterial().setColor("Color", ColorRGBA.Orange);
  31.  
  32. RigidBodyControl rbc = new RigidBodyControl(CollisionShapeFactory.createBoxShape(geom), 10);
  33. geom.addControl(rbc);
  34.  
  35. bas.getPhysicsSpace().add(rbc);
  36. rootNode.attachChild(geom);
  37.  
  38. cam.setLocation(new Vector3f(0, -20, 50));
  39. }
  40. }
Advertisement
RAW Paste Data Copied
Advertisement