com.jme3.bullet.objects.PhysicsRigidBody Java Examples
The following examples show how to use
com.jme3.bullet.objects.PhysicsRigidBody.
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 MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
private void addRigidBody(PhysicsRigidBody node) { physicsNodes.put(node.getObjectId(), node); //Workaround //It seems that adding a Kinematic RigidBody to the dynamicWorld prevent it from being non kinematic again afterward. //so we add it non kinematic, then set it kinematic again. boolean kinematic = false; if (node.isKinematic()) { kinematic = true; node.setKinematic(false); } addRigidBody(physicsSpaceId, node.getObjectId()); if (kinematic) { node.setKinematic(true); } Logger.getLogger(PhysicsSpace.class.getName()).log(Level.FINE, "Adding RigidBody {0} to physics space.", node.getObjectId()); if (node instanceof PhysicsVehicle) { Logger.getLogger(PhysicsSpace.class.getName()).log(Level.FINE, "Adding vehicle constraint {0} to physics space.", Long.toHexString(((PhysicsVehicle) node).getVehicleId())); ((PhysicsVehicle) node).createVehicle(this); addVehicle(physicsSpaceId, ((PhysicsVehicle) node).getVehicleId()); // dynamicsWorld.addVehicle(((PhysicsVehicle) node).getVehicleId()); } }
Example #2
Source File: TestIssue918.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void simpleInitApp() { CollisionShape capsule = new SphereCollisionShape(1f); PhysicsRigidBody body1 = new PhysicsRigidBody(capsule, 1f); PhysicsRigidBody body2 = new PhysicsRigidBody(capsule, 1f); Vector3f pivot1 = new Vector3f(); Vector3f pivot2 = new Vector3f(); Point2PointJoint joint = new Point2PointJoint(body1, body2, pivot1, pivot2); joint.setImpulseClamp(42f); joint.setTau(99f); if (joint.getImpulseClamp() != 42f) { throw new RuntimeException(); } if (joint.getTau() != 99f) { throw new RuntimeException(); } stop(); }
Example #3
Source File: BombControl.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override 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); }
Example #4
Source File: BombControl.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
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); }
Example #5
Source File: SixDofJoint.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
/** * @param pivotA local translation of the joint connection point in node A * @param pivotB local translation of the joint connection point in node B */ public SixDofJoint(PhysicsRigidBody nodeA, PhysicsRigidBody nodeB, Vector3f pivotA, Vector3f pivotB, Matrix3f rotA, Matrix3f rotB, boolean useLinearReferenceFrameA) { super(nodeA, nodeB, pivotA, pivotB); this.useLinearReferenceFrameA = useLinearReferenceFrameA; Transform transA = new Transform(Converter.convert(rotA)); Converter.convert(pivotA, transA.origin); Converter.convert(rotA, transA.basis); Transform transB = new Transform(Converter.convert(rotB)); Converter.convert(pivotB, transB.origin); Converter.convert(rotB, transB.basis); constraint = new Generic6DofConstraint(nodeA.getObjectId(), nodeB.getObjectId(), transA, transB, useLinearReferenceFrameA); gatherMotors(); }
Example #6
Source File: SixDofJoint.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @param pivotA local translation of the joint connection point in node A * @param pivotB local translation of the joint connection point in node B */ public SixDofJoint(PhysicsRigidBody nodeA, PhysicsRigidBody nodeB, Vector3f pivotA, Vector3f pivotB, Matrix3f rotA, Matrix3f rotB, boolean useLinearReferenceFrameA) { super(nodeA, nodeB, pivotA, pivotB); this.useLinearReferenceFrameA = useLinearReferenceFrameA; Transform transA = new Transform(Converter.convert(rotA)); Converter.convert(pivotA, transA.origin); Converter.convert(rotA, transA.basis); Transform transB = new Transform(Converter.convert(rotB)); Converter.convert(pivotB, transB.origin); Converter.convert(rotB, transB.basis); constraint = new Generic6DofConstraint(nodeA.getObjectId(), nodeB.getObjectId(), transA, transB, useLinearReferenceFrameA); gatherMotors(); }
Example #7
Source File: PhysicsSpace.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override protected void finalize() throws Throwable { for(;;) { try { while(physicsJoints.size() > 0) { remove(physicsJoints.get(0)); } while(physicsNodes.size() > 0) { for(PhysicsRigidBody node : physicsNodes.values()) { remove(node); break; } } super.finalize(); Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Finalizing PhysicsSpace {0}", Long.toHexString(physicsSpaceId)); finalizeNative(physicsSpaceId); break; } catch(Exception ex) { Logger.getLogger(PhysicsSpace.class.getName()).log(Level.SEVERE, "finalize failed.", ex); } } }
Example #8
Source File: KinematicRagdollControl.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
private void scanSpatial(Spatial model) { AnimControl animControl = model.getControl(AnimControl.class); Map<Integer, List<Float>> pointsMap = null; if (weightThreshold == -1.0f) { pointsMap = RagdollUtils.buildPointMap(model); } skeleton = animControl.getSkeleton(); skeleton.resetAndUpdate(); for (int i = 0; i < skeleton.getRoots().length; i++) { Bone childBone = skeleton.getRoots()[i]; if (childBone.getParent() == null) { logger.log(Level.INFO, "Found root bone in skeleton {0}", skeleton); baseRigidBody = new PhysicsRigidBody(new BoxCollisionShape(Vector3f.UNIT_XYZ.mult(0.1f)), 1); baseRigidBody.setKinematic(mode == Mode.Kinetmatic); boneRecursion(model, childBone, baseRigidBody, 1, pointsMap); } } }
Example #9
Source File: DacLinks.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Alter the mass of the named bone/torso. * * @param boneName the name of the bone, or torsoName (not null) * @param mass the desired mass (>0) */ @Override public void setMass(String boneName, float mass) { super.setMass(boneName, mass); if (getSpatial() != null) { PhysicsRigidBody rigidBody; if (torsoName.equals(boneName)) { rigidBody = torsoLink.getRigidBody(); } else { BoneLink link = findBoneLink(boneName); rigidBody = link.getRigidBody(); } rigidBody.setMass(mass); } }
Example #10
Source File: DacLinks.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Remove all managed physics objects from the PhysicsSpace. */ @Override protected void removePhysics(PhysicsSpace space) { assert added; PhysicsRigidBody rigidBody; if (torsoLink != null) { rigidBody = torsoLink.getRigidBody(); space.remove(rigidBody); } for (BoneLink boneLink : boneLinks.values()) { rigidBody = boneLink.getRigidBody(); space.remove(rigidBody); PhysicsJoint joint = boneLink.getJoint(); space.remove(joint); } }
Example #11
Source File: DacLinks.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Add all managed physics objects to the PhysicsSpace. */ @Override protected void addPhysics(PhysicsSpace space) { Vector3f gravity = gravity(null); PhysicsRigidBody rigidBody; if (torsoLink != null) { rigidBody = torsoLink.getRigidBody(); space.add(rigidBody); rigidBody.setGravity(gravity); } for (BoneLink boneLink : boneLinkList) { rigidBody = boneLink.getRigidBody(); space.add(rigidBody); rigidBody.setGravity(gravity); PhysicsJoint joint = boneLink.getJoint(); space.add(joint); } }
Example #12
Source File: DacLinks.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Enumerate all rigid bodies managed by this control. * <p> * Allowed only when the control IS added to a spatial. * * @return a new array of pre-existing rigid bodies (not null, not empty) */ public PhysicsRigidBody[] listRigidBodies() { verifyAddedToSpatial("enumerate rigid bodies"); int numLinks = countLinks(); PhysicsRigidBody[] result = new PhysicsRigidBody[numLinks]; int linkIndex = 0; if (torsoLink != null) { result[0] = torsoLink.getRigidBody(); ++linkIndex; } for (BoneLink boneLink : boneLinkList) { result[linkIndex] = boneLink.getRigidBody(); ++linkIndex; } assert linkIndex == numLinks; return result; }
Example #13
Source File: DynamicAnimControl.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Recalculate the total mass of the ragdoll. Also updates the location and * estimated velocity of the center of mass. */ private void recalculateCenter() { double massSum = 0.0; Vector3f locationSum = new Vector3f(); Vector3f velocitySum = new Vector3f(); Vector3f tmpVector = new Vector3f(); List<PhysicsLink> links = listLinks(PhysicsLink.class); for (PhysicsLink link : links) { PhysicsRigidBody rigidBody = link.getRigidBody(); float mass = rigidBody.getMass(); massSum += mass; rigidBody.getPhysicsLocation(tmpVector); tmpVector.multLocal(mass); locationSum.addLocal(tmpVector); link.velocity(tmpVector); tmpVector.multLocal(mass); velocitySum.addLocal(tmpVector); } float invMass = (float) (1.0 / massSum); locationSum.mult(invMass, centerLocation); velocitySum.mult(invMass, centerVelocity); ragdollMass = (float) massSum; }
Example #14
Source File: PhysicsSpace.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
private void addRigidBody(PhysicsRigidBody node) { physicsNodes.put(node.getObjectId(), node); //Workaround //It seems that adding a Kinematic RigidBody to the dynamicWorld prevent it from being non kinematic again afterward. //so we add it non kinematic, then set it kinematic again. boolean kinematic = false; if (node.isKinematic()) { kinematic = true; node.setKinematic(false); } dynamicsWorld.addRigidBody(node.getObjectId()); if (kinematic) { node.setKinematic(true); } Logger.getLogger(PhysicsSpace.class.getName()).log(Level.INFO, "Adding RigidBody {0} to physics space.", node.getObjectId()); if (node instanceof PhysicsVehicle) { Logger.getLogger(PhysicsSpace.class.getName()).log(Level.INFO, "Adding vehicle constraint {0} to physics space.", ((PhysicsVehicle) node).getVehicleId()); ((PhysicsVehicle) node).createVehicle(this); dynamicsWorld.addVehicle(((PhysicsVehicle) node).getVehicleId()); } }
Example #15
Source File: PhysicsLink.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * De-serialize this link, for example when loading from a J3O file. * * @param im importer (not null) * @throws IOException from importer */ @Override @SuppressWarnings("unchecked") public void read(JmeImporter im) throws IOException { InputCapsule ic = im.getCapsule(this); children = ic.readSavableArrayList("children", new ArrayList(1)); bone = (Joint) ic.readSavable("bone", null); control = (DacLinks) ic.readSavable("control", null); blendInterval = ic.readFloat("blendInterval", 1f); kinematicWeight = ic.readFloat("kinematicWeight", 1f); joint = (PhysicsJoint) ic.readSavable("joint", null); parent = (PhysicsLink) ic.readSavable("parent", null); rigidBody = (PhysicsRigidBody) ic.readSavable("rigidBody", null); kpTransform = (Transform) ic.readSavable("kpTransform", new Transform()); kpVelocity = (Vector3f) ic.readSavable("kpVelocity", new Vector3f()); localOffset = (Vector3f) ic.readSavable("offset", new Vector3f()); }
Example #16
Source File: SliderJoint.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @param pivotA local translation of the joint connection point in node A * @param pivotB local translation of the joint connection point in node B */ public SliderJoint(PhysicsRigidBody nodeA, PhysicsRigidBody nodeB, Vector3f pivotA, Vector3f pivotB, boolean useLinearReferenceFrameA) { super(nodeA, nodeB, pivotA, pivotB); this.rotA=new Matrix3f(); this.rotB=new Matrix3f(); this.useLinearReferenceFrameA=useLinearReferenceFrameA; createJoint(); }
Example #17
Source File: PhysicsSpace.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void addRigidBody(PhysicsRigidBody node) { if(physicsBodies.containsKey(node.getObjectId())){ logger.log(Level.WARNING, "RigidBody {0} already exists in PhysicsSpace, cannot add.", node); return; } physicsBodies.put(node.getObjectId(), node); //Workaround //It seems that adding a Kinematic RigidBody to the dynamicWorld prevent it from being non kinematic again afterward. //so we add it non kinematic, then set it kinematic again. boolean kinematic = false; if (node.isKinematic()) { kinematic = true; node.setKinematic(false); } dynamicsWorld.addRigidBody(node.getObjectId()); if (kinematic) { node.setKinematic(true); } logger.log(Level.FINE, "Adding RigidBody {0} to physics space.", node.getObjectId()); if (node instanceof PhysicsVehicle) { logger.log(Level.FINE, "Adding vehicle constraint {0} to physics space.", ((PhysicsVehicle) node).getVehicleId()); ((PhysicsVehicle) node).createVehicle(this); physicsVehicles.put(((PhysicsVehicle) node).getVehicleId(), (PhysicsVehicle)node); dynamicsWorld.addVehicle(((PhysicsVehicle) node).getVehicleId()); } }
Example #18
Source File: HingeJoint.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * Creates a new HingeJoint * @param pivotA local translation of the joint connection point in node A * @param pivotB local translation of the joint connection point in node B */ public HingeJoint(PhysicsRigidBody nodeA, PhysicsRigidBody nodeB, Vector3f pivotA, Vector3f pivotB, Vector3f axisA, Vector3f axisB) { super(nodeA, nodeB, pivotA, pivotB); this.axisA = axisA; this.axisB = axisB; createJoint(); }
Example #19
Source File: PhysicsSpace.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void addCollisionObject(PhysicsCollisionObject obj) { if (obj instanceof PhysicsGhostObject) { addGhostObject((PhysicsGhostObject) obj); } else if (obj instanceof PhysicsRigidBody) { addRigidBody((PhysicsRigidBody) obj); } else if (obj instanceof PhysicsVehicle) { addRigidBody((PhysicsVehicle) obj); } else if (obj instanceof PhysicsCharacter) { addCharacter((PhysicsCharacter) obj); } }
Example #20
Source File: BoneLink.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Calculate the local bone transform to match the physics transform of the * rigid body. * * @param storeResult storage for the result (modified if not null) * @return the calculated bone transform (in local coordinates, either * storeResult or a new transform, not null) */ private Transform localBoneTransform(Transform storeResult) { Transform result = (storeResult == null) ? new Transform() : storeResult; Vector3f location = result.getTranslation(); Quaternion orientation = result.getRotation(); Vector3f scale = result.getScale(); /* * Start with the rigid body's transform in physics/world coordinates. */ PhysicsRigidBody body = getRigidBody(); body.getPhysicsLocation(result.getTranslation()); body.getPhysicsRotation(result.getRotation()); result.setScale(body.getCollisionShape().getScale()); /* * Convert to mesh coordinates. */ Transform worldToMesh = getControl().meshTransform(null).invert(); result.combineWithParent(worldToMesh); /* * Convert to the bone's local coordinate system by factoring out the * parent bone's transform. */ Joint parentBone = getBone().getParent(); RagUtils.meshToLocal(parentBone, result); /* * Subtract the body's local offset, rotated and scaled. */ Vector3f parentOffset = localOffset(null); parentOffset.multLocal(scale); orientation.mult(parentOffset, parentOffset); location.subtractLocal(parentOffset); return result; }
Example #21
Source File: ConeJoint.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * @param pivotA local translation of the joint connection point in node A * @param pivotB local translation of the joint connection point in node B */ public ConeJoint(PhysicsRigidBody nodeA, PhysicsRigidBody nodeB, Vector3f pivotA, Vector3f pivotB, Matrix3f rotA, Matrix3f rotB) { super(nodeA, nodeB, pivotA, pivotB); this.rotA = rotA; this.rotB = rotB; createJoint(); }
Example #22
Source File: DacLinks.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Alter this control's gravitational acceleration for Ragdoll mode. * * @param gravity the desired acceleration vector (in physics-space * coordinates, not null, unaffected, default=0,-9.8,0) */ @Override public void setGravity(Vector3f gravity) { super.setGravity(gravity); if (getSpatial() != null) { // TODO make sure it's in ragdoll mode PhysicsRigidBody[] bodies = listRigidBodies(); for (PhysicsRigidBody rigidBody : bodies) { rigidBody.setGravity(gravity); } } }
Example #23
Source File: DacLinks.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Alter the viscous damping ratio for all rigid bodies, including new ones. * * @param dampingRatio the desired damping ratio (non-negative, 0→no * damping, 1→critically damped, default=0.6) */ @Override public void setDamping(float dampingRatio) { super.setDamping(dampingRatio); if (getSpatial() != null) { PhysicsRigidBody[] bodies = listRigidBodies(); for (PhysicsRigidBody rigidBody : bodies) { rigidBody.setDamping(dampingRatio, dampingRatio); } } }
Example #24
Source File: PhysicsSpace.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void addCollisionObject(PhysicsCollisionObject obj) { if (obj instanceof PhysicsGhostObject) { addGhostObject((PhysicsGhostObject) obj); } else if (obj instanceof PhysicsRigidBody) { addRigidBody((PhysicsRigidBody) obj); } else if (obj instanceof PhysicsVehicle) { addRigidBody((PhysicsVehicle) obj); } else if (obj instanceof PhysicsCharacter) { addCharacter((PhysicsCharacter) obj); } }
Example #25
Source File: SixDofJoint.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * @param pivotA local translation of the joint connection point in node A * @param pivotB local translation of the joint connection point in node B */ public SixDofJoint(PhysicsRigidBody nodeA, PhysicsRigidBody nodeB, Vector3f pivotA, Vector3f pivotB, Matrix3f rotA, Matrix3f rotB, boolean useLinearReferenceFrameA) { super(nodeA, nodeB, pivotA, pivotB); this.useLinearReferenceFrameA = useLinearReferenceFrameA; this.rotA = rotA; this.rotB = rotB; objectId = createJoint(nodeA.getObjectId(), nodeB.getObjectId(), pivotA, rotA, pivotB, rotB, useLinearReferenceFrameA); Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created Joint {0}", Long.toHexString(objectId)); gatherMotors(); }
Example #26
Source File: ReactivatePhysicsControlsTransformationHandler.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
@Override public void accept(@NotNull final Spatial spatial) { NodeUtils.children(spatial) .flatMap(ControlUtils::controls) .filter(RigidBodyControl.class::isInstance) .map(RigidBodyControl.class::cast) .filter(RigidBodyControl::isEnabled) .filter(control -> Float.compare(control.getMass(), 0.0F) != 0) .filter(control -> !control.isActive()) .forEach(PhysicsRigidBody::activate); }
Example #27
Source File: SixDofJoint.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * @param pivotA local translation of the joint connection point in node A * @param pivotB local translation of the joint connection point in node B */ public SixDofJoint(PhysicsRigidBody nodeA, PhysicsRigidBody nodeB, Vector3f pivotA, Vector3f pivotB, boolean useLinearReferenceFrameA) { super(nodeA, nodeB, pivotA, pivotB); this.useLinearReferenceFrameA = useLinearReferenceFrameA; rotA = new Matrix3f(); rotB = new Matrix3f(); objectId = createJoint(nodeA.getObjectId(), nodeB.getObjectId(), pivotA, rotA, pivotB, rotB, useLinearReferenceFrameA); Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created Joint {0}", Long.toHexString(objectId)); gatherMotors(); }
Example #28
Source File: SliderJoint.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * @param pivotA local translation of the joint connection point in node A * @param pivotB local translation of the joint connection point in node B */ public SliderJoint(PhysicsRigidBody nodeA, PhysicsRigidBody nodeB, Vector3f pivotA, Vector3f pivotB, Matrix3f rotA, Matrix3f rotB, boolean useLinearReferenceFrameA) { super(nodeA, nodeB, pivotA, pivotB); this.rotA=rotA; this.rotB=rotB; this.useLinearReferenceFrameA=useLinearReferenceFrameA; createJoint(); }
Example #29
Source File: TorsoLink.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Calculate the local bone transform to match the physics transform of the * rigid body. * * @param storeResult storage for the result (modified if not null) * @return the calculated bone transform (in local coordinates, either * storeResult or a new transform, not null) */ private Transform localBoneTransform(Transform storeResult) { Transform result = (storeResult == null) ? new Transform() : storeResult; Vector3f location = result.getTranslation(); Quaternion orientation = result.getRotation(); Vector3f scale = result.getScale(); /* * Start with the rigid body's transform in physics/world coordinates. */ PhysicsRigidBody body = getRigidBody(); body.getPhysicsLocation(result.getTranslation()); body.getPhysicsRotation(result.getRotation()); result.setScale(body.getCollisionShape().getScale()); /* * Convert to mesh coordinates. */ Transform worldToMesh = getControl().meshTransform(null).invert(); result.combineWithParent(worldToMesh); /* * Subtract the body's local offset, rotated and scaled. */ Vector3f meshOffset = localOffset(null); meshOffset.multLocal(scale); orientation.mult(meshOffset, meshOffset); location.subtractLocal(meshOffset); return result; }
Example #30
Source File: ConeJoint.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * @param pivotA local translation of the joint connection point in node A * @param pivotB local translation of the joint connection point in node B */ public ConeJoint(PhysicsRigidBody nodeA, PhysicsRigidBody nodeB, Vector3f pivotA, Vector3f pivotB) { super(nodeA, nodeB, pivotA, pivotB); this.rotA = new Matrix3f(); this.rotB = new Matrix3f(); createJoint(); }