Search in sources :

Example 6 with PhysicsRigidBody

use of com.jme3.bullet.objects.PhysicsRigidBody in project jmonkeyengine by jMonkeyEngine.

the class BombControl method physicsTick.

public void physicsTick(PhysicsSpace space, float f) {
    //get all overlapping objects and apply impulse to them
    for (Iterator<PhysicsCollisionObject> it = ghostObject.getOverlappingObjects().iterator(); it.hasNext(); ) {
        PhysicsCollisionObject physicsCollisionObject = it.next();
        if (physicsCollisionObject instanceof PhysicsRigidBody) {
            PhysicsRigidBody rBody = (PhysicsRigidBody) physicsCollisionObject;
            rBody.getPhysicsLocation(vector2);
            vector2.subtractLocal(vector);
            float force = explosionRadius - vector2.length();
            force *= forceFactor;
            force = force > 0 ? force : 0;
            vector2.normalizeLocal();
            vector2.multLocal(force);
            ((PhysicsRigidBody) physicsCollisionObject).applyImpulse(vector2, Vector3f.ZERO);
        }
    }
    space.removeTickListener(this);
    space.remove(ghostObject);
}
Also used : PhysicsRigidBody(com.jme3.bullet.objects.PhysicsRigidBody) PhysicsCollisionObject(com.jme3.bullet.collision.PhysicsCollisionObject)

Example 7 with PhysicsRigidBody

use of com.jme3.bullet.objects.PhysicsRigidBody in project jmonkeyengine by jMonkeyEngine.

the class PhysicsJoint method read.

public void read(JmeImporter im) throws IOException {
    InputCapsule capsule = im.getCapsule(this);
    this.nodeA = ((PhysicsRigidBody) capsule.readSavable("nodeA", new PhysicsRigidBody()));
    this.nodeB = (PhysicsRigidBody) capsule.readSavable("nodeB", new PhysicsRigidBody());
    this.pivotA = (Vector3f) capsule.readSavable("pivotA", new Vector3f());
    this.pivotB = (Vector3f) capsule.readSavable("pivotB", new Vector3f());
}
Also used : Vector3f(com.jme3.math.Vector3f) PhysicsRigidBody(com.jme3.bullet.objects.PhysicsRigidBody)

Aggregations

PhysicsRigidBody (com.jme3.bullet.objects.PhysicsRigidBody)5 Vector3f (com.jme3.math.Vector3f)5 Bone (com.jme3.animation.Bone)1 PhysicsCollisionObject (com.jme3.bullet.collision.PhysicsCollisionObject)1 HullCollisionShape (com.jme3.bullet.collision.shapes.HullCollisionShape)1 SixDofJoint (com.jme3.bullet.joints.SixDofJoint)1 InputCapsule (com.jme3.export.InputCapsule)1 Node (com.jme3.scene.Node)1 Spatial (com.jme3.scene.Spatial)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1