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

The following examples show how to use com.jme3.bullet.PhysicsSpace#addCollisionObject() . 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: CharacterControl.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * If enabled, add this control's physics object to the specified physics
 * space. If not enabled, alter where the object would be added. The object
 * is removed from any other space it's currently in.
 *
 * @param newSpace where to add, or null to simply remove
 */
@Override
public void setPhysicsSpace(PhysicsSpace newSpace) {
    if (space == newSpace) {
        return;
    }
    if (added) {
        space.removeCollisionObject(this);
        added = false;
    }
    if (newSpace != null && isEnabled()) {
        newSpace.addCollisionObject(this);
        added = true;
    }
    /*
     * If this control isn't enabled, its physics object will be
     * added to the new space when the control becomes enabled.
     */
    space = newSpace;
}
 
Example 2
Source File: RigidBodyControl.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * If enabled, add this control's body to the specified physics space. In
 * not enabled, alter where the body would be added. The body is removed
 * from any other space it's currently in.
 *
 * @param newSpace where to add, or null to simply remove
 */
@Override
public void setPhysicsSpace(PhysicsSpace newSpace) {
    if (space == newSpace) {
        return;
    }
    if (added) {
        space.removeCollisionObject(this);
        added = false;
    }
    if (newSpace != null && isEnabled()) {
        newSpace.addCollisionObject(this);
        added = true;
    }
    /*
     * If this control isn't enabled, its body will be
     * added to the new space when the control becomes enabled.
     */
    space = newSpace;
}
 
Example 3
Source File: VehicleControl.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * If enabled, add this control's physics object to the specified physics
 * space. In not enabled, alter where the object would be added. The object
 * is removed from any other space it's currently in.
 *
 * @param newSpace where to add, or null to simply remove
 */
@Override
public void setPhysicsSpace(PhysicsSpace newSpace) {
    if (space == newSpace) {
        return;
    }
    if (added) {
        space.removeCollisionObject(this);
        added = false;
    }
    if (newSpace != null && isEnabled()) {
        newSpace.addCollisionObject(this);
        added = true;
    }
    /*
     * If this control isn't enabled, its physics object will be
     * added to the new space when the control becomes enabled.
     */
    space = newSpace;
}
 
Example 4
Source File: GhostControl.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * If enabled, add this control's physics object to the specified physics
 * space. If not enabled, alter where the object would be added. The object
 * is removed from any other space it's currently in.
 *
 * @param newSpace where to add, or null to simply remove
 */
@Override
public void setPhysicsSpace(PhysicsSpace newSpace) {
    if (space == newSpace) {
        return;
    }
    if (added) {
        space.removeCollisionObject(this);
        added = false;
    }
    if (newSpace != null && isEnabled()) {
        newSpace.addCollisionObject(this);
        added = true;
    }
    /*
     * If this control isn't enabled, its physics object will be
     * added to the new space when the control becomes enabled.
     */
    space = newSpace;
}
 
Example 5
Source File: PhysicsHoverControl.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void setPhysicsSpace(PhysicsSpace space) {
    createVehicle(space);
    if (space == null) {
        if (this.space != null) {
            this.space.removeCollisionObject(this);
            this.space.removeTickListener(this);
        }
        this.space = space;
    } else {
        space.addCollisionObject(this);
        space.addTickListener(this);
    }
    this.space = space;
}
 
Example 6
Source File: BetterCharacterControl.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Add all managed physics objects to the specified space.
 *
 * @param space which physics space to add to (not null)
 */
@Override
protected void addPhysics(PhysicsSpace space) {
    space.getGravity(localUp).normalizeLocal().negateLocal();
    updateLocalCoordinateSystem();

    space.addCollisionObject(rigidBody);
    space.addTickListener(this);
}
 
Example 7
Source File: CharacterControl.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setPhysicsSpace(PhysicsSpace space) {
    if (space == null) {
        if (this.space != null) {
            this.space.removeCollisionObject(this);
            added = false;
        }
    } else {
        if (this.space == space) {
            return;
        }
        space.addCollisionObject(this);
        added = true;
    }
    this.space = space;
}
 
Example 8
Source File: RigidBodyControl.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setPhysicsSpace(PhysicsSpace space) {
    if (space == null) {
        if (this.space != null) {
            this.space.removeCollisionObject(this);
            added = false;
        }
    } else {
        if(this.space==space) return;
        space.addCollisionObject(this);
        added = true;
    }
    this.space = space;
}
 
Example 9
Source File: VehicleControl.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setPhysicsSpace(PhysicsSpace space) {
//        createVehicle(space);
        if (space == null) {
            if (this.space != null) {
                this.space.removeCollisionObject(this);
                added = false;
            }
        } else {
            if(this.space==space) return;
            space.addCollisionObject(this);
            added = true;
        }
        this.space = space;
    }
 
Example 10
Source File: GhostControl.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setPhysicsSpace(PhysicsSpace space) {
    if (space == null) {
        if (this.space != null) {
            this.space.removeCollisionObject(this);
            added = false;
        }
    } else {
        if (this.space == space) {
            return;
        }
        space.addCollisionObject(this);
        added = true;
    }
    this.space = space;
}
 
Example 11
Source File: CharacterControl.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setPhysicsSpace(PhysicsSpace space) {
    if (space == null) {
        if (this.space != null) {
            this.space.removeCollisionObject(this);
            added = false;
        }
    } else {
        if (this.space == space) {
            return;
        }
        space.addCollisionObject(this);
        added = true;
    }
    this.space = space;
}
 
Example 12
Source File: RigidBodyControl.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setPhysicsSpace(PhysicsSpace space) {
    if (space == null) {
        if (this.space != null) {
            this.space.removeCollisionObject(this);
            added = false;
        }
    } else {
        if(this.space==space) return;
        space.addCollisionObject(this);
        added = true;
    }
    this.space = space;
}
 
Example 13
Source File: VehicleControl.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setPhysicsSpace(PhysicsSpace space) {
    createVehicle(space);
    if (space == null) {
        if (this.space != null) {
            this.space.removeCollisionObject(this);
            added = false;
        }
    } else {
        if(this.space==space) return;
        space.addCollisionObject(this);
        added = true;
    }
    this.space = space;
}
 
Example 14
Source File: GhostControl.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setPhysicsSpace(PhysicsSpace space) {
    if (space == null) {
        if (this.space != null) {
            this.space.removeCollisionObject(this);
            added = false;
        }
    } else {
        if (this.space == space) {
            return;
        }
        space.addCollisionObject(this);
        added = true;
    }
    this.space = space;
}
 
Example 15
Source File: PhysicsHoverControl.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setPhysicsSpace(PhysicsSpace space) {
    if (space == null) {
        if (this.space != null) {
            this.space.removeCollisionObject(this);
            this.space.removeTickListener(this);
        }
        this.space = space;
    } else {
        space.addCollisionObject(this);
        space.addTickListener(this);
    }
    this.space = space;
}