Search in sources :

Example 56 with Node

use of com.jme3.scene.Node in project jmonkeyengine by jMonkeyEngine.

the class TestRagDoll method createLimb.

private Node createLimb(float width, float height, Vector3f location, boolean rotate) {
    int axis = rotate ? PhysicsSpace.AXIS_X : PhysicsSpace.AXIS_Y;
    CapsuleCollisionShape shape = new CapsuleCollisionShape(width, height, axis);
    Node node = new Node("Limb");
    RigidBodyControl rigidBodyControl = new RigidBodyControl(shape, 1);
    node.setLocalTranslation(location);
    node.addControl(rigidBodyControl);
    return node;
}
Also used : Node(com.jme3.scene.Node) CapsuleCollisionShape(com.jme3.bullet.collision.shapes.CapsuleCollisionShape) RigidBodyControl(com.jme3.bullet.control.RigidBodyControl) PhysicsJoint(com.jme3.bullet.joints.PhysicsJoint) ConeJoint(com.jme3.bullet.joints.ConeJoint)

Example 57 with Node

use of com.jme3.scene.Node in project jmonkeyengine by jMonkeyEngine.

the class TestRagDoll method join.

private PhysicsJoint join(Node A, Node B, Vector3f connectionPoint) {
    Vector3f pivotA = A.worldToLocal(connectionPoint, new Vector3f());
    Vector3f pivotB = B.worldToLocal(connectionPoint, new Vector3f());
    ConeJoint joint = new ConeJoint(A.getControl(RigidBodyControl.class), B.getControl(RigidBodyControl.class), pivotA, pivotB);
    joint.setLimit(1f, 1f, 0);
    return joint;
}
Also used : Vector3f(com.jme3.math.Vector3f) RigidBodyControl(com.jme3.bullet.control.RigidBodyControl) ConeJoint(com.jme3.bullet.joints.ConeJoint)

Example 58 with Node

use of com.jme3.scene.Node 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 59 with Node

use of com.jme3.scene.Node 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 60 with Node

use of com.jme3.scene.Node 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)

Aggregations

Node (com.jme3.scene.Node)135 Vector3f (com.jme3.math.Vector3f)81 Geometry (com.jme3.scene.Geometry)64 Spatial (com.jme3.scene.Spatial)53 Material (com.jme3.material.Material)51 DirectionalLight (com.jme3.light.DirectionalLight)35 Quaternion (com.jme3.math.Quaternion)32 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)26 Box (com.jme3.scene.shape.Box)24 Sphere (com.jme3.scene.shape.Sphere)19 AmbientLight (com.jme3.light.AmbientLight)17 BulletAppState (com.jme3.bullet.BulletAppState)16 ColorRGBA (com.jme3.math.ColorRGBA)15 AnimControl (com.jme3.animation.AnimControl)14 KeyTrigger (com.jme3.input.controls.KeyTrigger)14 FilterPostProcessor (com.jme3.post.FilterPostProcessor)14 HashMap (java.util.HashMap)14 CameraNode (com.jme3.scene.CameraNode)13 ArrayList (java.util.ArrayList)13 ActionListener (com.jme3.input.controls.ActionListener)12