Search in sources :

Example 6 with BulletAppState

use of com.jme3.bullet.BulletAppState in project jmonkeyengine by jMonkeyEngine.

the class TestRagDoll method simpleInitApp.

@Override
public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    stateManager.attach(bulletAppState);
    bulletAppState.setDebugEnabled(true);
    inputManager.addMapping("Pull ragdoll up", new MouseButtonTrigger(0));
    inputManager.addListener(this, "Pull ragdoll up");
    PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
    createRagDoll();
}
Also used : BulletAppState(com.jme3.bullet.BulletAppState) MouseButtonTrigger(com.jme3.input.controls.MouseButtonTrigger)

Example 7 with BulletAppState

use of com.jme3.bullet.BulletAppState in project jmonkeyengine by jMonkeyEngine.

the class TestRagdollCharacter method simpleInitApp.

public void simpleInitApp() {
    setupKeys();
    bulletAppState = new BulletAppState();
    bulletAppState.setEnabled(true);
    stateManager.attach(bulletAppState);
    //        bulletAppState.getPhysicsSpace().enableDebug(assetManager);
    PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
    initWall(2, 1, 1);
    setupLight();
    cam.setLocation(new Vector3f(-8, 0, -4));
    cam.lookAt(new Vector3f(4, 0, -7), Vector3f.UNIT_Y);
    model = (Node) assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
    model.lookAt(new Vector3f(0, 0, -1), Vector3f.UNIT_Y);
    model.setLocalTranslation(4, 0, -7f);
    ragdoll = new KinematicRagdollControl(0.5f);
    model.addControl(ragdoll);
    getPhysicsSpace().add(ragdoll);
    speed = 1.3f;
    rootNode.attachChild(model);
    AnimControl control = model.getControl(AnimControl.class);
    animChannel = control.createChannel();
    animChannel.setAnim("IdleTop");
    control.addListener(this);
}
Also used : BulletAppState(com.jme3.bullet.BulletAppState) Vector3f(com.jme3.math.Vector3f) KinematicRagdollControl(com.jme3.bullet.control.KinematicRagdollControl) AnimControl(com.jme3.animation.AnimControl)

Example 8 with BulletAppState

use of com.jme3.bullet.BulletAppState in project jmonkeyengine by jMonkeyEngine.

the class TestSweepTest method simpleInitApp.

@Override
public void simpleInitApp() {
    obstacleCollisionShape = new CapsuleCollisionShape(0.3f, 0.5f);
    capsuleCollisionShape = new CapsuleCollisionShape(1f, 1f);
    stateManager.attach(bulletAppState);
    capsule = new Node("capsule");
    capsule.move(-2, 0, 0);
    capsule.addControl(new RigidBodyControl(capsuleCollisionShape, 1));
    capsule.getControl(RigidBodyControl.class).setKinematic(true);
    bulletAppState.getPhysicsSpace().add(capsule);
    rootNode.attachChild(capsule);
    obstacle = new Node("obstacle");
    obstacle.move(2, 0, 0);
    RigidBodyControl bodyControl = new RigidBodyControl(obstacleCollisionShape, 0);
    obstacle.addControl(bodyControl);
    bulletAppState.getPhysicsSpace().add(obstacle);
    rootNode.attachChild(obstacle);
    bulletAppState.setDebugEnabled(true);
}
Also used : Node(com.jme3.scene.Node) CapsuleCollisionShape(com.jme3.bullet.collision.shapes.CapsuleCollisionShape) RigidBodyControl(com.jme3.bullet.control.RigidBodyControl)

Example 9 with BulletAppState

use of com.jme3.bullet.BulletAppState in project jmonkeyengine by jMonkeyEngine.

the class TestPhysicsRayCast method simpleInitApp.

@Override
public void simpleInitApp() {
    stateManager.attach(bulletAppState);
    initCrossHair();
    Spatial s = assetManager.loadModel("Models/Elephant/Elephant.mesh.xml");
    s.setLocalScale(0.1f);
    CollisionShape collisionShape = CollisionShapeFactory.createMeshShape(s);
    Node n = new Node("elephant");
    n.addControl(new RigidBodyControl(collisionShape, 1));
    n.getControl(RigidBodyControl.class).setKinematic(true);
    bulletAppState.getPhysicsSpace().add(n);
    rootNode.attachChild(n);
    bulletAppState.setDebugEnabled(true);
}
Also used : CollisionShape(com.jme3.bullet.collision.shapes.CollisionShape) Spatial(com.jme3.scene.Spatial) Node(com.jme3.scene.Node) RigidBodyControl(com.jme3.bullet.control.RigidBodyControl)

