当前位置: 首页>>代码示例>>C#>>正文


C# World.AddJoint方法代码示例

本文整理汇总了C#中FarseerPhysics.Dynamics.World.AddJoint方法的典型用法代码示例。如果您正苦于以下问题:C# World.AddJoint方法的具体用法?C# World.AddJoint怎么用?C# World.AddJoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FarseerPhysics.Dynamics.World的用法示例。


在下文中一共展示了World.AddJoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AttachBodiesWithRevoluteJoint

        /// <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<RevoluteJoint> AttachBodiesWithRevoluteJoint(World world, List<Body> bodies,
                                                                        Vector2 localAnchorA,
                                                                        Vector2 localAnchorB, bool connectFirstAndLast,
                                                                        bool collideConnected)
        {
            List<RevoluteJoint> joints = new List<RevoluteJoint>(bodies.Count + 1);

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

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

            return joints;
        }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:35,代码来源:PathManager.cs

示例2: CreateExtraJoints

        protected override void CreateExtraJoints(World world)
        {
            rightHandSpring = new FixedMouseJoint(_lowerRightArm, _lowerRightArm.Position);
            rightHandSpring.MaxForce = 1000.0f * _lowerRightArm.Mass;
            world.AddJoint(rightHandSpring);

            leftHandSpring = new FixedMouseJoint(_lowerLeftArm, _lowerLeftArm.Position);
            leftHandSpring.MaxForce = 1000.0f * _lowerLeftArm.Mass;
            world.AddJoint(leftHandSpring);
        }
开发者ID:guozanhua,项目名称:KinectRagdoll,代码行数:10,代码来源:RagdollAttractor.cs

示例3: CreateFixedDistanceJoint

 public static FixedDistanceJoint CreateFixedDistanceJoint(World world, Body body, Vector2 localAnchor,
                                                           Vector2 worldAnchor)
 {
     FixedDistanceJoint distanceJoint = new FixedDistanceJoint(body, localAnchor, worldAnchor);
     world.AddJoint(distanceJoint);
     return distanceJoint;
 }
开发者ID:kyallbarrows,项目名称:Cinch_4-3,代码行数:7,代码来源:JointFactory.cs

示例4: CreateFixedAngleJoint

        /// <summary>
        /// Creates a fixed angle joint.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="body">The body.</param>
        /// <returns></returns>
        public static FixedAngleJoint CreateFixedAngleJoint(World world, Body body)
        {
            FixedAngleJoint angleJoint = new FixedAngleJoint(body);
            world.AddJoint(angleJoint);

            return angleJoint;
        }
开发者ID:kyallbarrows,项目名称:Cinch_4-3,代码行数:13,代码来源:JointFactory.cs

示例5: CreateDistanceJoint

 public static DistanceJoint CreateDistanceJoint(World world, Body bodyA, Body bodyB, Vector2 anchorA,
                                                 Vector2 anchorB)
 {
     DistanceJoint distanceJoint = new DistanceJoint(bodyA, bodyB, anchorA, anchorB);
     world.AddJoint(distanceJoint);
     return distanceJoint;
 }
开发者ID:kyallbarrows,项目名称:Cinch_4-3,代码行数:7,代码来源:JointFactory.cs

示例6: CreateAngleJoint

        /// <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 AngleJoint CreateAngleJoint(World world, Body bodyA, Body bodyB)
        {
            AngleJoint angleJoint = new AngleJoint(bodyA, bodyB);
            world.AddJoint(angleJoint);

            return angleJoint;
        }
开发者ID:kyallbarrows,项目名称:Cinch_4-3,代码行数:14,代码来源:JointFactory.cs

