Search in sources :

Example 1 with DistanceJoint

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

the class Box2DTests method drawJoint.

private void drawJoint(Joint joint) {
    g.setColor(Color.GREEN);
    Tuple2f v1 = new Vec2();
    Tuple2f v2 = new Vec2();
    switch(joint.getType()) {
        case DISTANCE:
            DistanceJoint dj = (DistanceJoint) joint;
            v1 = joint.getBodyA().getWorldPoint(dj.getLocalAnchorA());
            v2 = joint.getBodyB().getWorldPoint(dj.getLocalAnchorB());
            break;
        case MOUSE:
            MouseJoint localMj = (MouseJoint) joint;
            localMj.getAnchorA(v1);
            localMj.getAnchorB(v2);
            break;
    }
    Point p1 = getPoint(v1);
    Point p2 = getPoint(v2);
    g.drawLine(p1.x, p1.y, p2.x, p2.y);
}
Also used : Tuple2f(spacegraph.util.math.Tuple2f) DistanceJoint(spacegraph.space2d.phys.dynamics.joints.DistanceJoint) Vec2(spacegraph.space2d.phys.common.Vec2) MouseJoint(spacegraph.space2d.phys.dynamics.joints.MouseJoint)

Aggregations

Vec2 (spacegraph.space2d.phys.common.Vec2)1 DistanceJoint (spacegraph.space2d.phys.dynamics.joints.DistanceJoint)1 MouseJoint (spacegraph.space2d.phys.dynamics.joints.MouseJoint)1 Tuple2f (spacegraph.util.math.Tuple2f)1