/** * Destroy this joint and remove it from the joint lists of its connected * bodies. */ public void destroy() { getBodyA().removeJoint(this); getBodyB().removeJoint(this); }
/** * destroys this joint and removes it from its connected PhysicsRigidBodys joint lists */ public void destroy() { getBodyA().removeJoint(this); getBodyB().removeJoint(this); }
/** * 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); } } }
/** * Add all collision objects and joints in the specified subtree of the * scene graph to this space (e.g. after loading from disk). Note: * recursive! * * @param spatial the root of the subtree (not null) */ public void addAll(Spatial spatial) { add(spatial); if (spatial.getControl(RigidBodyControl.class) != null) { RigidBodyControl physicsNode = spatial.getControl(RigidBodyControl.class); //add 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())) { //add(physicsJoint.getBodyB()); add(physicsJoint); } } } //recursion if (spatial instanceof Node) { List<Spatial> children = ((Node) spatial).getChildren(); for (Iterator<Spatial> it = children.iterator(); it.hasNext();) { Spatial spat = it.next(); addAll(spat); } } }
/** * adds all physics controls and joints in the given spatial node to the physics space * (e.g. after loading from disk) - recursive if node * @param spatial the rootnode containing the physics objects */ public void addAll(Spatial spatial) { add(spatial); if (spatial.getControl(RigidBodyControl.class) != null) { RigidBodyControl physicsNode = spatial.getControl(RigidBodyControl.class); //add 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())) { //add(physicsJoint.getBodyB()); add(physicsJoint); } } } //recursion if (spatial instanceof Node) { List<Spatial> children = ((Node) spatial).getChildren(); for (Iterator<Spatial> it = children.iterator(); it.hasNext();) { Spatial spat = it.next(); addAll(spat); } } }
for (Iterator<PhysicsJoint> it1 = joints.iterator(); it1.hasNext();) { PhysicsJoint physicsJoint = it1.next(); if (physicsNode.equals(physicsJoint.getBodyA())) { removeJoint(physicsJoint);
/** * Update this control. Invoked once per frame during the logical-state * update, provided the control is enabled and added to a scene. Should be * invoked only by a subclass or by AbstractControl. * * @param tpf the time interval between frames (in seconds, ≥0) */ @Override protected void controlUpdate(float tpf) { body.getBodyA().getPhysicsLocation(a.getTranslation()); body.getBodyA().getPhysicsRotation(a.getRotation()); body.getBodyB().getPhysicsLocation(b.getTranslation()); body.getBodyB().getPhysicsRotation(b.getRotation()); geomA.setLocalTransform(a); geomB.setLocalTransform(b); arrowA.setArrowExtent(body.getPivotA()); arrowB.setArrowExtent(body.getPivotB()); }
/** * Update this control. Invoked once per frame during the logical-state * update, provided the control is enabled and added to a scene. Should be * invoked only by a subclass or by AbstractControl. * * @param tpf the time interval between frames (in seconds, ≥0) */ @Override protected void controlUpdate(float tpf) { body.getBodyA().getPhysicsLocation(a.getTranslation()); body.getBodyA().getPhysicsRotation(a.getRotation()); body.getBodyB().getPhysicsLocation(b.getTranslation()); body.getBodyB().getPhysicsRotation(b.getRotation()); geomA.setLocalTransform(a); geomB.setLocalTransform(b); arrowA.setArrowExtent(body.getPivotA()); arrowB.setArrowExtent(body.getPivotB()); }
/** * destroys this joint and removes it from its connected PhysicsRigidBodys joint lists */ public void destroy() { getBodyA().removeJoint(this); getBodyB().removeJoint(this); }
/** * destroys this joint and removes it from its connected PhysicsRigidBodys joint lists */ public void destroy() { getBodyA().removeJoint(this); getBodyB().removeJoint(this); }
/** * destroys this joint and removes it from its connected PhysicsRigidBodys joint lists */ public void destroy() { getBodyA().removeJoint(this); getBodyB().removeJoint(this); }
/** * adds all physics controls and joints in the given spatial node to the physics space * (e.g. after loading from disk) - recursive if node * @param spatial the rootnode containing the physics objects */ public void addAll(Spatial spatial) { add(spatial); if (spatial.getControl(RigidBodyControl.class) != null) { RigidBodyControl physicsNode = spatial.getControl(RigidBodyControl.class); //add 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())) { //add(physicsJoint.getBodyB()); add(physicsJoint); } } } //recursion if (spatial instanceof Node) { List<Spatial> children = ((Node) spatial).getChildren(); for (Iterator<Spatial> it = children.iterator(); it.hasNext();) { Spatial spat = it.next(); addAll(spat); } } }
/** * 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); } } }
/** * 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); } } }
/** * adds all physics controls and joints in the given spatial node to the physics space * (e.g. after loading from disk) - recursive if node * @param spatial the rootnode containing the physics objects */ public void addAll(Spatial spatial) { add(spatial); if (spatial.getControl(RigidBodyControl.class) != null) { RigidBodyControl physicsNode = spatial.getControl(RigidBodyControl.class); //add 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())) { //add(physicsJoint.getBodyB()); add(physicsJoint); } } } //recursion if (spatial instanceof Node) { List<Spatial> children = ((Node) spatial).getChildren(); for (Iterator<Spatial> it = children.iterator(); it.hasNext();) { Spatial spat = it.next(); addAll(spat); } } }
PhysicsJoint physicsJoint = it1.next(); if (!physicsNodes.containsValue(physicsJoint.getBodyA())) { if (physicsJoint.getBodyA() instanceof PhysicsControl) { add(physicsJoint.getBodyA()); } else { addRigidBody(physicsJoint.getBodyA()); if (physicsJoint.getBodyA() instanceof PhysicsControl) { add(physicsJoint.getBodyB()); } else {
PhysicsJoint physicsJoint = it1.next(); if (physicsNodes.containsValue(physicsJoint.getBodyA())) { if (physicsJoint.getBodyA() instanceof PhysicsControl) { remove(physicsJoint.getBodyA()); } else { removeRigidBody(physicsJoint.getBodyA()); if (physicsJoint.getBodyA() instanceof PhysicsControl) { remove(physicsJoint.getBodyB()); } else {
@Override protected Spatial getDebugShape() { //add joints Spatial shape = super.getDebugShape(); Node node = null; if (shape instanceof Node) { node = (Node) shape; } else { node = new Node("DebugShapeNode"); node.attachChild(shape); } int i = 0; for (Iterator<PhysicsJoint> it = joints.iterator(); it.hasNext();) { PhysicsJoint physicsJoint = it.next(); Vector3f pivot = null; if (physicsJoint.getBodyA() == this) { pivot = physicsJoint.getPivotA(); } else { pivot = physicsJoint.getPivotB(); } Arrow arrow = new Arrow(pivot); Geometry geom = new Geometry("DebugBone" + i, arrow); geom.setMaterial(debugMaterialGreen); node.attachChild(geom); i++; } return node; }
@Override protected void controlUpdate(float tpf) { body.getBodyA().getPhysicsLocation(a.getTranslation()); body.getBodyA().getPhysicsRotation(a.getRotation()); body.getBodyB().getPhysicsLocation(b.getTranslation()); body.getBodyB().getPhysicsRotation(b.getRotation()); geomA.setLocalTransform(a); geomB.setLocalTransform(b); arrowA.setArrowExtent(body.getPivotA()); arrowB.setArrowExtent(body.getPivotB()); }
/** * Update this control. Invoked once per frame during the logical-state * update, provided the control is enabled and added to a scene. Should be * invoked only by a subclass or by AbstractControl. * * @param tpf the time interval between frames (in seconds, ≥0) */ @Override protected void controlUpdate(float tpf) { body.getBodyA().getPhysicsLocation(a.getTranslation()); body.getBodyA().getPhysicsRotation(a.getRotation()); body.getBodyB().getPhysicsLocation(b.getTranslation()); body.getBodyB().getPhysicsRotation(b.getRotation()); geomA.setLocalTransform(a); geomB.setLocalTransform(b); arrowA.setArrowExtent(body.getPivotA()); arrowB.setArrowExtent(body.getPivotB()); }