示例7: CreatePulleyJoint

        public static PulleyJoint CreatePulleyJoint(World world, Body bodyA, Body bodyB, Vector2 anchorA, Vector2 anchorB,
			Vector2 worldAnchorA, Vector2 worldAnchorB, float ratio, bool useWorldCoordinates = false)
        {
            PulleyJoint pulleyJoint = new PulleyJoint(bodyA, bodyB, anchorA, anchorB, worldAnchorA, worldAnchorB, ratio, useWorldCoordinates);
            world.AddJoint(pulleyJoint);
            return pulleyJoint;
        }
开发者ID:Daramkun,项目名称:Misty,代码行数:7,代码来源:JointFactory.cs

示例8: CreateFrictionJoint

 public static FrictionJoint CreateFrictionJoint(World world, Body bodyA, Body bodyB, Vector2 anchorA,
                                                 Vector2 anchorB)
 {
     FrictionJoint frictionJoint = new FrictionJoint(bodyA, bodyB, anchorA, anchorB);
     world.AddJoint(frictionJoint);
     return frictionJoint;
 }
开发者ID:hilts-vaughan,项目名称:Farseer-Physics,代码行数:7,代码来源:JointFactory.cs

示例9: Turret

        public Turret(Vector2 farseerLoc, World w, RagdollManager r, Fixture f)
        {
            

            DebugMaterial gray = new DebugMaterial(MaterialType.Blank)
            {
                Color = Color.DarkGray
            };

            body = new Body(w);
            pivot = FixtureFactory.AttachCircle(.9f, 1, body, gray);
            FixtureFactory.AttachRectangle(barrelLength, .5f, 1, new Vector2(barrelLength / 2, 0), body, gray);
            body.Position = farseerLoc;
            body.BodyType = BodyType.Dynamic;
            //b.CollidesWith = Category.None;

            if (f == null)
            {

                motor = JointFactory.CreateFixedRevoluteJoint(w, body, Vector2.Zero, farseerLoc);
            }
            else
            {
                motor = new RevoluteJoint(body, f.Body, Vector2.Zero, f.Body.GetLocalPoint(farseerLoc));
                w.AddJoint(motor);
            }

            motor.MotorEnabled = true;
            motor.MaxMotorTorque = 5000;

            Init(w, r);
        }
开发者ID:guozanhua,项目名称:KinectRagdoll,代码行数:32,代码来源:Turret.cs

示例10: CreateRevoluteJoint

 /// <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="anchorB"></param>
 /// <returns></returns>
 public static RevoluteJoint CreateRevoluteJoint(World world, Body bodyA, Body bodyB, Vector2 anchorB)
 {
     Vector2 localanchorA = bodyA.GetLocalPoint(bodyB.GetWorldPoint(anchorB));
     RevoluteJoint joint = new RevoluteJoint(bodyA, bodyB, localanchorA, anchorB);
     world.AddJoint(joint);
     return joint;
 }
开发者ID:Alexz18z35z,项目名称:Gibbo2D,代码行数:15,代码来源:JointFactory.cs

示例11: CreateFixedPrismaticJoint

 public static FixedPrismaticJoint CreateFixedPrismaticJoint(World world, Body body, Vector2 worldAnchor,
                                                             Vector2 axis)
 {
     FixedPrismaticJoint joint = new FixedPrismaticJoint(body, worldAnchor, axis);
     world.AddJoint(joint);
     return joint;
 }
开发者ID:kyallbarrows,项目名称:Cinch_4-3,代码行数:7,代码来源:JointFactory.cs

示例12: CreateFixedRevoluteJoint

 /// <summary>
 /// Creates the fixed revolute joint.
 /// </summary>
 /// <param name="world">The world.</param>
 /// <param name="body">The body.</param>
 /// <param name="bodyAnchor">The body anchor.</param>
 /// <param name="worldAnchor">The world anchor.</param>
 /// <returns></returns>
 public static FixedRevoluteJoint CreateFixedRevoluteJoint(World world, Body body, Vector2 bodyAnchor,
                                                           Vector2 worldAnchor)
 {
     FixedRevoluteJoint fixedRevoluteJoint = new FixedRevoluteJoint(body, bodyAnchor, worldAnchor);
     world.AddJoint(fixedRevoluteJoint);
     return fixedRevoluteJoint;
 }
