• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Joints.RevoluteJoint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



RevoluteJoint类属于FarseerPhysics.Dynamics.Joints命名空间,在下文中一共展示了RevoluteJoint类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: HumanoidBody

        public HumanoidBody(World world, Vector2 dimensions, object userData)
        {
            _torsoHeight = dimensions.Y - dimensions.X/2f;

            Torso = BodyFactory.CreateRectangle(
                world: world,
                width: dimensions.X,
                height: _torsoHeight,
                density: 1f,
                position: Vector2.UnitX*20,
                userData: userData);

            Torso.BodyType = BodyType.Dynamic;

            Wheel = BodyFactory.CreateCircle(
                world: world,
                radius: dimensions.X/2f,
                density: 1f,
                position: Torso.Position + new Vector2(0, _torsoHeight/2),
                userData: userData);

            Wheel.BodyType = BodyType.Dynamic;
            Wheel.Friction = float.MaxValue;
            Wheel.Restitution = float.MinValue;

            JointFactory.CreateFixedAngleJoint(world, Torso);

            Motor = JointFactory.CreateRevoluteJoint(world, Torso, Wheel, Vector2.Zero);
            Motor.MotorEnabled = true;
            Motor.MaxMotorTorque = 10;
        }
开发者ID:victorMoneratto,项目名称:infinite-island,代码行数:31,代码来源:HumanoidBody.cs


示例2: 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


示例3: 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


示例4: ChainTest

        private ChainTest()
        {
            //Ground
            Body ground = BodyFactory.CreateEdge(World, new Vector2(-40.0f, 0.0f), new Vector2(40.0f, 0.0f));

            {
                const float y = 25.0f;
                Body prevBody = ground;
                for (int i = 0; i < 30; ++i)
                {
                    Body body = BodyFactory.CreateRectangle(World, 1.2f, 0.25f, 20, new Vector2(0.5f + i, y));
                    body.BodyType = BodyType.Dynamic;
                    body.Friction = 0.2f;

                    Vector2 anchor = new Vector2(i, y);
                    RevoluteJoint joint = new RevoluteJoint(prevBody, body, anchor, true);

                    //The chain is breakable
                    joint.Breakpoint = 10000f;
                    World.AddJoint(joint);

                    prevBody = body;
                }
            }
        }
开发者ID:RCGame,项目名称:FarseerPhysics,代码行数:25,代码来源:ChainTest.cs


示例5: CreateRevoluteJoint

		public static RevoluteJoint CreateRevoluteJoint( World world, Body bodyA, Body bodyB, Vector2 anchor )
		{
			var localanchorA = bodyA.getLocalPoint( bodyB.getWorldPoint( anchor ) );
			var joint = new RevoluteJoint( bodyA, bodyB, localanchorA, anchor );
			world.addJoint( joint );
			return joint;
		}
开发者ID:prime31,项目名称:Nez,代码行数:7,代码来源:JointFactory.cs


示例6: CreatePlayerPhysicsObjects

        private void CreatePlayerPhysicsObjects(Vector2 gameWorldPosition)
        {
            MainFixture = FixtureFactory.CreateRectangle(Engine.Physics.World, 0.5f, 0.5f, 1);
            MainFixture.CollisionFilter.CollisionCategories = (Category)(Global.CollisionCategories.Player);
            Bodies.Add(MainFixture.Body);
            MainFixture.Body.Position = Engine.Physics.PositionToPhysicsWorld(gameWorldPosition);
            MainFixture.Body.BodyType = BodyType.Dynamic;
            MainFixture.Body.SleepingAllowed = false;

            WheelFixture = FixtureFactory.CreateCircle(Engine.Physics.World, 0.3f, 1.0f);
            WheelFixture.CollisionFilter.CollisionCategories = (Category)(Global.CollisionCategories.Player);
            Bodies.Add(WheelFixture.Body);
            WheelFixture.Body.Position = MainFixture.Body.Position + new Vector2(0.0f, 0.6f);
            WheelFixture.Body.BodyType = BodyType.Dynamic;

            WheelFixture.Body.SleepingAllowed = false;
            WheelFixture.Friction = 0.5f;

            playerFAJ = JointFactory.CreateFixedAngleJoint(Engine.Physics.World, MainFixture.Body);
            playerFAJ.BodyB = WheelFixture.Body;

            wheelMotorRevJoint = JointFactory.CreateRevoluteJoint(MainFixture.Body, WheelFixture.Body, Vector2.Zero);
            wheelMotorRevJoint.MaxMotorTorque = 10.0f;
            wheelMotorRevJoint.MotorEnabled = true;
            Engine.Physics.World.AddJoint(wheelMotorRevJoint);
        }
