@Override public void write(JmeExporter ex) throws IOException { super.write(ex); OutputCapsule cap = ex.getCapsule(this); cap.write(getDamping(), "damping", 1.0f); cap.write(getTau(), "tau", 0.3f); cap.write(getImpulseClamp(), "impulseClamp", 0f); }
@Override public void read(JmeImporter im) throws IOException { super.read(im); createJoint(); InputCapsule cap=im.getCapsule(this); setDamping(cap.readFloat("damping", 1.0f)); setDamping(cap.readFloat("tau", 0.3f)); setDamping(cap.readFloat("impulseClamp", 0f)); }
@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(); } }
/** * @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 Point2PointJoint(PhysicsRigidBody nodeA, PhysicsRigidBody nodeB, Vector3f pivotA, Vector3f pivotB) { super(nodeA, nodeB, pivotA, pivotB); createJoint(); }
private native float getTau(long objectId);
private native float getImpulseClamp(long objectId);
private native void setDamping(long objectId, float value);
private native float getDamping(long objectId);
private native void setTau(long objectId, float value);
private native void setImpulseClamp(long objectId, float value);
/** * Instantiate a Point2PointJoint. To be effective, the joint must be added * to a physics space. * * @param nodeA the 1st body connected by the joint (not null, alias * created) * @param nodeB the 2nd body connected by the joint (not null, alias * created) * @param pivotA the local offset of the connection point in node A (not * null, alias created) * @param pivotB the local offset of the connection point in node B (not * null, alias created) */ public Point2PointJoint(PhysicsRigidBody nodeA, PhysicsRigidBody nodeB, Vector3f pivotA, Vector3f pivotB) { super(nodeA, nodeB, pivotA, pivotB); createJoint(); }
private native float getTau(long objectId);
private native float getImpulseClamp(long objectId);
private native void setDamping(long objectId, float value);
private native float getDamping(long objectId);
private native void setTau(long objectId, float value);
private native void setImpulseClamp(long objectId, float value);
/** * Serialize this joint, for example when saving to a J3O file. * * @param ex exporter (not null) * @throws IOException from exporter */ @Override public void write(JmeExporter ex) throws IOException { super.write(ex); OutputCapsule cap = ex.getCapsule(this); cap.write(getDamping(), "damping", 1.0f); cap.write(getTau(), "tau", 0.3f); cap.write(getImpulseClamp(), "impulseClamp", 0f); }
/** * De-serialize this joint, for example when loading from a J3O file. * * @param im importer (not null) * @throws IOException from importer */ @Override public void read(JmeImporter im) throws IOException { super.read(im); createJoint(); InputCapsule cap = im.getCapsule(this); setDamping(cap.readFloat("damping", 1.0f)); setDamping(cap.readFloat("tau", 0.3f)); setDamping(cap.readFloat("impulseClamp", 0f)); }
private native long createJoint(long objectIdA, long objectIdB, Vector3f pivotA, Vector3f pivotB); }