private void addGhostObject(PhysicsGhostObject node) { if (physicsGhostObjects.containsKey(node.getObjectId())) { logger.log(Level.WARNING, "GhostObject {0} already exists in PhysicsSpace, cannot add.", node); return; } physicsGhostObjects.put(node.getObjectId(), node); logger.log(Level.FINE, "Adding ghost object {0} to physics space.", Long.toHexString(node.getObjectId())); addCollisionObject(physicsSpaceId, node.getObjectId()); }
/** * 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 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 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; }
/** * 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); }
/** * 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); }
/** * adds an object to the physics space * @param obj the PhysicsControl or Spatial with PhysicsControl to add */ public void add(Object obj) { if (obj == null) return; if (obj instanceof PhysicsControl) { ((PhysicsControl) obj).setPhysicsSpace(this); } else if (obj instanceof Spatial) { Spatial node = (Spatial) obj; for (int i = 0; i < node.getNumControls(); i++) { if (node.getControl(i) instanceof PhysicsControl) { add(((PhysicsControl) node.getControl(i))); } } } 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.")); } }
/** * Add the specified object to this space. * * @param obj the PhysicsControl, Spatial-with-PhysicsControl, * PhysicsCollisionObject, or PhysicsJoint to add (not null, modified) */ public void add(Object obj) { if (obj instanceof PhysicsControl) { ((PhysicsControl) obj).setPhysicsSpace(this); } else if (obj instanceof Spatial) { Spatial node = (Spatial) obj; for (int i = 0; i < node.getNumControls(); i++) { if (node.getControl(i) instanceof PhysicsControl) { add(((PhysicsControl) node.getControl(i))); } } } 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.")); } }
/** * 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 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 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; } } }