开发者ID:PhoenixWright,项目名称:NePlus,代码行数:26,代码来源:PlayerPhysicsComponent.cs


示例7: Tumbler

        private Tumbler()
        {
            var ground = BodyFactory.CreateBody(World);

            var body = BodyFactory.CreateBody(World);
            body.BodyType = BodyType.Dynamic;
            body.Position = new Vector2(0.0f, 10.0f);

            PolygonShape shape = new PolygonShape(5);
            shape.SetAsBox(0.5f, 10.0f, new Vector2(10.0f, 0.0f), 0.0f);
            body.CreateFixture(shape);

            shape.SetAsBox(0.5f, 10.0f, new Vector2(-10.0f, 0.0f), 0.0f);
            body.CreateFixture(shape);

            shape.SetAsBox(10.0f, 0.5f, new Vector2(0.0f, 10.0f), 0.0f);
            body.CreateFixture(shape);

            shape.SetAsBox(10.0f, 0.5f, new Vector2(0.0f, -10.0f), 0.0f);
            body.CreateFixture(shape);

            var jd = new RevoluteJoint(ground, body, new Vector2(0.0f, 10.0f), new Vector2(0.0f, 0.0f));
            jd.ReferenceAngle = 0.0f;
            jd.MotorSpeed = 0.05f * MathHelper.Pi;
            jd.MaxMotorTorque = 1e8f;
            jd.MotorEnabled = true;

            World.AddJoint(jd);
        }
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:29,代码来源:Tumbler.cs


示例8: RopeGrabComponent

 public RopeGrabComponent(int entityId, RopeComponent ropeComponent, RevoluteJoint joint, float progress)
 {
     _entityId = entityId;
     _ropeComponent = ropeComponent;
     _joint = joint;
     _progress = progress;
 }
开发者ID:klutch,项目名称:Loderpit,代码行数:7,代码来源:RopeGrabComponent.cs


示例9: RopeNode

 public RopeNode(Body body, RevoluteJoint joint, float halfLength)
 {
     _ropeNodeTextures = ropeNodeTextures;
     _body = body;
     _joint = joint;
     _halfLength = halfLength;
 }
开发者ID:klutch,项目名称:StasisEngine,代码行数:7,代码来源:RopeNode.cs


示例10: CompositePhysicsObject

 public CompositePhysicsObject(World world, PhysicsObject physObA, PhysicsObject physObB, Vector2 relativeJointPosition)
 {
     this.physObA = physObA;
     this.physObB = physObB;
     revJoint = JointFactory.CreateRevoluteJoint(world, physObA.fixture.Body, physObB.fixture.Body, ConvertUnits.ToSimUnits(relativeJointPosition));
     physObA.fixture.IgnoreCollisionWith(physObB.fixture);
     physObB.fixture.IgnoreCollisionWith(physObA.fixture);
 }
开发者ID:psykano,项目名称:STFU-xna,代码行数:8,代码来源:CompositePhysicsObject.cs


示例11: CharacterComponent

 public CharacterComponent(int entityId, Body body, Body feet, RevoluteJoint feetJoint, CharacterClass characterClass)
 {
     _entityId = entityId;
     _body = body;
     _feet = feet;
     _feetJoint = feetJoint;
     _characterClass = characterClass;
 }
开发者ID:klutch,项目名称:Loderpit,代码行数:8,代码来源:CharacterComponent.cs


