Search in sources :

Example 1 with RopeJoint

use of spacegraph.space2d.phys.dynamics.joints.RopeJoint in project narchy by automenta.

the class VerletTest method spring.

public void spring(Dynamics2D w, Body2D p, Body2D q, float STRENGTH, float REST_LENGTH) {
    // RevoluteJoint j = (RevoluteJoint) w.addJoint(new RevoluteJointDef(p, q));
    // j.positionFactor = 1f - STRENGTH;
    // j.getLocalAnchorA().set(+REST_LENGTH/2,0);
    // j.getLocalAnchorB().set(-REST_LENGTH/2,0);
    RopeJoint j = (RopeJoint) w.addJoint(new RopeJointDef(p, q));
    j.setTargetLength(REST_LENGTH);
    j.setPositionFactor(STRENGTH);
// j.getLocalAnchorA().set(+REST_LENGTH/2,0);
// j.getLocalAnchorB().set(-REST_LENGTH/2,0);
// DistanceJoint j = (DistanceJoint ) w.addJoint(new DistanceJointDef().initialize(
// p, q, new v2(0,0), new v2(+REST_LENGTH,0)
// ));
// j.setDampingRatio(0.9f);
}
Also used : RopeJoint(spacegraph.space2d.phys.dynamics.joints.RopeJoint) RopeJointDef(spacegraph.space2d.phys.dynamics.joints.RopeJointDef)

Aggregations

RopeJoint (spacegraph.space2d.phys.dynamics.joints.RopeJoint)1 RopeJointDef (spacegraph.space2d.phys.dynamics.joints.RopeJointDef)1