/// <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); }
/// <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); }
/// <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); }
//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); }
public static FSFixedMouseJoint CreateFixedMouseJoint(FSWorld world, FSBody body, FVector2 target) { FSFixedMouseJoint joint = new FSFixedMouseJoint(body, target); world.AddJoint(joint); return(joint); }
/// <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); }
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); }
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); }
//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); }
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); }
/// <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); }
/// <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); }
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); }