示例12: RevoluteTest

        private RevoluteTest()
        {
            //Ground
            Body ground = BodyFactory.CreateEdge(World, new Vector2(-40.0f, 0.0f), new Vector2(40.0f, 0.0f));

            {
                Body bodyB = BodyFactory.CreateCircle(World, 0.5f, 5f, new Vector2(-10.0f, 20.0f));
                bodyB.BodyType = BodyType.Dynamic;

                const float w = 100.0f;
                bodyB.AngularVelocity = w;
                bodyB.LinearVelocity = new Vector2(-8.0f * w, 0.0f);

                _joint = new RevoluteJoint(ground, bodyB, new Vector2(-10.0f, 12.0f), true);
                _joint.MotorSpeed = 1.0f * Settings.Pi;
                _joint.MaxMotorTorque = 10000.0f;
                _joint.MotorEnabled = false;
                _joint.LowerLimit = -0.25f * Settings.Pi;
                _joint.UpperLimit = 0.5f * Settings.Pi;
                _joint.LimitEnabled = true;
                _joint.CollideConnected = true;

                World.AddJoint(_joint);
            }

            {
                Body ball = BodyFactory.CreateCircle(World, 3.0f, 5.0f, new Vector2(5.0f, 30.0f));
                ball.BodyType = BodyType.Dynamic;
                ball.CollisionCategories = Category.Cat1;

                Vertices polygonVertices = PolygonTools.CreateRectangle(10.0f, 0.2f, new Vector2(-10.0f, 0.0f), 0.0f);

                Body polygonBody = BodyFactory.CreatePolygon(World, polygonVertices, 2, new Vector2(20, 10));
                polygonBody.BodyType = BodyType.Dynamic;
                polygonBody.IsBullet = true;

                RevoluteJoint joint = new RevoluteJoint(ground, polygonBody, new Vector2(20, 10), true);
                joint.LowerLimit = -0.25f * Settings.Pi;
                joint.UpperLimit = 0.0f * Settings.Pi;
                joint.LimitEnabled = true;

                World.AddJoint(joint);
            }

            // Tests mass computation of a small object far from the origin
            {
                Vertices verts = new Vertices(3);
                verts.Add(new Vector2(17.63f, 36.31f));
                verts.Add(new Vector2(17.52f, 36.69f));
                verts.Add(new Vector2(17.19f, 36.36f));

                Body polyShape = BodyFactory.CreatePolygon(World, verts, 1);
                polyShape.BodyType = BodyType.Dynamic;
            }
        }
开发者ID:boris2,项目名称:mmogameproject2,代码行数:55,代码来源:RevoluteTest.cs


示例13: RevoluteTest

        private RevoluteTest()
        {
            //Ground
            var ground = BodyFactory.CreateEdge(World, new Vector2(-40.0f, 0.0f), new Vector2(40.0f, 0.0f));

            {
                //The big fixed wheel
                CircleShape shape = new CircleShape(5.0f, 5);

                Body body = BodyFactory.CreateBody(World);
                body.Position = new Vector2(-10.0f, 15.0f);
                body.BodyType = BodyType.Dynamic;

                body.CreateFixture(shape);

                _fixedJoint = new FixedRevoluteJoint(body, Vector2.Zero, body.Position);
                _fixedJoint.MotorSpeed = 0.25f * Settings.Pi;
                _fixedJoint.MaxMotorTorque = 5000.0f;
                _fixedJoint.MotorEnabled = true;
                World.AddJoint(_fixedJoint);

                // The small gear attached to the big one
                Body body1 = BodyFactory.CreateGear(World, 1.5f, 10, 0.1f, 1, 1);
                body1.Position = new Vector2(-10.0f, 12.0f);
                body1.BodyType = BodyType.Dynamic;

                _joint = new RevoluteJoint(body, body1, body.GetLocalPoint(body1.Position),
                                           Vector2.Zero);
                _joint.MotorSpeed = 1.0f * Settings.Pi;
                _joint.MaxMotorTorque = 5000.0f;
                _joint.MotorEnabled = true;
                _joint.CollideConnected = false;

                World.AddJoint(_joint);

                CircleShape circle_shape = new CircleShape(3.0f, 5);
                var circleBody = BodyFactory.CreateBody(World);
                circleBody.Position = new Vector2(5.0f, 30.0f);
                circleBody.BodyType = BodyType.Dynamic;
                circleBody.CreateFixture(circle_shape);
                PolygonShape polygonShape = new PolygonShape(2.0f);
                polygonShape.SetAsBox(10.0f, 0.2f, new Vector2(-10.0f, 0.0f), 0.0f);
                var polygon_body = BodyFactory.CreateBody(World);
                polygon_body.Position = new Vector2(20.0f, 10.0f);
                polygon_body.BodyType = BodyType.Dynamic;
                polygon_body.IsBullet = true;
                polygon_body.CreateFixture(polygonShape);
                RevoluteJoint rjd = new RevoluteJoint(ground, polygon_body, new Vector2(20.0f, 10.0f));
                rjd.LowerLimit = -0.25f * Settings.Pi;
                rjd.UpperLimit = 0.0f;
                rjd.LimitEnabled = true;
                World.AddJoint(rjd);
            }
        }
