Java Code Examples for com.jme3.bullet.control.RigidBodyControl#getJoints()
The following examples show how to use
com.jme3.bullet.control.RigidBodyControl#getJoints() .
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: PhysicsSpace.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 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); } } }
Example 2
Source File: PhysicsSpace.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Remove all physics controls and joints in the specified subtree of the * scene graph from the physics space (e.g. before saving to disk) Note: * recursive! * * @param spatial the root of the subtree (not null) */ 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); } } }
Example 3
Source File: PhysicsSpace.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 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); } } }
Example 4
Source File: PhysicsSpace.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 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); } } }
Example 5
Source File: PhysicsSpace.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
/** * 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) { if (spatial.getControl(RigidBodyControl.class) != null) { RigidBodyControl physicsNode = spatial.getControl(RigidBodyControl.class); if (!physicsNodes.containsValue(physicsNode)) { physicsNode.setPhysicsSpace(this); } //add joints List<PhysicsJoint> joints = physicsNode.getJoints(); for (Iterator<PhysicsJoint> it1 = joints.iterator(); it1.hasNext();) { PhysicsJoint physicsJoint = it1.next(); //add connected physicsnodes if they are not already added if (!physicsNodes.containsValue(physicsJoint.getBodyA())) { if (physicsJoint.getBodyA() instanceof PhysicsControl) { add(physicsJoint.getBodyA()); } else { addRigidBody(physicsJoint.getBodyA()); } } if (!physicsNodes.containsValue(physicsJoint.getBodyB())) { if (physicsJoint.getBodyA() instanceof PhysicsControl) { add(physicsJoint.getBodyB()); } else { addRigidBody(physicsJoint.getBodyB()); } } if (!physicsJoints.contains(physicsJoint)) { addJoint(physicsJoint); } } } else if (spatial.getControl(PhysicsControl.class) != null) { spatial.getControl(PhysicsControl.class).setPhysicsSpace(this); } //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); } } }
Example 6
Source File: PhysicsSpace.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
/** * 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); if (physicsNodes.containsValue(physicsNode)) { physicsNode.setPhysicsSpace(null); } //remove joints List<PhysicsJoint> joints = physicsNode.getJoints(); for (Iterator<PhysicsJoint> it1 = joints.iterator(); it1.hasNext();) { PhysicsJoint physicsJoint = it1.next(); //add connected physicsnodes if they are not already added if (physicsNodes.containsValue(physicsJoint.getBodyA())) { if (physicsJoint.getBodyA() instanceof PhysicsControl) { remove(physicsJoint.getBodyA()); } else { removeRigidBody(physicsJoint.getBodyA()); } } if (physicsNodes.containsValue(physicsJoint.getBodyB())) { if (physicsJoint.getBodyA() instanceof PhysicsControl) { remove(physicsJoint.getBodyB()); } else { removeRigidBody(physicsJoint.getBodyB()); } } if (physicsJoints.contains(physicsJoint)) { removeJoint(physicsJoint); } } } else if (spatial.getControl(PhysicsControl.class) != null) { spatial.getControl(PhysicsControl.class).setPhysicsSpace(null); } //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); } } }
Example 7
Source File: PhysicsSpace.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
/** * 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) { if (spatial.getControl(RigidBodyControl.class) != null) { RigidBodyControl physicsNode = spatial.getControl(RigidBodyControl.class); if (!physicsNodes.containsValue(physicsNode)) { physicsNode.setPhysicsSpace(this); } //add joints List<PhysicsJoint> joints = physicsNode.getJoints(); for (Iterator<PhysicsJoint> it1 = joints.iterator(); it1.hasNext();) { PhysicsJoint physicsJoint = it1.next(); //add connected physicsnodes if they are not already added if (!physicsNodes.containsValue(physicsJoint.getBodyA())) { if (physicsJoint.getBodyA() instanceof PhysicsControl) { add(physicsJoint.getBodyA()); } else { addRigidBody(physicsJoint.getBodyA()); } } if (!physicsNodes.containsValue(physicsJoint.getBodyB())) { if (physicsJoint.getBodyA() instanceof PhysicsControl) { add(physicsJoint.getBodyB()); } else { addRigidBody(physicsJoint.getBodyB()); } } if (!physicsJoints.contains(physicsJoint)) { addJoint(physicsJoint); } } } else if (spatial.getControl(PhysicsControl.class) != null) { spatial.getControl(PhysicsControl.class).setPhysicsSpace(this); } //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); } } }
Example 8
Source File: PhysicsSpace.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
/** * 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); if (physicsNodes.containsValue(physicsNode)) { physicsNode.setPhysicsSpace(null); } //remove joints List<PhysicsJoint> joints = physicsNode.getJoints(); for (Iterator<PhysicsJoint> it1 = joints.iterator(); it1.hasNext();) { PhysicsJoint physicsJoint = it1.next(); //add connected physicsnodes if they are not already added if (physicsNodes.containsValue(physicsJoint.getBodyA())) { if (physicsJoint.getBodyA() instanceof PhysicsControl) { remove(physicsJoint.getBodyA()); } else { removeRigidBody(physicsJoint.getBodyA()); } } if (physicsNodes.containsValue(physicsJoint.getBodyB())) { if (physicsJoint.getBodyA() instanceof PhysicsControl) { remove(physicsJoint.getBodyB()); } else { removeRigidBody(physicsJoint.getBodyB()); } } if (physicsJoints.contains(physicsJoint)) { removeJoint(physicsJoint); } } } else if (spatial.getControl(PhysicsControl.class) != null) { spatial.getControl(PhysicsControl.class).setPhysicsSpace(null); } //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); } } }