/// <summary> /// Creates a prsimatic joint /// </summary> /// <param name="bodyA"></param> /// <param name="bodyB"></param> /// <param name="localanchorB"></param> /// <param name="axis"></param> /// <returns></returns> public static FSPrismaticJoint CreatePrismaticJoint(FSBody bodyA, FSBody bodyB, FVector2 localanchorB, FVector2 axis) { FVector2 localanchorA = bodyA.GetLocalPoint(bodyB.GetWorldPoint(localanchorB)); FSPrismaticJoint joint = new FSPrismaticJoint(bodyA, bodyB, localanchorA, localanchorB, axis); return(joint); }
/// <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); }
public override void InitJoint() { base.InitJoint (); //Microsoft.Xna.Framework.FVector2 angleV = new Microsoft.Xna.Framework.FVector2(BodyB.PhysicsBody.Position.X - BodyA.PhysicsBody.Position.X, BodyB.PhysicsBody.Position.Y - BodyA.PhysicsBody.Position.Y); float ang = Mathf.Atan2(BodyB.PhysicsBody.Position.Y - BodyA.PhysicsBody.Position.Y, BodyB.PhysicsBody.Position.X - BodyA.PhysicsBody.Position.X); Microsoft.Xna.Framework.FVector2 angleV = new Microsoft.Xna.Framework.FVector2(Mathf.Cos(ang), Mathf.Sin(ang)); //angleV.Normalize(); joint = FarseerPhysics.Factories.JointFactory.CreatePrismaticJoint(FSWorldComponent.PhysicsWorld, BodyA.PhysicsBody, BodyB.PhysicsBody, Microsoft.Xna.Framework.FVector2.Zero, angleV); joint.CollideConnected = CollideConnected; //joint.Frequency = Frequency; //joint.DampingRatio = 0.5f; d }
public override void InitJoint() { base.InitJoint(); //Microsoft.Xna.Framework.FVector2 angleV = new Microsoft.Xna.Framework.FVector2(BodyB.PhysicsBody.Position.X - BodyA.PhysicsBody.Position.X, BodyB.PhysicsBody.Position.Y - BodyA.PhysicsBody.Position.Y); float ang = Mathf.Atan2(BodyB.PhysicsBody.Position.Y - BodyA.PhysicsBody.Position.Y, BodyB.PhysicsBody.Position.X - BodyA.PhysicsBody.Position.X); Microsoft.Xna.Framework.FVector2 angleV = new Microsoft.Xna.Framework.FVector2(Mathf.Cos(ang), Mathf.Sin(ang)); //angleV.Normalize(); joint = FarseerPhysics.Factories.JointFactory.CreatePrismaticJoint(FSWorldComponent.PhysicsWorld, BodyA.PhysicsBody, BodyB.PhysicsBody, Microsoft.Xna.Framework.FVector2.Zero, angleV); joint.CollideConnected = CollideConnected; //joint.Frequency = Frequency; //joint.DampingRatio = 0.5f; d }
/// <summary> /// Creates a prsimatic joint /// </summary> /// <param name="bodyA"></param> /// <param name="bodyB"></param> /// <param name="localanchorB"></param> /// <param name="axis"></param> /// <returns></returns> public static FSPrismaticJoint CreatePrismaticJoint(FSBody bodyA, FSBody bodyB, FVector2 localanchorB, FVector2 axis) { FVector2 localanchorA = bodyA.GetLocalPoint(bodyB.GetWorldPoint(localanchorB)); FSPrismaticJoint joint = new FSPrismaticJoint(bodyA, bodyB, localanchorA, localanchorB, axis); return joint; }