Example #1
0
        /// <summary>
        /// Attaches the bodies with revolute joints.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="bodies">The bodies.</param>
        /// <param name="localAnchorA">The local anchor A.</param>
        /// <param name="localAnchorB">The local anchor B.</param>
        /// <param name="connectFirstAndLast">if set to <c>true</c> [connect first and last].</param>
        /// <param name="collideConnected">if set to <c>true</c> [collide connected].</param>
        public static List<FSRevoluteJoint> AttachBodiesWithRevoluteJoint(FSWorld world, List<FSBody> bodies,
                                                                        FVector2 localAnchorA,
                                                                        FVector2 localAnchorB, bool connectFirstAndLast,
                                                                        bool collideConnected)
        {
            List<FSRevoluteJoint> joints = new List<FSRevoluteJoint>(bodies.Count + 1);

            for (int i = 1; i < bodies.Count; i++)
            {
                FSRevoluteJoint joint = new FSRevoluteJoint(bodies[i], bodies[i - 1], localAnchorA, localAnchorB);
                joint.CollideConnected = collideConnected;
                world.AddJoint(joint);
                joints.Add(joint);
            }

            if (connectFirstAndLast)
            {
                FSRevoluteJoint lastjoint = new FSRevoluteJoint(bodies[0], bodies[bodies.Count - 1], localAnchorA,
                                                            localAnchorB);
                lastjoint.CollideConnected = collideConnected;
                world.AddJoint(lastjoint);
                joints.Add(lastjoint);
            }

            return joints;
        }
Example #2
0
 public static FSFrictionJoint CreateFrictionJoint(FSWorld world, FSBody bodyA, FSBody bodyB, FVector2 anchorA,
                                                 FVector2 anchorB)
 {
     FSFrictionJoint frictionJoint = new FSFrictionJoint(bodyA, bodyB, anchorA, anchorB);
     world.AddJoint(frictionJoint);
     return frictionJoint;
 }
Example #3
0
        /// <summary>
        /// Creates a fixed angle joint.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="body">The body.</param>
        /// <returns></returns>
        public static FSFixedAngleJoint CreateFixedAngleJoint(FSWorld world, FSBody body)
        {
            FSFixedAngleJoint angleJoint = new FSFixedAngleJoint(body);
            world.AddJoint(angleJoint);

            return angleJoint;
        }
Example #4
0
 public static FSDistanceJoint CreateDistanceJoint(FSWorld world, FSBody bodyA, FSBody bodyB, FVector2 anchorA,
                                                 FVector2 anchorB)
 {
     FSDistanceJoint distanceJoint = new FSDistanceJoint(bodyA, bodyB, anchorA, anchorB);
     world.AddJoint(distanceJoint);
     return distanceJoint;
 }
Example #5
0
        /// <summary>
        /// Creates an angle joint.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="bodyA">The first body.</param>
        /// <param name="bodyB">The second body.</param>
        /// <returns></returns>
        public static FSAngleJoint CreateAngleJoint(FSWorld world, FSBody bodyA, FSBody bodyB)
        {
            FSAngleJoint angleJoint = new FSAngleJoint(bodyA, bodyB);
            world.AddJoint(angleJoint);

            return angleJoint;
        }
Example #6
0
 /// <summary>
 /// Creates a prismatic joint and adds it to the world
 /// </summary>
 /// <param name="world"></param>
 /// <param name="bodyA"></param>
 /// <param name="bodyB"></param>
 /// <param name="localanchorB"></param>
 /// <param name="axis"></param>
 /// <returns></returns>
 public static FSPrismaticJoint CreatePrismaticJoint(FSWorld world, FSBody bodyA, FSBody bodyB, FVector2 localanchorB,
                                                   FVector2 axis)
 {
     FSPrismaticJoint joint = CreatePrismaticJoint(bodyA, bodyB, localanchorB, axis);
     world.AddJoint(joint);
     return joint;
 }
Example #7
0
 public static FSGearJoint CreateGearJoint(FSWorld world, FarseerJoint jointA, FarseerJoint jointB, float ratio)
 {
     FSGearJoint gearJoint = new FSGearJoint(jointA, jointB, ratio);
     world.AddJoint(gearJoint);
     return gearJoint;
 }
Example #8
0
 public static FSFixedMouseJoint CreateFixedMouseJoint(FSWorld world, FSBody body, FVector2 target)
 {
     FSFixedMouseJoint joint = new FSFixedMouseJoint(body, target);
     world.AddJoint(joint);
     return joint;
 }
Example #9
0
 public static FSWeldJoint CreateWeldJoint(FSWorld world, FSBody bodyA, FSBody bodyB, FVector2 localAnchorA,
                                         FVector2 localAnchorB)
 {
     FSWeldJoint weldJoint = new FSWeldJoint(bodyA, bodyB, localAnchorA, localAnchorB);
     world.AddJoint(weldJoint);
     return weldJoint;
 }
Example #10
0
 /// <summary>
 /// Creates a weld joint and adds it to the world
 /// </summary>
 /// <param name="world"></param>
 /// <param name="bodyA"></param>
 /// <param name="bodyB"></param>
 /// <param name="worldAnchor">World space coordinates of weld joint</param>
 /// <returns></returns>
 public static FSWeldJoint CreateWeldJoint(FSWorld world, FSBody bodyA, FSBody bodyB, FVector2 worldAnchor)
 {
     FSWeldJoint joint = CreateWeldJoint(bodyA, bodyB, worldAnchor);
     world.AddJoint(joint);
     return joint;
 }
Example #11
0
 public static FSSliderJoint CreateSliderJoint(FSWorld world, FSBody bodyA, FSBody bodyB, FVector2 anchorA,
                                             FVector2 anchorB, float minLength, float maxLength)
 {
     FSSliderJoint sliderJoint = new FSSliderJoint(bodyA, bodyB, anchorA, anchorB, minLength, maxLength);
     world.AddJoint(sliderJoint);
     return sliderJoint;
 }
Example #12
0
 /// <summary>
 /// Creates a revolute joint and adds it to the world
 /// </summary>
 /// <param name="world"></param>
 /// <param name="bodyA"></param>
 /// <param name="bodyB"></param>
 /// <param name="anchor"></param>
 /// <returns></returns>
 public static FSRevoluteJoint CreateRevoluteJoint(FSWorld world, FSBody bodyA, FSBody bodyB, FVector2 anchor)
 {
     FSRevoluteJoint joint = CreateRevoluteJoint(bodyA, bodyB, anchor);
     world.AddJoint(joint);
     return joint;
 }
Example #13
0
 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;
 }