use of com.badlogic.gdx.physics.box2d.joints.PulleyJoint in project libgdx by libgdx.
the class Box2DDebugRenderer method drawJoint.
private void drawJoint(Joint joint) {
Body bodyA = joint.getBodyA();
Body bodyB = joint.getBodyB();
Transform xf1 = bodyA.getTransform();
Transform xf2 = bodyB.getTransform();
Vector2 x1 = xf1.getPosition();
Vector2 x2 = xf2.getPosition();
Vector2 p1 = joint.getAnchorA();
Vector2 p2 = joint.getAnchorB();
if (joint.getType() == JointType.DistanceJoint) {
drawSegment(p1, p2, JOINT_COLOR);
} else if (joint.getType() == JointType.PulleyJoint) {
PulleyJoint pulley = (PulleyJoint) joint;
Vector2 s1 = pulley.getGroundAnchorA();
Vector2 s2 = pulley.getGroundAnchorB();
drawSegment(s1, p1, JOINT_COLOR);
drawSegment(s2, p2, JOINT_COLOR);
drawSegment(s1, s2, JOINT_COLOR);
} else if (joint.getType() == JointType.MouseJoint) {
drawSegment(joint.getAnchorA(), joint.getAnchorB(), JOINT_COLOR);
} else {
drawSegment(x1, p1, JOINT_COLOR);
drawSegment(p1, p2, JOINT_COLOR);
drawSegment(x2, p2, JOINT_COLOR);
}
}
use of com.badlogic.gdx.physics.box2d.joints.PulleyJoint in project libgdx by libgdx.
the class World method createJoint.
/*
b2World* world = (b2World*)(addr);
b2Body* body = (b2Body*)(bodyAddr);
CustomContactFilter contactFilter(env, object);
CustomContactListener contactListener(env, object);
world->SetContactFilter(&contactFilter);
world->SetContactListener(&contactListener);
body->SetActive(false);
world->SetContactFilter(&defaultFilter);
world->SetContactListener(0);
*/
/** Create a joint to constrain bodies together. No reference to the definition is retained. This may cause the connected bodies
* to cease colliding.
* @warning This function is locked during callbacks. */
public Joint createJoint(JointDef def) {
long jointAddr = createProperJoint(def);
Joint joint = null;
if (def.type == JointType.DistanceJoint)
joint = new DistanceJoint(this, jointAddr);
if (def.type == JointType.FrictionJoint)
joint = new FrictionJoint(this, jointAddr);
if (def.type == JointType.GearJoint)
joint = new GearJoint(this, jointAddr, ((GearJointDef) def).joint1, ((GearJointDef) def).joint2);
if (def.type == JointType.MotorJoint)
joint = new MotorJoint(this, jointAddr);
if (def.type == JointType.MouseJoint)
joint = new MouseJoint(this, jointAddr);
if (def.type == JointType.PrismaticJoint)
joint = new PrismaticJoint(this, jointAddr);
if (def.type == JointType.PulleyJoint)
joint = new PulleyJoint(this, jointAddr);
if (def.type == JointType.RevoluteJoint)
joint = new RevoluteJoint(this, jointAddr);
if (def.type == JointType.RopeJoint)
joint = new RopeJoint(this, jointAddr);
if (def.type == JointType.WeldJoint)
joint = new WeldJoint(this, jointAddr);
if (def.type == JointType.WheelJoint)
joint = new WheelJoint(this, jointAddr);
if (joint != null)
joints.put(joint.addr, joint);
JointEdge jointEdgeA = new JointEdge(def.bodyB, joint);
JointEdge jointEdgeB = new JointEdge(def.bodyA, joint);
joint.jointEdgeA = jointEdgeA;
joint.jointEdgeB = jointEdgeB;
def.bodyA.joints.add(jointEdgeA);
def.bodyB.joints.add(jointEdgeB);
return joint;
}
Aggregations