Search in sources :

Example 6 with PhysicsCollisionObject

use of com.jme3.bullet.collision.PhysicsCollisionObject 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)

Aggregations

PhysicsCollisionObject (com.jme3.bullet.collision.PhysicsCollisionObject)6 CollisionObject (com.bulletphysics.collision.dispatch.CollisionObject)2 ContactAddedCallback (com.bulletphysics.ContactAddedCallback)1 ContactDestroyedCallback (com.bulletphysics.ContactDestroyedCallback)1 ContactProcessedCallback (com.bulletphysics.ContactProcessedCallback)1 BroadphaseProxy (com.bulletphysics.collision.broadphase.BroadphaseProxy)1 OverlapFilterCallback (com.bulletphysics.collision.broadphase.OverlapFilterCallback)1 PairCachingGhostObject (com.bulletphysics.collision.dispatch.PairCachingGhostObject)1 ManifoldPoint (com.bulletphysics.collision.narrowphase.ManifoldPoint)1 TypedConstraint (com.bulletphysics.dynamics.constraintsolver.TypedConstraint)1 Bone (com.jme3.animation.Bone)1 PhysicsCollisionGroupListener (com.jme3.bullet.collision.PhysicsCollisionGroupListener)1 PhysicsRayTestResult (com.jme3.bullet.collision.PhysicsRayTestResult)1 PhysicsSweepTestResult (com.jme3.bullet.collision.PhysicsSweepTestResult)1 RagdollCollisionListener (com.jme3.bullet.collision.RagdollCollisionListener)1 PhysicsJoint (com.jme3.bullet.joints.PhysicsJoint)1 PhysicsGhostObject (com.jme3.bullet.objects.PhysicsGhostObject)1 PhysicsRigidBody (com.jme3.bullet.objects.PhysicsRigidBody)1 Transform (com.jme3.math.Transform)1