Example 10 with BulletAppState

use of com.jme3.bullet.BulletAppState in project jmonkeyengine by jMonkeyEngine.

the class TestQ3 method simpleInitApp.

public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    stateManager.attach(bulletAppState);
    flyCam.setMoveSpeed(100);
    setupKeys();
    this.cam.setFrustumFar(2000);
    DirectionalLight dl = new DirectionalLight();
    dl.setColor(ColorRGBA.White.clone().multLocal(2));
    dl.setDirection(new Vector3f(-1, -1, -1).normalize());
    rootNode.addLight(dl);
    AmbientLight am = new AmbientLight();
    am.setColor(ColorRGBA.White.mult(2));
    rootNode.addLight(am);
    // load the level from zip or http zip
    if (useHttp) {
        assetManager.registerLocator("http://jmonkeyengine.googlecode.com/files/quake3level.zip", HttpZipLocator.class);
    } else {
        assetManager.registerLocator("quake3level.zip", ZipLocator.class);
    }
    // create the geometry and attach it
    MaterialList matList = (MaterialList) assetManager.loadAsset("Scene.material");
    OgreMeshKey key = new OgreMeshKey("main.meshxml", matList);
    gameLevel = (Node) assetManager.loadAsset(key);
    gameLevel.setLocalScale(0.1f);
    // add a physics control, it will generate a MeshCollisionShape based on the gameLevel
    gameLevel.addControl(new RigidBodyControl(0));
    player = new PhysicsCharacter(new SphereCollisionShape(5), .01f);
    player.setJumpSpeed(20);
    player.setFallSpeed(30);
    player.setGravity(30);
    player.setPhysicsLocation(new Vector3f(60, 10, -60));
    rootNode.attachChild(gameLevel);
    getPhysicsSpace().addAll(gameLevel);
    getPhysicsSpace().add(player);
}
Also used : PhysicsCharacter(com.jme3.bullet.objects.PhysicsCharacter) SphereCollisionShape(com.jme3.bullet.collision.shapes.SphereCollisionShape) BulletAppState(com.jme3.bullet.BulletAppState) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) MaterialList(com.jme3.material.MaterialList) OgreMeshKey(com.jme3.scene.plugins.ogre.OgreMeshKey) RigidBodyControl(com.jme3.bullet.control.RigidBodyControl) AmbientLight(com.jme3.light.AmbientLight)

Aggregations

BulletAppState (com.jme3.bullet.BulletAppState)34 Vector3f (com.jme3.math.Vector3f)25 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)20 Node (com.jme3.scene.Node)14 Sphere (com.jme3.scene.shape.Sphere)13 SphereCollisionShape (com.jme3.bullet.collision.shapes.SphereCollisionShape)11 CapsuleCollisionShape (com.jme3.bullet.collision.shapes.CapsuleCollisionShape)8 DirectionalLight (com.jme3.light.DirectionalLight)8 Material (com.jme3.material.Material)8 Box (com.jme3.scene.shape.Box)8 CharacterControl (com.jme3.bullet.control.CharacterControl)7 ColorRGBA (com.jme3.math.ColorRGBA)7 TerrainLodControl (com.jme3.terrain.geomipmap.TerrainLodControl)6 TerrainQuad (com.jme3.terrain.geomipmap.TerrainQuad)6 MouseButtonTrigger (com.jme3.input.controls.MouseButtonTrigger)5 DistanceLodCalculator (com.jme3.terrain.geomipmap.lodcalc.DistanceLodCalculator)5 ScreenshotAppState (com.jme3.app.state.ScreenshotAppState)4 HeightfieldCollisionShape (com.jme3.bullet.collision.shapes.HeightfieldCollisionShape)4 Plane (com.jme3.math.Plane)4 Geometry (com.jme3.scene.Geometry)4