/** * 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); }
/** * 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); }
private void removeGhostObject(PhysicsGhostObject node) { if (!physicsGhostObjects.containsKey(node.getObjectId())) { logger.log(Level.WARNING, "GhostObject {0} does not exist in PhysicsSpace, cannot remove.", node); return; } physicsGhostObjects.remove(node.getObjectId()); logger.log(Level.FINE, "Removing ghost object {0} from physics space.", Long.toHexString(node.getObjectId())); removeCollisionObject(physicsSpaceId, node.getObjectId()); }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
public void setEnabled(boolean enabled) { this.enabled = enabled; if (space != null) { if (enabled && !added) { if (spatial != null) { warp(getSpatialTranslation()); } space.addCollisionObject(this); added = true; } else if (!enabled && added) { space.removeCollisionObject(this); added = false; } } }
public void setEnabled(boolean enabled) { this.enabled = enabled; if (space != null) { if (enabled && !added) { if (spatial != null) { warp(getSpatialTranslation()); } space.addCollisionObject(this); added = true; } else if (!enabled && added) { space.removeCollisionObject(this); added = false; } } }
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; }
/** * Remove the specified object from this space. * * @param obj the PhysicsCollisionObject to add, or null (modified) */ public void remove(Object obj) { if (obj == null) return; if (obj instanceof PhysicsControl) { ((PhysicsControl) obj).setPhysicsSpace(null); } else if (obj instanceof Spatial) { Spatial node = (Spatial) obj; for (int i = 0; i < node.getNumControls(); i++) { if (node.getControl(i) instanceof PhysicsControl) { remove(((PhysicsControl) node.getControl(i))); } } } 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.")); } }
/** * removes an object from the physics space * * @param obj the PhysicsControl or Spatial with PhysicsControl to remove */ public void remove(Object obj) { if (obj == null) return; if (obj instanceof PhysicsControl) { ((PhysicsControl) obj).setPhysicsSpace(null); } else if (obj instanceof Spatial) { Spatial node = (Spatial) obj; for (int i = 0; i < node.getNumControls(); i++) { if (node.getControl(i) instanceof PhysicsControl) { remove(((PhysicsControl) node.getControl(i))); } } } 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.")); } }
/** * Enable or disable this control. * <p> * When the control is disabled, the ghost object is removed from physics * space. When the control is enabled again, the object is moved to the * current location of the spatial and then added to the physics space. * * @param enabled true→enable the control, false→disable it */ public void setEnabled(boolean enabled) { this.enabled = enabled; if (space != null) { if (enabled && !added) { if (spatial != null) { setPhysicsLocation(getSpatialTranslation()); setPhysicsRotation(getSpatialRotation()); } space.addCollisionObject(this); added = true; } else if (!enabled && added) { space.removeCollisionObject(this); added = false; } } }
/** * Enable or disable this control. * <p> * When the control is disabled, the ghost object is removed from physics * space. When the control is enabled again, the object is moved to the * current location of the spatial and then added to the physics space. * * @param enabled true→enable the control, false→disable it */ public void setEnabled(boolean enabled) { this.enabled = enabled; if (space != null) { if (enabled && !added) { if (spatial != null) { setPhysicsLocation(getSpatialTranslation()); setPhysicsRotation(getSpatialRotation()); } space.addCollisionObject(this); added = true; } else if (!enabled && added) { space.removeCollisionObject(this); added = false; } } }
/** * Enable or disable this control. * <p> * When the control is disabled, the body is removed from physics space. * When the control is enabled again, the body is moved to the current * location of the spatial and then added to the physics space. * * @param enabled true→enable the control, false→disable it */ public void setEnabled(boolean enabled) { this.enabled = enabled; if (space != null) { if (enabled && !added) { if (spatial != null) { setPhysicsLocation(getSpatialTranslation()); setPhysicsRotation(getSpatialRotation()); } space.addCollisionObject(this); added = true; } else if (!enabled && added) { space.removeCollisionObject(this); added = false; } } }
/** * Enable or disable this control. * <p> * When the control is disabled, the vehicle is removed from physics space. * When the control is enabled again, the physics object is moved to the * spatial's location and then added to the physics space. * * @param enabled true→enable the control, false→disable it */ public void setEnabled(boolean enabled) { this.enabled = enabled; if (space != null) { if (enabled && !added) { if(spatial!=null){ setPhysicsLocation(getSpatialTranslation()); setPhysicsRotation(getSpatialRotation()); } space.addCollisionObject(this); added = true; } else if (!enabled && added) { space.removeCollisionObject(this); added = false; } } }
/** * Enable or disable this control. * <p> * When the control is disabled, the body is removed from physics space. * When the control is enabled again, the body is moved to the current * location of the spatial and then added to the physics space. * * @param enabled true→enable the control, false→disable it */ public void setEnabled(boolean enabled) { this.enabled = enabled; if (space != null) { if (enabled && !added) { if (spatial != null) { setPhysicsLocation(getSpatialTranslation()); setPhysicsRotation(getSpatialRotation()); } space.addCollisionObject(this); added = true; } else if (!enabled && added) { space.removeCollisionObject(this); added = false; } } }