use of com.jme3.bullet.BulletAppState in project jmonkeyengine by jMonkeyEngine.
the class TestBatchNodeTower method simpleInitApp.
@Override
public void simpleInitApp() {
timer = new NanoTimer();
bulletAppState = new BulletAppState();
bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
// bulletAppState.setEnabled(false);
stateManager.attach(bulletAppState);
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.4f);
brick = new Box(brickWidth, brickHeight, brickDepth);
brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
//bulletAppState.getPhysicsSpace().enableDebug(assetManager);
initMaterial();
initTower();
initFloor();
initCrossHairs();
this.cam.setLocation(new Vector3f(0, 25f, 8f));
cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
cam.setFrustumFar(80);
inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(actionListener, "shoot");
rootNode.setShadowMode(ShadowMode.Off);
batchNode.batch();
batchNode.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(batchNode);
shadowRenderer = new DirectionalLightShadowFilter(assetManager, 1024, 2);
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
shadowRenderer.setLight(dl);
shadowRenderer.setLambda(0.55f);
shadowRenderer.setShadowIntensity(0.6f);
shadowRenderer.setShadowCompareMode(CompareMode.Hardware);
shadowRenderer.setEdgeFilteringMode(EdgeFilteringMode.PCF4);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
fpp.addFilter(shadowRenderer);
viewPort.addProcessor(fpp);
}
use of com.jme3.bullet.BulletAppState in project jmonkeyengine by jMonkeyEngine.
the class TestAttachDriver method simpleInitApp.
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bulletAppState.setDebugEnabled(true);
setupKeys();
setupFloor();
buildPlayer();
}
use of com.jme3.bullet.BulletAppState in project jmonkeyengine by jMonkeyEngine.
the class TestAttachGhostObject method simpleInitApp.
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bulletAppState.setDebugEnabled(true);
setupKeys();
setupJoint();
}
use of com.jme3.bullet.BulletAppState 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);
}
use of com.jme3.bullet.BulletAppState in project jmonkeyengine by jMonkeyEngine.
the class TestCcd 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.1f);
setupKeys();
mat = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.getAdditionalRenderState().setWireframe(true);
mat.setColor("Color", ColorRGBA.Green);
mat2 = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat2.getAdditionalRenderState().setWireframe(true);
mat2.setColor("Color", ColorRGBA.Red);
// An obstacle mesh, does not move (mass=0)
Node node2 = new Node();
node2.setName("mesh");
node2.setLocalTranslation(new Vector3f(2.5f, 0, 0f));
node2.addControl(new RigidBodyControl(new MeshCollisionShape(new Box(4, 4, 0.1f)), 0));
rootNode.attachChild(node2);
getPhysicsSpace().add(node2);
// The floor, does not move (mass=0)
Node node3 = new Node();
node3.setLocalTranslation(new Vector3f(0f, -6, 0f));
node3.addControl(new RigidBodyControl(new BoxCollisionShape(new Vector3f(100, 1, 100)), 0));
rootNode.attachChild(node3);
getPhysicsSpace().add(node3);
}
Aggregations