开发者ID:danzel,项目名称:FarseerPhysics,代码行数:54,代码来源:RevoluteTest.cs


示例14: RopeTest

        private RopeTest()
        {
            Body ground = BodyFactory.CreateEdge(World, new Vector2(-40.0f, 0.0f), new Vector2(40.0f, 0.0f));

            {
                Body prevBody = ground;
                PolygonShape largeShape = new PolygonShape(PolygonTools.CreateRectangle(1.5f, 1.5f), 100);
                PolygonShape smallShape = new PolygonShape(PolygonTools.CreateRectangle(0.5f, 0.125f), 20);

                const int N = 10;
                const float y = 15;

                for (int i = 0; i < N; ++i)
                {
                    Body body = BodyFactory.CreateBody(World);
                    body.BodyType = BodyType.Dynamic;
                    body.Position = new Vector2(0.5f + 1.0f * i, y);

                    if (i == N - 1)
                    {
                        Fixture fixture = body.CreateFixture(largeShape);
                        fixture.Friction = 0.2f;
                        fixture.CollisionCategories = Category.Cat2;
                        fixture.CollidesWith = Category.All & ~Category.Cat2;
                        body.Position = new Vector2(1.0f * i, y);
                        body.AngularDamping = 0.4f;
                    }
                    else
                    {
                        Fixture fixture = body.CreateFixture(smallShape);
                        fixture.Friction = 0.2f;
                        fixture.CollisionCategories = Category.Cat1;
                        fixture.CollidesWith = Category.All & ~Category.Cat2;
                    }

                    Vector2 anchor = new Vector2(i, y);
                    RevoluteJoint jd = new RevoluteJoint(prevBody, body, anchor, true); 
                    jd.CollideConnected = false;

                    World.AddJoint(jd);

                    prevBody = body;
                }

                _rj = new RopeJoint(ground, prevBody, new Vector2(0, y), Vector2.Zero);

                //FPE: The two following lines are actually not needed as FPE sets the MaxLength to a default value
                const float extraLength = 0.01f;
                _rj.MaxLength = N - 1.0f + extraLength;

                World.AddJoint(_rj);
            }
        }
开发者ID:RCGame,项目名称:FarseerPhysics,代码行数:53,代码来源:RopeTest.cs


示例15: physic_wheel_Initialysed

        void physic_wheel_Initialysed(object sender, EventArgs e)
        {

            var RectangleA2 = BodyFactory.CreateRectangle(physic_wheel.world, 999999f, 999999f, 1.0f);
            RectangleA2.BodyType = BodyType.Static;
            RectangleA2.Position = new Vector2(0f, 0f);
            RectangleA2.Rotation = 0f;
            RectangleA2.CollisionCategories = Category.None;

            var joint = new RevoluteJoint(physic_wheel.Body, RectangleA2, physic_wheel.physicWorld.UIToPhysic(wheel_cont, 
                new Point(wheel_cont.RenderSize.Width / 2.0, wheel_cont.RenderSize.Height / 2.0)), true) 
            { MotorEnabled = true, MotorSpeed = -0.2f , MaxMotorTorque = 10};
            physic_wheel.world.AddJoint(joint);
        }
