public static FSPulleyJoint CreatePulleyJoint(FSWorld world, FSBody bodyA, FSBody bodyB, FVector2 groundAnchorA, FVector2 groundAnchorB, FVector2 anchorA, FVector2 anchorB, float ratio) { FSPulleyJoint pulleyJoint = new FSPulleyJoint(bodyA, bodyB, groundAnchorA, groundAnchorB, anchorA, anchorB, ratio); world.AddJoint(pulleyJoint); return(pulleyJoint); }
public override void InitJoint() { base.InitJoint(); Vector3 p0 = BodyA.transform.TransformPoint(new Vector3(LocalAnchorA.x, LocalAnchorA.y, -5f)); Vector3 p1 = BodyB.transform.TransformPoint(new Vector3(LocalAnchorB.x, LocalAnchorB.y, -5f)); joint = JointFactory.CreatePulleyJoint(FSWorldComponent.PhysicsWorld, BodyA.PhysicsBody, BodyB.PhysicsBody, FSHelper.Vector3ToFVector2(GroundAnchorA.position), FSHelper.Vector3ToFVector2(GroundAnchorB.position), BodyA.PhysicsBody.GetLocalPoint(FSHelper.Vector3ToFVector2(p0)), BodyB.PhysicsBody.GetLocalPoint(FSHelper.Vector3ToFVector2(p1)), ForceRatio); joint.CollideConnected = CollideConnected; }
private void DrawJoint(FarseerJoint joint) { if (!joint.Enabled) { return; } FSBody b1 = joint.BodyA; FSBody b2 = joint.BodyB; Transform xf1, xf2; b1.GetTransform(out xf1); FVector2 x2 = FVector2.Zero; // WIP David if (!joint.IsFixedType()) { b2.GetTransform(out xf2); x2 = xf2.p; } FVector2 p1 = joint.WorldAnchorA; FVector2 p2 = joint.WorldAnchorB; FVector2 x1 = xf1.p; Color color = new Color(0.5f, 0.8f, 0.8f); switch (joint.JointType) { case JointType.Distance: DrawSegment(p1, p2, color); break; case JointType.Pulley: FSPulleyJoint pulley = (FSPulleyJoint)joint; FVector2 s1 = pulley.GroundAnchorA; FVector2 s2 = pulley.GroundAnchorB; DrawSegment(s1, p1, color); DrawSegment(s2, p2, color); DrawSegment(s1, s2, color); break; case JointType.FixedMouse: DrawPoint(p1, 0.5f, new Color(0.0f, 1.0f, 0.0f)); DrawSegment(p1, p2, new Color(0.8f, 0.8f, 0.8f)); break; case JointType.Revolute: //DrawSegment(x2, p1, color); DrawSegment(p2, p1, color); DrawSolidCircle(p2, 0.1f, FVector2.Zero, Color.red); DrawSolidCircle(p1, 0.1f, FVector2.Zero, Color.blue); break; case JointType.FixedAngle: //Should not draw anything. break; case JointType.FixedRevolute: DrawSegment(x1, p1, color); DrawSolidCircle(p1, 0.1f, FVector2.Zero, new Color(1f, 0.5f, 1f)); break; case JointType.FixedLine: DrawSegment(x1, p1, color); DrawSegment(p1, p2, color); break; case JointType.FixedDistance: DrawSegment(x1, p1, color); DrawSegment(p1, p2, color); break; case JointType.FixedPrismatic: DrawSegment(x1, p1, color); DrawSegment(p1, p2, color); break; case JointType.Gear: DrawSegment(x1, x2, color); break; //case JointType.Weld: // break; default: DrawSegment(x1, p1, color); DrawSegment(p1, p2, color); DrawSegment(x2, p2, color); break; } }