本文整理汇总了C#中FarseerPhysics.Dynamics.Joints.RevoluteJoint.SetLimits方法的典型用法代码示例。如果您正苦于以下问题:C# RevoluteJoint.SetLimits方法的具体用法?C# RevoluteJoint.SetLimits怎么用?C# RevoluteJoint.SetLimits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FarseerPhysics.Dynamics.Joints.RevoluteJoint
的用法示例。
在下文中一共展示了RevoluteJoint.SetLimits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Ragdoll
//.........这里部分代码省略.........
_lowerRightLeg = BodyFactory.CreateCapsule(world, 1f, 0.5f, LegDensity);
_lowerRightLeg.BodyType = BodyType.Dynamic;
_lowerRightLeg.AngularDamping = LimbAngularDamping;
_lowerRightLeg.Mass = 2f;
_lowerRightLeg.Position = position + new Vector2(0.6f, 8f);
_upperRightLeg = BodyFactory.CreateCapsule(world, 1f, 0.5f, LegDensity);
_upperRightLeg.BodyType = BodyType.Dynamic;
_upperRightLeg.AngularDamping = LimbAngularDamping;
_upperRightLeg.Mass = 2f;
_upperRightLeg.Position = position + new Vector2(0.6f, 6f);
// head -> upper body
DistanceJoint jointHeadBody = new DistanceJoint(_head, _upperBody, new Vector2(0f, 1f), new Vector2(-0.75f, 0f));
jointHeadBody.CollideConnected = true;
jointHeadBody.DampingRatio = DampingRatio;
jointHeadBody.Frequency = Frequency;
jointHeadBody.Length = 0.025f;
world.AddJoint(jointHeadBody);
// lowerLeftArm -> upperLeftArm
DistanceJoint jointLeftArm = new DistanceJoint(_lowerLeftArm, _upperLeftArm, new Vector2(0f, -1f), new Vector2(0f, 1f));
jointLeftArm.CollideConnected = true;
jointLeftArm.DampingRatio = DampingRatio;
jointLeftArm.Frequency = Frequency;
jointLeftArm.Length = 0.02f;
world.AddJoint(jointLeftArm);
// upperLeftArm -> upper body
DistanceJoint jointLeftArmBody = new DistanceJoint(_upperLeftArm, _upperBody, new Vector2(0f, -1f), new Vector2(-0.15f, 1f));
jointLeftArmBody.DampingRatio = DampingRatio;
jointLeftArmBody.Frequency = Frequency;
jointLeftArmBody.Length = 0.02f;
world.AddJoint(jointLeftArmBody);
// lowerRightArm -> upperRightArm
DistanceJoint jointRightArm = new DistanceJoint(_lowerRightArm, _upperRightArm, new Vector2(0f, -1f), new Vector2(0f, 1f));
jointRightArm.CollideConnected = true;
jointRightArm.DampingRatio = DampingRatio;
jointRightArm.Frequency = Frequency;
jointRightArm.Length = 0.02f;
world.AddJoint(jointRightArm);
// upperRightArm -> upper body
DistanceJoint jointRightArmBody = new DistanceJoint(_upperRightArm, _upperBody, new Vector2(0f, -1f), new Vector2(-0.15f, -1f));
jointRightArmBody.DampingRatio = DampingRatio;
jointRightArmBody.Frequency = 25;
jointRightArmBody.Length = 0.02f;
world.AddJoint(jointRightArmBody);
// lowerLeftLeg -> upperLeftLeg
DistanceJoint jointLeftLeg = new DistanceJoint(_lowerLeftLeg, _upperLeftLeg, new Vector2(0f, -1.1f), new Vector2(0f, 1f));
jointLeftLeg.CollideConnected = true;
jointLeftLeg.DampingRatio = DampingRatio;
jointLeftLeg.Frequency = Frequency;
jointLeftLeg.Length = 0.05f;
world.AddJoint(jointLeftLeg);
// upperLeftLeg -> lower body
DistanceJoint jointLeftLegBody = new DistanceJoint(_upperLeftLeg, _lowerBody, new Vector2(0f, -1.1f), new Vector2(0.7f, 0.8f));
jointLeftLegBody.CollideConnected = true;
jointLeftLegBody.DampingRatio = DampingRatio;
jointLeftLegBody.Frequency = Frequency;
jointLeftLegBody.Length = 0.02f;
world.AddJoint(jointLeftLegBody);
// lowerRightleg -> upperRightleg
DistanceJoint jointRightLeg = new DistanceJoint(_lowerRightLeg, _upperRightLeg, new Vector2(0f, -1.1f), new Vector2(0f, 1f));
jointRightLeg.CollideConnected = true;
jointRightLeg.DampingRatio = DampingRatio;
jointRightLeg.Frequency = Frequency;
jointRightLeg.Length = 0.05f;
world.AddJoint(jointRightLeg);
// upperRightleg -> lower body
DistanceJoint jointRightLegBody = new DistanceJoint(_upperRightLeg, _lowerBody, new Vector2(0f, -1.1f), new Vector2(0.7f, -0.8f));
jointRightLegBody.CollideConnected = true;
jointRightLegBody.DampingRatio = DampingRatio;
jointRightLegBody.Frequency = Frequency;
jointRightLegBody.Length = 0.02f;
world.AddJoint(jointRightLegBody);
// upper body -> middle body
RevoluteJoint jointUpperTorso = new RevoluteJoint(_upperBody, _middleBody, _upperBody.Position + new Vector2(0f, 0.625f), true);
jointUpperTorso.LimitEnabled = true;
jointUpperTorso.SetLimits(-MathHelper.Pi / 16f, MathHelper.Pi / 16f);
world.AddJoint(jointUpperTorso);
// middle body -> lower body
RevoluteJoint jointLowerTorso = new RevoluteJoint(_middleBody, _lowerBody, _middleBody.Position + new Vector2(0f, 0.625f), true);
jointLowerTorso.LimitEnabled = true;
jointLowerTorso.SetLimits(-MathHelper.Pi / 8f, MathHelper.Pi / 8f);
world.AddJoint(jointLowerTorso);
// GFX
_face = new Sprite(ContentWrapper.CircleTexture(0.75f, "Square", ContentWrapper.Gold, ContentWrapper.Orange, ContentWrapper.Grey, 1f));
_torso = new Sprite(ContentWrapper.PolygonTexture(PolygonTools.CreateRoundedRectangle(1.5f, 2f, 0.75f, 0.75f, 2), "Stripe", ContentWrapper.Gold, ContentWrapper.Orange, ContentWrapper.Black, 2.0f));
_upperLimb = new Sprite(ContentWrapper.PolygonTexture(PolygonTools.CreateCapsule(1.9f, 0.45f, 16), "Square", ContentWrapper.Gold, ContentWrapper.Orange, ContentWrapper.Black, 1f));
_lowerLimb = new Sprite(ContentWrapper.PolygonTexture(PolygonTools.CreateCapsule(2f, 0.5f, 16), "Square", ContentWrapper.Gold, ContentWrapper.Orange, ContentWrapper.Black, 1f));
}