示例#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>
        /// <param name="minLength">Minimum length of the slider joint.</param>
        /// <param name="maxLength">Maximum length of the slider joint.</param>
        /// <returns></returns>
        public static List <FSSliderJoint> AttachBodiesWithSliderJoint(FSWorld world, List <FSBody> bodies, FVector2 localAnchorA,
                                                                       FVector2 localAnchorB, bool connectFirstAndLast,
                                                                       bool collideConnected, float minLength,
                                                                       float maxLength)
        {
            List <FSSliderJoint> joints = new List <FSSliderJoint>(bodies.Count + 1);

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

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

            return(joints);
        }
示例#2
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);
        }
示例#3
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);
        }
示例#4
0
        //public static FixedFrictionJoint CreateFixedFrictionJoint(World world, Body body, Vector2 bodyAnchor)
        //{
        //    FixedFrictionJoint frictionJoint = new FixedFrictionJoint(body, bodyAnchor);
        //    world.AddJoint(frictionJoint);
        //    return frictionJoint;
        //}

        #endregion

        #region Gear Joint

        public static FSGearJoint CreateGearJoint(FSWorld world, FarseerJoint jointA, FarseerJoint jointB, float ratio)
        {
            FSGearJoint gearJoint = new FSGearJoint(jointA, jointB, ratio);

            world.AddJoint(gearJoint);
            return(gearJoint);
        }
示例#5
0
        public static FSFixedMouseJoint CreateFixedMouseJoint(FSWorld world, FSBody body, FVector2 target)
        {
            FSFixedMouseJoint joint = new FSFixedMouseJoint(body, target);

            world.AddJoint(joint);
            return(joint);
        }
示例#6
0
        /// <summary>
        /// Creates a Wheel 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 FSWheelJoint CreateWheelJoint(FSWorld world, FSBody bodyA, FSBody bodyB, FVector2 localanchorB, FVector2 axis)
        {
            FSWheelJoint joint = CreateWheelJoint(bodyA, bodyB, localanchorB, axis);

            world.AddJoint(joint);
            return(joint);
        }
示例#7
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);
        }
示例#8
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);
        }
示例#9
0
        //public static FixedDistanceJoint CreateFixedDistanceJoint(World world, Body body, Vector2 localAnchor,
        //                                                          Vector2 worldAnchor)
        //{
        //    FixedDistanceJoint distanceJoint = new FixedDistanceJoint(body, localAnchor, worldAnchor);
        //    world.AddJoint(distanceJoint);
        //    return distanceJoint;
        //}

        #endregion

        #region Friction Joint

        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);
        }
示例#10
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);
        }
示例#11
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);
        }
示例#12
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);
        }
示例#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);
        }