开发者ID:HaKDMoDz,项目名称:Zazumo,代码行数:15,代码来源:JointFactory.cs

示例13: AttachBodiesWithSliderJoint

        /// <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 void AttachBodiesWithSliderJoint(World world, List<Body> bodies, Vector2 localAnchorA,
                                                         Vector2 localAnchorB, bool connectFirstAndLast,
                                                         bool collideConnected, float minLength, float maxLength)
        {
            for (int i = 1; i < bodies.Count; i++)
            {
                SliderJoint joint = new SliderJoint(bodies[i], bodies[i - 1], localAnchorA, localAnchorB, minLength, maxLength);
                joint.CollideConnected = collideConnected;
                world.AddJoint(joint);
            }

            if (connectFirstAndLast)
            {
                SliderJoint lastjoint = new SliderJoint(bodies[0], bodies[bodies.Count - 1], localAnchorA, localAnchorB, minLength, maxLength);
                lastjoint.CollideConnected = collideConnected;
                world.AddJoint(lastjoint);
            }
        }
开发者ID:HaKDMoDz,项目名称:Lunar-Development-Kit,代码行数:27,代码来源:PathManager.cs

示例14: LoadContent

        public override void LoadContent(ContentManager content, World physics)
        {
            base.LoadContent(content, physics);

            this.physics.Position = ConvertUnits.ToSimUnits(50, 50);
            this.physics.CollisionCategories = Category.Cat1;
            this.physics.CollidesWith = Category.Cat1;

            fixture = new FixedMouseJoint(this.physics, ConvertUnits.ToSimUnits(new Vector2(50)));
            fixture.MaxForce = float.MaxValue;

            physics.AddJoint(fixture);
        }
开发者ID:rantingmong,项目名称:Diseases-game,代码行数:13,代码来源:DGPlayer.cs

示例15: Update

 public void Update(GameTime gameTime, CameraOperator cameraOperator, World world)
 {
     _sprite.Body.Center = Input.Mouse.Position;
     if (_mouseJoint != null)
     {
         if (Input.Mouse.IsButtonDown(Input.Mouse.MouseButton.Left))
         {
             _mouseJoint.WorldAnchorB = cameraOperator.Camera.PositionOnWorld(Input.Mouse.Position);
         }
         else
         {
             world.RemoveJoint(_mouseJoint);
             _mouseJoint = null;
         }
     }
     else
     {
         Vector2 cursorWorldPosition = cameraOperator.Camera.PositionOnWorld(Input.Mouse.Position);
         if (Input.Mouse.IsButtonClicked(Input.Mouse.MouseButton.Left))
         {
             Fixture fixture;
             float radiusMeters = _sprite.Body.Projection.BoundingBox.Dimensions.X.ToMeters();
             if ((fixture =
                 world.TestPoint(cursorWorldPosition - new Vector2(radiusMeters))) != null ||
                 (fixture =
                     world.TestPoint(cursorWorldPosition + new Vector2(radiusMeters))) != null ||
                 (fixture =
                     world.TestPoint(cursorWorldPosition + new Vector2(radiusMeters, -radiusMeters))) != null ||
                 (fixture =
                     world.TestPoint(cursorWorldPosition - new Vector2(radiusMeters, -radiusMeters))) != null)
             {
                 if (fixture.UserData is Coin)
                 {
                     _mouseJoint = new FixedMouseJoint(fixture.Body, cursorWorldPosition)
                     {
                         MaxForce = 200*fixture.Body.Mass
                     };
                     world.AddJoint(_mouseJoint);
                 }
             }
         }
     }
 }
开发者ID:victorMoneratto,项目名称:infinite-island,代码行数:43,代码来源:Cursor.cs


注:本文中的FarseerPhysics.Dynamics.World.AddJoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。