Example #1
0
 public WheelJoint(Body bodyA, Body bodyB, TSVector2 anchor, TSVector2 axis, bool useWorldCoordinates = false) : base(bodyA, bodyB)
 {
     base.JointType = JointType.Wheel;
     if (useWorldCoordinates)
     {
         this.LocalAnchorA = bodyA.GetLocalPoint(anchor);
         this.LocalAnchorB = bodyB.GetLocalPoint(anchor);
     }
     else
     {
         this.LocalAnchorA = bodyA.GetLocalPoint(bodyB.GetWorldPoint(anchor));
         this.LocalAnchorB = anchor;
     }
     this.Axis = axis;
 }
Example #2
0
        public static RevoluteJoint CreateRevoluteJoint(World world, Body bodyA, Body bodyB, TSVector2 anchor)
        {
            TSVector2     localPoint    = bodyA.GetLocalPoint(bodyB.GetWorldPoint(anchor));
            RevoluteJoint revoluteJoint = new RevoluteJoint(bodyA, bodyB, localPoint, anchor, false);

            world.AddJoint(revoluteJoint);
            return(revoluteJoint);
        }
Example #3
0
 public RopeJoint(Body bodyA, Body bodyB, TSVector2 anchorA, TSVector2 anchorB, bool useWorldCoordinates = false) : base(bodyA, bodyB)
 {
     base.JointType = JointType.Rope;
     if (useWorldCoordinates)
     {
         this.LocalAnchorA = bodyA.GetLocalPoint(anchorA);
         this.LocalAnchorB = bodyB.GetLocalPoint(anchorB);
     }
     else
     {
         this.LocalAnchorA = anchorA;
         this.LocalAnchorB = anchorB;
     }
     this.MaxLength = (this.WorldAnchorB - this.WorldAnchorA).magnitude;
 }
Example #4
0
 public WeldJoint(Body bodyA, Body bodyB, TSVector2 anchorA, TSVector2 anchorB, bool useWorldCoordinates = false) : base(bodyA, bodyB)
 {
     base.JointType = JointType.Weld;
     if (useWorldCoordinates)
     {
         this.LocalAnchorA = bodyA.GetLocalPoint(anchorA);
         this.LocalAnchorB = bodyB.GetLocalPoint(anchorB);
     }
     else
     {
         this.LocalAnchorA = anchorA;
         this.LocalAnchorB = anchorB;
     }
     this.ReferenceAngle = base.BodyB.Rotation - base.BodyA.Rotation;
 }
Example #5
0
 public DistanceJoint(Body bodyA, Body bodyB, TSVector2 anchorA, TSVector2 anchorB, bool useWorldCoordinates = false) : base(bodyA, bodyB)
 {
     base.JointType = JointType.Distance;
     if (useWorldCoordinates)
     {
         this.LocalAnchorA = bodyA.GetLocalPoint(ref anchorA);
         this.LocalAnchorB = bodyB.GetLocalPoint(ref anchorB);
         this.Length       = (anchorB - anchorA).magnitude;
     }
     else
     {
         this.LocalAnchorA = anchorA;
         this.LocalAnchorB = anchorB;
         this.Length       = (base.BodyB.GetWorldPoint(ref anchorB) - base.BodyA.GetWorldPoint(ref anchorA)).magnitude;
     }
 }