开发者ID:TerisseNicolas,项目名称:Archip3l-WPF,代码行数:14,代码来源:ShowcaseHome.xaml.cs


示例16: InitJoint

    public override void InitJoint()
    {
        base.InitJoint ();
        //
        Vector3 p0 = BodyB.transform.TransformPoint(new Vector3(LocalAnchorB.x, LocalAnchorB.y, -5f));

        joint = JointFactory.CreateRevoluteJoint(FSWorldComponent.PhysicsWorld, BodyA.PhysicsBody, BodyB.PhysicsBody, BodyB.PhysicsBody.GetLocalPoint(FSHelper.Vector3ToFVector2(p0)));
        joint.CollideConnected = CollideConnected;
        joint.LowerLimit = LowerLimit * Mathf.Deg2Rad;
        joint.UpperLimit = UpperLimit * Mathf.Deg2Rad;
        joint.LimitEnabled = LimitEnabled;
        joint.MaxMotorTorque = MaxMotorTorque;
        joint.MotorSpeed = MotorSpeed;
        joint.MotorEnabled = MotorEnabled;
    }
开发者ID:pracalic,项目名称:Farseer-Unity3D,代码行数:15,代码来源:FSRevoluteJointComponent.cs


示例17: BodyTypesTest

        private BodyTypesTest()
        {
            //Ground
            Body ground = BodyFactory.CreateEdge(World, new Vector2(-20.0f, 0.0f), new Vector2(20.0f, 0.0f));

            // Define attachment
            {
                _attachment = BodyFactory.CreateRectangle(World, 1, 4, 2);
                _attachment.BodyType = BodyType.Dynamic;
                _attachment.Position = new Vector2(0.0f, 3.0f);
            }

            // Define platform
            {
                _platform = BodyFactory.CreateRectangle(World, 8.0f, 1f, 2);
                _platform.BodyType = BodyType.Dynamic;
                _platform.Position = new Vector2(0.0f, 5.0f);
                _platform.Friction = 0.6f;

                RevoluteJoint rjd = new RevoluteJoint(_attachment, _platform, new Vector2(0, 5), true);
                rjd.MaxMotorTorque = 50.0f;
                rjd.MotorEnabled = true;
                World.AddJoint(rjd);

                PrismaticJoint pjd = new PrismaticJoint(ground, _platform, new Vector2(0.0f, 5.0f), new Vector2(1.0f, 0.0f), true);
                pjd.MaxMotorForce = 1000.0f;
                pjd.MotorEnabled = true;
                pjd.LowerLimit = -10.0f;
                pjd.UpperLimit = 10.0f;
                pjd.LimitEnabled = true;

                World.AddJoint(pjd);

                _speed = 3.0f;
            }

            // Create a payload
            {
                Body body = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 2);
                body.BodyType = BodyType.Dynamic;
                body.Position = new Vector2(0.0f, 8.0f);
                body.Friction = 0.6f;
            }
        }
开发者ID:tinco,项目名称:Farseer-Physics,代码行数:44,代码来源:BodyTypesTest.cs


示例18: SwingPlatform

        public SwingPlatform(World world, SwingPlatformData swingPlatformData)
        {
            width = swingPlatformData.Width;
            height = swingPlatformData.Height;

            body = BodyFactory.CreateRectangle(world, width, height, 1.0f);
            body.Position = swingPlatformData.Center;
            body.BodyType = BodyType.Dynamic;
            anchor = BodyFactory.CreateCircle(world, 0.1f, 1.0f);
            anchor.Position = swingPlatformData.Center;
            anchor.BodyType = BodyType.Static;

            RevoluteJoint revoluteJoint = new RevoluteJoint(body, anchor, new Vector2(0.0f, 0.0f), new Vector2(0.0f, 0.0f));
            revoluteJoint.LowerLimit = -swingPlatformData.MaxAngle;
            revoluteJoint.UpperLimit = swingPlatformData.MaxAngle;
            revoluteJoint.LimitEnabled = true;
            revoluteJoint.MaxMotorTorque = 10.0f;
            revoluteJoint.MotorSpeed = 0.0f;
            revoluteJoint.MotorEnabled = true;
            world.AddJoint(revoluteJoint);
        }
