Java Code Examples for com.jme3.bullet.PhysicsSpace#removeTickListener()

The following examples show how to use com.jme3.bullet.PhysicsSpace#removeTickListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BombControl.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
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);
}
 
Example 2
Source File: BombControl.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);
}
 
Example 3
Source File: DynamicAnimControl.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Remove all managed physics objects from the PhysicsSpace.
 */
@Override
protected void removePhysics(PhysicsSpace space) {
    super.removePhysics(space);

    space.removeCollisionListener(this);
    space.removeTickListener(this);
}
 
Example 4
Source File: BetterCharacterControl.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Remove all managed physics objects from the specified space.
 *
 * @param space which physics space to remove from (not null)
 */
@Override
protected void removePhysics(PhysicsSpace space) {
    space.removeCollisionObject(rigidBody);
    space.removeTickListener(this);
}