use of com.jme3.bullet.BulletAppState in project jmonkeyengine by jMonkeyEngine.
the class TestCollisionListener method simpleInitApp.
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bulletAppState.setDebugEnabled(true);
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.4f);
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
PhysicsTestHelper.createBallShooter(this, rootNode, bulletAppState.getPhysicsSpace());
// add ourselves as collision listener
getPhysicsSpace().addCollisionListener(this);
}
use of com.jme3.bullet.BulletAppState in project jmonkeyengine by jMonkeyEngine.
the class TestCollisionShapeFactory method simpleInitApp.
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bulletAppState.setDebugEnabled(true);
createMaterial();
Node node = new Node("node1");
attachRandomGeometry(node, mat1);
randomizeTransform(node);
Node node2 = new Node("node2");
attachRandomGeometry(node2, mat2);
randomizeTransform(node2);
node.attachChild(node2);
rootNode.attachChild(node);
RigidBodyControl control = new RigidBodyControl(0);
node.addControl(control);
getPhysicsSpace().add(control);
//test single geometry too
Geometry myGeom = new Geometry("cylinder", new Cylinder(16, 16, 0.5f, 1));
myGeom.setMaterial(mat3);
randomizeTransform(myGeom);
rootNode.attachChild(myGeom);
RigidBodyControl control3 = new RigidBodyControl(0);
myGeom.addControl(control3);
getPhysicsSpace().add(control3);
}
use of com.jme3.bullet.BulletAppState in project jmonkeyengine by jMonkeyEngine.
the class TestFancyCar method simpleInitApp.
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
// bulletAppState.getPhysicsSpace().enableDebug(assetManager);
if (settings.getRenderer().startsWith("LWJGL")) {
BasicShadowRenderer bsr = new BasicShadowRenderer(assetManager, 512);
bsr.setDirection(new Vector3f(-0.5f, -0.3f, -0.3f).normalizeLocal());
// viewPort.addProcessor(bsr);
}
cam.setFrustumFar(150f);
flyCam.setMoveSpeed(10);
setupKeys();
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
// setupFloor();
buildPlayer();
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.5f, -1f, -0.3f).normalizeLocal());
rootNode.addLight(dl);
dl = new DirectionalLight();
dl.setDirection(new Vector3f(0.5f, -0.1f, 0.3f).normalizeLocal());
// rootNode.addLight(dl);
}
use of com.jme3.bullet.BulletAppState in project jmonkeyengine by jMonkeyEngine.
the class TestGhostObject method simpleInitApp.
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bulletAppState.setDebugEnabled(true);
// Mesh to be shared across several boxes.
Box boxGeom = new Box(1f, 1f, 1f);
// CollisionShape to be shared across several boxes.
CollisionShape shape = new BoxCollisionShape(new Vector3f(1, 1, 1));
Node physicsBox = PhysicsTestHelper.createPhysicsTestNode(assetManager, shape, 1);
physicsBox.setName("box0");
physicsBox.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(.6f, 4, .5f));
rootNode.attachChild(physicsBox);
getPhysicsSpace().add(physicsBox);
Node physicsBox1 = PhysicsTestHelper.createPhysicsTestNode(assetManager, shape, 1);
physicsBox1.setName("box1");
physicsBox1.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0, 40, 0));
rootNode.attachChild(physicsBox1);
getPhysicsSpace().add(physicsBox1);
Node physicsBox2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(1, 1, 1)), 1);
physicsBox2.setName("box0");
physicsBox2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(.5f, 80, -.8f));
rootNode.attachChild(physicsBox2);
getPhysicsSpace().add(physicsBox2);
// the floor, does not move (mass=0)
Node node = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(100, 1, 100)), 0);
node.setName("floor");
node.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, -6, 0f));
rootNode.attachChild(node);
getPhysicsSpace().add(node);
initGhostObject();
}
use of com.jme3.bullet.BulletAppState in project jmonkeyengine by jMonkeyEngine.
the class TestPhysicsCharacter method simpleInitApp.
@Override
public void simpleInitApp() {
// activate physics
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
// init a physical test scene
PhysicsTestHelper.createPhysicsTestWorldSoccer(rootNode, assetManager, bulletAppState.getPhysicsSpace());
setupKeys();
// Add a physics character to the world
physicsCharacter = new CharacterControl(new CapsuleCollisionShape(0.5f, 1.8f), .1f);
physicsCharacter.setPhysicsLocation(new Vector3f(0, 1, 0));
characterNode = new Node("character node");
Spatial model = assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
model.scale(0.25f);
characterNode.addControl(physicsCharacter);
getPhysicsSpace().add(physicsCharacter);
rootNode.attachChild(characterNode);
characterNode.attachChild(model);
// set forward camera node that follows the character
camNode = new CameraNode("CamNode", cam);
camNode.setControlDir(ControlDirection.SpatialToCamera);
camNode.setLocalTranslation(new Vector3f(0, 1, -5));
camNode.lookAt(model.getLocalTranslation(), Vector3f.UNIT_Y);
characterNode.attachChild(camNode);
//disable the default 1st-person flyCam (don't forget this!!)
flyCam.setEnabled(false);
}
Aggregations