use of com.jme3.bullet.control.BetterCharacterControl in project jmonkeyengine by jMonkeyEngine.
the class TestBetterCharacter method simpleInitApp.
@Override
public void simpleInitApp() {
//setup keyboard mapping
setupKeys();
// activate physics
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bulletAppState.setDebugEnabled(true);
// init a physics test scene
PhysicsTestHelper.createPhysicsTestWorldSoccer(rootNode, assetManager, bulletAppState.getPhysicsSpace());
PhysicsTestHelper.createBallShooter(this, rootNode, bulletAppState.getPhysicsSpace());
setupPlanet();
// Create a node for the character model
characterNode = new Node("character node");
characterNode.setLocalTranslation(new Vector3f(4, 5, 2));
// Add a character control to the node so we can add other things and
// control the model rotation
physicsCharacter = new BetterCharacterControl(0.3f, 2.5f, 8f);
characterNode.addControl(physicsCharacter);
getPhysicsSpace().add(physicsCharacter);
// Load model, attach to character node
Node model = (Node) assetManager.loadModel("Models/Jaime/Jaime.j3o");
model.setLocalScale(1.50f);
characterNode.attachChild(model);
// Add character node to the rootNode
rootNode.attachChild(characterNode);
// Set forward camera node that follows the character, only used when
// view is "locked"
camNode = new CameraNode("CamNode", cam);
camNode.setControlDir(ControlDirection.SpatialToCamera);
camNode.setLocalTranslation(new Vector3f(0, 2, -6));
Quaternion quat = new Quaternion();
// These coordinates are local, the camNode is attached to the character node!
quat.lookAt(Vector3f.UNIT_Z, Vector3f.UNIT_Y);
camNode.setLocalRotation(quat);
characterNode.attachChild(camNode);
// Disable by default, can be enabled via keyboard shortcut
camNode.setEnabled(false);
}
Aggregations