/** Destroy a joint. This may cause the connected bodies to begin colliding. * @warning This function is locked during callbacks. */ public void destroyJoint (Joint joint) { joint.setUserData(null); world.destroyJoint(joint.joint); joints.remove(joint.joint); }
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); } }
@Override public org.jbox2d.dynamics.joints.JointDef toJBox2d () { org.jbox2d.dynamics.joints.GearJointDef jd = new org.jbox2d.dynamics.joints.GearJointDef(); jd.bodyA = bodyA.body; jd.bodyB = bodyB.body; jd.collideConnected = collideConnected; jd.joint1 = joint1.getJBox2DJoint(); jd.joint2 = joint2.getJBox2DJoint(); jd.ratio = ratio; jd.type = org.jbox2d.dynamics.joints.JointType.GEAR; return jd; } }
public Vector2 getAnchorA () { jniGetAnchorA(addr, tmp); anchorA.x = tmp[0]; anchorA.y = tmp[1]; return anchorA; }
@Override public Joint getPhysicsJoint(String name) { Array<Joint> joints = new Array<>(world.getJointCount()); world.getJoints(joints); for (Joint joint : joints) if (joint.getUserData().equals(name)) return joint; return null; }
public Vector2 getAnchorA () { jniGetAnchorA(addr, tmp); anchorA.x = tmp[0]; anchorA.y = tmp[1]; return anchorA; }
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); } }
/** Destroy a joint. This may cause the connected bodies to begin colliding. * @warning This function is locked during callbacks. */ public void destroyJoint (Joint joint) { joint.setUserData(null); joints.remove(joint.addr); joint.jointEdgeA.other.joints.removeValue(joint.jointEdgeB, true); joint.jointEdgeB.other.joints.removeValue(joint.jointEdgeA, true); jniDestroyJoint(addr, joint.addr); }
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); } }
/** Destroy a joint. This may cause the connected bodies to begin colliding. * @warning This function is locked during callbacks. */ public void destroyJoint (Joint joint) { joint.setUserData(null); joints.remove(joint.addr); joint.jointEdgeA.other.joints.removeValue(joint.jointEdgeB, true); joint.jointEdgeB.other.joints.removeValue(joint.jointEdgeA, true); jniDestroyJoint(addr, joint.addr); }
/** * @return finished attached joint using GDXJoint data */ protected Joint attach(World world, JointDef def){ Body[] bodies = getBodyAB(world); if(bodies[0] == null || bodies[1] == null){ Log.error("GDXJoint.attach", "Body null! bodyA:" + this.bodyA + " bodyB:" + this.bodyB); return null; } def.bodyA = bodies[0]; def.bodyB = bodies[1]; def.type = jointType; def.collideConnected = collideConnected; Joint joint = world.createJoint(def); Log.log("GDXJoint.attach", "Successfully created joint " + toString()); joint.setUserData(name); return joint; }