Java Code Examples for com.jme3.bullet.control.PhysicsControl#setPhysicsSpace()

The following examples show how to use com.jme3.bullet.control.PhysicsControl#setPhysicsSpace() . 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: PhysicsSpace.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * adds an object to the physics space
 * @param obj the PhysicsControl or Spatial with PhysicsControl to add
 */
public void add(Object obj) {
    if (obj instanceof PhysicsControl) {
        ((PhysicsControl) obj).setPhysicsSpace(this);
    } else if (obj instanceof Spatial) {
        Spatial node = (Spatial) obj;
        PhysicsControl control = node.getControl(PhysicsControl.class);
        control.setPhysicsSpace(this);
    } else if (obj instanceof PhysicsCollisionObject) {
        addCollisionObject((PhysicsCollisionObject) obj);
    } else if (obj instanceof PhysicsJoint) {
        addJoint((PhysicsJoint) obj);
    } else {
        throw (new UnsupportedOperationException("Cannot add this kind of object to the physics space."));
    }
}
 
Example 2
Source File: PhysicsSpace.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * removes an object from the physics space
 * @param obj the PhysicsControl or Spatial with PhysicsControl to remove
 */
public void remove(Object obj) {
    if (obj instanceof PhysicsControl) {
        ((PhysicsControl) obj).setPhysicsSpace(null);
    } else if (obj instanceof Spatial) {
        Spatial node = (Spatial) obj;
        PhysicsControl control = node.getControl(PhysicsControl.class);
        control.setPhysicsSpace(null);
    } else if (obj instanceof PhysicsCollisionObject) {
        removeCollisionObject((PhysicsCollisionObject) obj);
    } else if (obj instanceof PhysicsJoint) {
        removeJoint((PhysicsJoint) obj);
    } else if (obj == null) {
        return;
    } else {
        throw (new UnsupportedOperationException("Cannot remove this kind of object from the physics space."+obj));
    }
}
 
Example 3
Source File: PhysicsSpace.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * adds an object to the physics space
 * @param obj the PhysicsControl or Spatial with PhysicsControl to add
 */
public void add(Object obj) {
    if (obj instanceof PhysicsControl) {
        ((PhysicsControl) obj).setPhysicsSpace(this);
    } else if (obj instanceof Spatial) {
        Spatial node = (Spatial) obj;
        PhysicsControl control = node.getControl(PhysicsControl.class);
        control.setPhysicsSpace(this);
    } else if (obj instanceof PhysicsCollisionObject) {
        addCollisionObject((PhysicsCollisionObject) obj);
    } else if (obj instanceof PhysicsJoint) {
        addJoint((PhysicsJoint) obj);
    } else {
        throw (new UnsupportedOperationException("Cannot add this kind of object to the physics space."));
    }
}
 
Example 4
Source File: PhysicsSpace.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * removes an object from the physics space
 * @param obj the PhysicsControl or Spatial with PhysicsControl to remove
 */
public void remove(Object obj) {
    if (obj instanceof PhysicsControl) {
        ((PhysicsControl) obj).setPhysicsSpace(null);
    } else if (obj instanceof Spatial) {
        Spatial node = (Spatial) obj;
        PhysicsControl control = node.getControl(PhysicsControl.class);
        control.setPhysicsSpace(null);
    } else if (obj instanceof PhysicsCollisionObject) {
        removeCollisionObject((PhysicsCollisionObject) obj);
    } else if (obj instanceof PhysicsJoint) {
        removeJoint((PhysicsJoint) obj);
    } else {
        throw (new UnsupportedOperationException("Cannot remove this kind of object from the physics space."));
    }
}