开发者ID:pakona,项目名称:Boxics,代码行数:21,代码来源:SwingPlatform.cs


示例19: Character

        public Character(Game game, Scene scene, Vector2 position)
            : base(game, scene)
        {
            texture = Game.Content.Load<Texture2D>("zombie");
            ZBuffer = 0f;

            width = Conversion.ToWorld(44);
            height = Conversion.ToWorld(165);

            body = BodyFactory.CreateCircle(scene.World, (width / 2f), 40);
            body.Position = position - Vector2.UnitY * body.FixtureList[0].Shape.Radius / 2 + Vector2.UnitY * (height - width + width / 2.0f) / 2.0f;
            body.BodyType = BodyType.Dynamic;
            body.Friction = float.MaxValue;
            body.UserData = this;
            body.CollisionCategories = ElementCategory.CHARACTER;
            body.SleepingAllowed = false;

            body.OnCollision += new OnCollisionEventHandler(body_OnCollision);
            body.OnSeparation += new OnSeparationEventHandler(body_OnSeparation);

            torso = BodyFactory.CreateRectangle(scene.World, (width), (height - width + width / 2.0f), 40);
            torso.Position = position - Vector2.UnitY * body.FixtureList[0].Shape.Radius / 2;
            torso.BodyType = BodyType.Dynamic;
            torso.FixedRotation = true;
            torso.Friction = 0.0f;
            torso.UserData = this;
            torso.CollisionCategories = ElementCategory.CHARACTER;
            torso.CollidesWith = Category.All & ~ElementCategory.ENERGY;
            torso.SleepingAllowed = false;

            //torso.OnCollision += new OnCollisionEventHandler(torso_OnCollision);
            torso.OnSeparation += new OnSeparationEventHandler(torso_OnSeparation);

            revoluteJoint = new RevoluteJoint(torso, body, new Vector2(0, (height - width + width / 2.0f) / 2.0f), Vector2.Zero);
            revoluteJoint.CollideConnected = false;
            scene.World.AddJoint(revoluteJoint);

            State = new RunningCharacterState(scene, this);
        }
开发者ID:MartinMcGuinness,项目名称:TheLastDawn,代码行数:39,代码来源:Character.cs


示例20: PlacePhysicsObject

        public override Object PlacePhysicsObject(Microsoft.Xna.Framework.Vector2 position, FarseerPhysics.Dynamics.World world)
        {
            List<Fixture> list = world.TestPointAll(position);


            if (pin.Checked && list.Count > 0)
            {
                FixedRevoluteJoint j = new FixedRevoluteJoint(list[0].Body, list[0].Body.GetLocalPoint(position), position);
                if (motorEnabled.Checked)
                {
                    j.MotorEnabled = true;
                    float speed;
                    float maxTorque;
                    if (float.TryParse(motorSpeed.Text, out speed)) j.MotorSpeed = speed;
                    if (float.TryParse(motorTorque.Text, out maxTorque)) j.MaxMotorTorque = maxTorque;
                }

                world.AddJoint(j);
                return j;
            }
            
            if (list.Count > 1)
            {
                RevoluteJoint j = new RevoluteJoint(list[0].Body, list[1].Body, list[0].Body.GetLocalPoint(position), list[1].Body.GetLocalPoint(position));
                if (motorEnabled.Checked)
                {
                    j.MotorEnabled = true;
                    float speed;
                    float maxTorque;
                    if (float.TryParse(motorSpeed.Text, out speed)) j.MotorSpeed = speed;
                    if (float.TryParse(motorTorque.Text, out maxTorque)) j.MaxMotorTorque = maxTorque;
                }
                world.AddJoint(j);
                return j;
            }

            return base.PlacePhysicsObject(position, world);
        }
开发者ID:guozanhua,项目名称:KinectRagdoll,代码行数:38,代码来源:JointForm.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Framework.GameSettings类代码示例发布时间:2022-05-26
下一篇:
C# Joints.Joint类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap