@Override protected void removePhysics(PhysicsSpace space) { if (baseRigidBody != null) { space.remove(baseRigidBody); } for (Iterator<PhysicsBoneLink> it = boneLinks.values().iterator(); it.hasNext();) { PhysicsBoneLink physicsBoneLink = it.next(); if (physicsBoneLink.joint != null) { space.remove(physicsBoneLink.joint); if (physicsBoneLink.rigidBody != null) { space.remove(physicsBoneLink.rigidBody); } } } space.removeCollisionListener(this); }
/** * 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 all physics controls and joints in the given spatial from the physics space * (e.g. before saving to disk) - recursive if node * @param spatial the rootnode containing the physics objects */ public void removeAll(Spatial spatial) { if (spatial.getControl(RigidBodyControl.class) != null) { RigidBodyControl physicsNode = spatial.getControl(RigidBodyControl.class); //remove joints with physicsNode as BodyA List<PhysicsJoint> joints = physicsNode.getJoints(); for (Iterator<PhysicsJoint> it1 = joints.iterator(); it1.hasNext();) { PhysicsJoint physicsJoint = it1.next(); if (physicsNode.equals(physicsJoint.getBodyA())) { removeJoint(physicsJoint); //remove(physicsJoint.getBodyB()); } } } remove(spatial); //recursion if (spatial instanceof Node) { List<Spatial> children = ((Node) spatial).getChildren(); for (Iterator<Spatial> it = children.iterator(); it.hasNext();) { Spatial spat = it.next(); removeAll(spat); } } }
public void tileDetached(Vector3f cell, TerrainQuad quad) { if (quad.getControl(RigidBodyControl.class) != null) { bulletAppState.getPhysicsSpace().remove(quad); quad.removeControl(RigidBodyControl.class); } }
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); }
@Override protected void removePhysics(PhysicsSpace space) { if (baseRigidBody != null) { space.remove(baseRigidBody); } for (Iterator<PhysicsBoneLink> it = boneLinks.values().iterator(); it.hasNext();) { PhysicsBoneLink physicsBoneLink = it.next(); if (physicsBoneLink.joint != null) { space.remove(physicsBoneLink.joint); if (physicsBoneLink.rigidBody != null) { space.remove(physicsBoneLink.rigidBody); } } } space.removeCollisionListener(this); }
/** * 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.")); } }
public void tileDetached(Vector3f cell, TerrainQuad quad) { if (usePhysics) { if (quad.getControl(RigidBodyControl.class) != null) { bulletAppState.getPhysicsSpace().remove(quad); quad.removeControl(RigidBodyControl.class); } } updateMarkerElevations(); } });
@Override public void update(float tpf) { super.update(tpf); if(enabled){ timer+=tpf; if(timer>maxTime){ if(spatial.getParent()!=null){ space.removeCollisionListener(this); space.remove(this); spatial.removeFromParent(); } } } if (enabled && curTime >= 0) { curTime += tpf; if (curTime > fxTime) { curTime = -1; effect.removeFromParent(); } } }
public void tileDetached(Vector3f cell, TerrainQuad quad) { if (quad.getControl(RigidBodyControl.class) != null) { bulletAppState.getPhysicsSpace().remove(quad); quad.removeControl(RigidBodyControl.class); } }
@Override protected void removePhysics(PhysicsSpace space) { if (baseRigidBody != null) { space.remove(baseRigidBody); } for (Iterator<PhysicsBoneLink> it = boneLinks.values().iterator(); it.hasNext();) { PhysicsBoneLink physicsBoneLink = it.next(); if (physicsBoneLink.joint != null) { space.remove(physicsBoneLink.joint); if (physicsBoneLink.rigidBody != null) { space.remove(physicsBoneLink.rigidBody); } } } space.removeCollisionListener(this); }
public void tileDetached(Vector3f cell, TerrainQuad quad) { if (quad.getControl(RigidBodyControl.class) != null) { bulletAppState.getPhysicsSpace().remove(quad); quad.removeControl(RigidBodyControl.class); } }
/** * Build/rebuild this body after parameters have changed. */ protected void rebuildRigidBody() { boolean removed = false; if (collisionShape instanceof MeshCollisionShape && mass != 0) { throw new IllegalStateException("Dynamic rigidbody can not have mesh collision shape!"); } if (objectId != 0) { if (isInWorld(objectId)) { PhysicsSpace.getPhysicsSpace().remove(this); removed = true; } Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Clearing RigidBody {0}", Long.toHexString(objectId)); finalizeNative(objectId); } preRebuild(); objectId = createRigidBody(mass, motionState.getObjectId(), collisionShape.getObjectId()); Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created RigidBody {0}", Long.toHexString(objectId)); postRebuild(); if (removed) { PhysicsSpace.getPhysicsSpace().add(this); } }
/** * Builds/rebuilds the phyiscs body when parameters have changed */ protected void rebuildRigidBody() { boolean removed = false; if(collisionShape instanceof MeshCollisionShape && mass != 0){ throw new IllegalStateException("Dynamic rigidbody can not have mesh collision shape!"); } if (rBody != null) { if (rBody.isInWorld()) { PhysicsSpace.getPhysicsSpace().remove(this); removed = true; } rBody.destroy(); } preRebuild(); rBody = new RigidBody(constructionInfo); postRebuild(); if (removed) { PhysicsSpace.getPhysicsSpace().add(this); } }
getPhysicsSpace().remove(slider); slider.destroy(); vehicle.applyImpulse(jumpForce, Vector3f.ZERO);
public void collision(PhysicsCollisionEvent event) { if (space == null) { return; } if (event.getObjectA() == this || event.getObjectB() == this) { space.add(ghostObject); ghostObject.setPhysicsLocation(getPhysicsLocation(vector)); space.addTickListener(this); if (effect != null && spatial.getParent() != null) { curTime = 0; effect.setLocalTranslation(spatial.getLocalTranslation()); spatial.getParent().attachChild(effect); effect.emitAllParticles(); } space.remove(this); spatial.removeFromParent(); } }
public void removePMDNode(PMDNode pmdNode) { SixDofJoint[] constArray = constraintMap.remove(pmdNode); if (constArray != null) { for (SixDofJoint joint : constArray) { physicsSpace.remove(joint); } } PMDRigidBody[] rigidBodyArray = rigidBodyMap.remove(pmdNode); if (rigidBodyArray != null) { for (PMDRigidBody rb : rigidBodyArray) { physicsSpace.remove(rb); } } nodeRigidBodyArray = rigidBodyMap.values().toArray(new PMDRigidBody[rigidBodyMap.size()][]); } float[] buf = new float[3];
public void detachFromVirtualWorld(final Node parentNode, PhysicsSpace ps) { ps.remove(myRagdollKinematicControl); parentNode.detachChild(myJME3ModelSceneNode); }
@Override public Void call() throws Exception { if (currentGeomBinding.myControl != null) { getRenderRegCli().getJme3BulletPhysicsSpace().remove(currentGeomBinding.myControl); } // Must detach by name; detaching by saved geometry does not work myContentNode.detachChildNamed(getUri().getLocalName()); myCurrAttachedBindingIndex = NULL_INDEX; return null; } }, style);