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


C# Body.GetLocalPoint方法代码示例

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


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

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

示例2: HandleInput

        public override void HandleInput()
        {


            InputHelper input = game.inputManager.inputHelper;

            if (input.IsNewButtonPress(MouseButtons.LeftButton))
            {
                Vector2 position = ProjectionHelper.PixelToFarseer(input.MousePosition);

                List<Fixture> list = game.farseerManager.world.TestPointAll(position);

               

                    if (list.Count > 0)
                    {
                        if (startBody == null)
                        {
                            startBody = list[0].Body;
                            startBodyLocal = startBody.GetLocalPoint(position);

                            
                        }
                        else
                        {
                            Body endBody = list[0].Body;
                            Vector2 endBodyLocal = endBody.GetLocalPoint(position);

                            RopeJoint j = new RopeJoint(startBody, endBody, startBodyLocal, endBodyLocal);
                            j.CollideConnected = true;
                            game.farseerManager.world.AddJoint(j);

                            FormManager.Property.setSelectedObject(j);

                            startBody = null;
                        }
                    }
                
            }
            
        }
开发者ID:guozanhua,项目名称:KinectRagdoll,代码行数:41,代码来源:RopeTool.cs

示例3: BodyTypesTest

        private BodyTypesTest()
        {
            //Ground
            BodyFactory.CreateEdge(World, new Vector2(-40.0f, 0.0f), new Vector2(40.0f, 0.0f));

            // Define attachment
            {
                _attachment = BodyFactory.CreateBody(World);
                _attachment.BodyType = BodyType.Dynamic;
                _attachment.Position = new Vector2(0.0f, 3.0f);

                Vertices box = PolygonTools.CreateRectangle(0.5f, 2.0f);
                PolygonShape shape = new PolygonShape(box, 2);
                _attachment.CreateFixture(shape);
            }

            // Define platform
            {
                _platform = BodyFactory.CreateBody(World);
                _platform.BodyType = BodyType.Dynamic;
                _platform.Position = new Vector2(0.0f, 5.0f);

                Vertices box = PolygonTools.CreateRectangle(4.0f, 0.5f);
                PolygonShape shape = new PolygonShape(box, 2);

                Fixture fixture = _platform.CreateFixture(shape);
                fixture.Friction = 0.6f;

                RevoluteJoint rjd = new RevoluteJoint(_attachment, _platform,
                                                      _attachment.GetLocalPoint(_platform.Position),
                                                      Vector2.Zero);
                rjd.MaxMotorTorque = 50.0f;
                rjd.MotorEnabled = true;
                World.AddJoint(rjd);

                //FixedPrismaticJoint pjd = new FixedPrismaticJoint(_platform, new Vector2(0.0f, 5.0f),
                //                                                  new Vector2(1.0f, 0.0f));
                //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.CreateBody(World);
                body.BodyType = BodyType.Dynamic;
                body.Position = new Vector2(0.0f, 8.0f);

                Vertices box = PolygonTools.CreateRectangle(0.75f, 0.75f);
                PolygonShape shape = new PolygonShape(box, 2);

                Fixture fixture = body.CreateFixture(shape);
                fixture.Friction = 0.6f;
            }
        }
开发者ID:hilts-vaughan,项目名称:Farseer-Physics,代码行数:61,代码来源:BodyTypesTest.cs

示例4: BridgeTest

        private BridgeTest()
        {
            Body ground;
            {
                ground = new Body(World);

                PolygonShape shape = new PolygonShape(0);
                shape.SetAsEdge(new Vector2(-40.0f, 0.0f), new Vector2(40.0f, 0.0f));
                ground.CreateFixture(shape);
            }
            {
                Vertices box = PolygonTools.CreateRectangle(0.5f, 0.125f);
                PolygonShape shape = new PolygonShape(box, 20);

                Body prevBody = ground;
                for (int i = 0; i < Count; ++i)
                {
                    Body body = BodyFactory.CreateBody(World);
                    body.BodyType = BodyType.Dynamic;
                    body.Position = new Vector2(-14.5f + 1.0f*i, 5.0f);

                    Fixture fixture = body.CreateFixture(shape);
                    fixture.Friction = 0.2f;

                    Vector2 anchor = new Vector2(-0.5f, 0.0f);
                    RevoluteJoint jd = new RevoluteJoint(prevBody, body,
                                                         prevBody.GetLocalPoint(body.GetWorldPoint(anchor)), anchor);
                    World.AddJoint(jd);

                    prevBody = body;
                }

                Vector2 anchor2 = new Vector2(0.5f, 0.0f);
                RevoluteJoint jd2 = new RevoluteJoint(ground, prevBody,
                                                      ground.GetLocalPoint(prevBody.GetWorldPoint(anchor2)), anchor2);
                World.AddJoint(jd2);
            }

            Vertices vertices = new Vertices(3);
            vertices.Add(new Vector2(-0.5f, 0.0f));
            vertices.Add(new Vector2(0.5f, 0.0f));
            vertices.Add(new Vector2(0.0f, 1.5f));

            for (int i = 0; i < 2; ++i)
            {
                PolygonShape shape = new PolygonShape(vertices, 1);

                Body body = BodyFactory.CreateBody(World);
                body.BodyType = BodyType.Dynamic;
                body.Position = new Vector2(-8.0f + 8.0f*i, 12.0f);

                body.CreateFixture(shape);
            }

            for (int i = 0; i < 3; ++i)
            {
                CircleShape shape = new CircleShape(0.5f, 1);

                Body body = BodyFactory.CreateBody(World);
                body.BodyType = BodyType.Dynamic;
                body.Position = new Vector2(-6.0f + 6.0f*i, 10.0f);

                body.CreateFixture(shape);
            }
        }
开发者ID:danielselnick,项目名称:Geometric-Replication,代码行数:65,代码来源:BridgeTest.cs

示例5: CreateChassis

        private void CreateChassis(World world, Vector2 pivot, AssetCreator assets)
        {
            {
                PolygonShape shape = new PolygonShape(1f);
                shape.Vertices = PolygonTools.CreateRectangle(2.5f, 1.0f);

                _body = new Sprite(assets.TextureFromShape(shape, MaterialType.Blank, Color.Beige, 1f));

                _chassis = BodyFactory.CreateBody(world);
                _chassis.BodyType = BodyType.Dynamic;
                _chassis.Position = pivot + _position;

                Fixture fixture = _chassis.CreateFixture(shape);
                fixture.CollisionGroup = -1;
            }

            {
                CircleShape shape = new CircleShape(1.6f, 1f);
                _engine = new Sprite(assets.TextureFromShape(shape, MaterialType.Waves, Color.Beige * 0.8f, 1f));

                _wheel = BodyFactory.CreateBody(world);
                _wheel.BodyType = BodyType.Dynamic;
                _wheel.Position = pivot + _position;

                Fixture fixture = _wheel.CreateFixture(shape);
                fixture.CollisionGroup = -1;
            }

            {
                _motorJoint = new RevoluteJoint(_wheel, _chassis, _wheel.GetLocalPoint(_chassis.Position), Vector2.Zero);
                _motorJoint.CollideConnected = false;
                _motorJoint.MotorSpeed = _motorSpeed;
                _motorJoint.MaxMotorTorque = 400f;
                _motorJoint.MotorEnabled = true;
                world.AddJoint(_motorJoint);
            }
        }
开发者ID:Woktopus,项目名称:Gamejam_lib,代码行数:37,代码来源:TheoJansen.cs

示例6: CreateWeldJoint

 /// <summary>
 /// Creates a weld joint
 /// </summary>
 /// <param name="bodyA"></param>
 /// <param name="bodyB"></param>
 /// <param name="localAnchor"></param>
 /// <returns></returns>
 public static WeldJoint CreateWeldJoint(Body bodyA, Body bodyB, Vector2 localAnchor)
 {
     WeldJoint joint = new WeldJoint(bodyA, bodyB, bodyA.GetLocalPoint(localAnchor),
                                     bodyB.GetLocalPoint(localAnchor));
     return joint;
 }
开发者ID:HaKDMoDz,项目名称:Zazumo,代码行数:13,代码来源:JointFactory.cs

示例7: CreateRevoluteJoint

 /// <summary>
 /// Creates a revolute joint.
 /// </summary>
 /// <param name="bodyA"></param>
 /// <param name="bodyB"></param>
 /// <param name="localAnchorB">The anchor of bodyB in local coordinates</param>
 /// <returns></returns>
 public static RevoluteJoint CreateRevoluteJoint(Body bodyA, Body bodyB, Vector2 localAnchorB)
 {
     Vector2 localanchorA = bodyA.GetLocalPoint(bodyB.GetWorldPoint(localAnchorB));
     RevoluteJoint joint = new RevoluteJoint(bodyA, bodyB, localanchorA, localAnchorB);
     return joint;
 }
开发者ID:HaKDMoDz,项目名称:Zazumo,代码行数:13,代码来源:JointFactory.cs

示例8: CreatePrismaticJoint

 /// <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 PrismaticJoint CreatePrismaticJoint(Body bodyA, Body bodyB, Vector2 localanchorB, Vector2 axis)
 {
     Vector2 localanchorA = bodyA.GetLocalPoint(bodyB.GetWorldPoint(localanchorB));
     PrismaticJoint joint = new PrismaticJoint(bodyA, bodyB, localanchorA, localanchorB, axis);
     return joint;
 }
开发者ID:HaKDMoDz,项目名称:Zazumo,代码行数:14,代码来源:JointFactory.cs

示例9: TheoJansenWalker

        public TheoJansenWalker(World world, PhysicsGameScreen screen, Vector2 position)
        {
            _position = position;
            _motorSpeed = 2.0f;
            _motorOn = true;
            _screen = screen;

            _walkerJoints = new List<DistanceJoint>();

            _leftShoulders = new Body[3];
            _rightShoulders = new Body[3];
            _leftLegs = new Body[3];
            _rightLegs = new Body[3];

            Vector2 pivot = new Vector2(0f, -0.8f);

            // Chassis
            {
                PolygonShape shape = new PolygonShape(1f);
                shape.SetAsBox(2.5f, 1.0f);

                _body =
                    new Sprite(_screen.ScreenManager.Assets.TextureFromShape(shape, MaterialType.Blank,
                                                                             Color.Beige, 1f));

                _chassis = BodyFactory.CreateBody(world);
                _chassis.BodyType = BodyType.Dynamic;
                _chassis.Position = pivot + _position;

                Fixture fixture = _chassis.CreateFixture(shape);
                fixture.CollisionGroup = -1;
            }

            {
                CircleShape shape = new CircleShape(1.6f, 1f);
                _engine =
                    new Sprite(_screen.ScreenManager.Assets.TextureFromShape(shape, MaterialType.Waves,
                                                                             Color.Beige * 0.8f, 1f));

                _wheel = BodyFactory.CreateBody(world);
                _wheel.BodyType = BodyType.Dynamic;
                _wheel.Position = pivot + _position;

                Fixture fixture = _wheel.CreateFixture(shape);
                fixture.CollisionGroup = -1;
            }

            {
                _motorJoint = new RevoluteJoint(_wheel, _chassis, _wheel.GetLocalPoint(_chassis.Position), Vector2.Zero);
                _motorJoint.CollideConnected = false;
                _motorJoint.MotorSpeed = _motorSpeed;
                _motorJoint.MaxMotorTorque = 400f;
                _motorJoint.MotorEnabled = _motorOn;
                world.AddJoint(_motorJoint);
            }

            Vector2 wheelAnchor = pivot + new Vector2(0f, 0.8f);

            CreateLegTextures();

            CreateLeg(world, -1f, wheelAnchor, 0);
            CreateLeg(world, 1f, wheelAnchor, 0);

            _leftLeg.Origin = AssetCreator.CalculateOrigin(_leftLegs[0]);
            _leftShoulder.Origin = AssetCreator.CalculateOrigin(_leftShoulders[0]);
            _rightLeg.Origin = AssetCreator.CalculateOrigin(_rightLegs[0]);
            _rightShoulder.Origin = AssetCreator.CalculateOrigin(_rightShoulders[0]);

            _wheel.SetTransform(_wheel.Position, 120f * Settings.Pi / 180f);
            CreateLeg(world, -1f, wheelAnchor, 1);
            CreateLeg(world, 1f, wheelAnchor, 1);

            _wheel.SetTransform(_wheel.Position, -120f * Settings.Pi / 180f);
            CreateLeg(world, -1f, wheelAnchor, 2);
            CreateLeg(world, 1f, wheelAnchor, 2);
        }
开发者ID:hilts-vaughan,项目名称:Farseer-Physics,代码行数:76,代码来源:TheoJansen.cs

示例10: CreateWeldJoint

 /// <summary>
 /// Creates a weld joint
 /// </summary>
 /// <param name="world"></param>
 /// <param name="bodyA"></param>
 /// <param name="bodyB"></param>
 /// <param name="localanchorB"></param>
 /// <returns></returns>
 public static WeldJoint CreateWeldJoint(Body bodyA, Body bodyB, Vector2 localanchorB)
 {
     Vector2 localanchorA = bodyA.GetLocalPoint(bodyB.GetWorldPoint(localanchorB));
     WeldJoint joint = new WeldJoint(bodyA, bodyB, localanchorA, localanchorB);
     return joint;
 }
开发者ID:HaKDMoDz,项目名称:Lunar-Development-Kit,代码行数:14,代码来源:JointFactory.cs

示例11: TheoJansenTest

        private TheoJansenTest()
        {
            _offset = new Vector2(0.0f, 8.0f);
            _motorSpeed = 2.0f;
            _motorOn = true;
            Vector2 pivot = new Vector2(0.0f, 0.8f);

            // Ground
            {
                Body ground = BodyFactory.CreateBody(World);

                EdgeShape shape = new EdgeShape(new Vector2(-50.0f, 0.0f), new Vector2(50.0f, 0.0f));
                ground.CreateFixture(shape);

                shape = new EdgeShape(new Vector2(-50.0f, 0.0f), new Vector2(-50.0f, 10.0f));
                ground.CreateFixture(shape);

                shape = new EdgeShape(new Vector2(50.0f, 0.0f), new Vector2(50.0f, 10.0f));
                ground.CreateFixture(shape);
            }

            // Balls
            for (int i = 0; i < 40; ++i)
            {
                CircleShape shape = new CircleShape(0.25f, 1);

                Body body = BodyFactory.CreateBody(World);
                body.BodyType = BodyType.Dynamic;
                body.Position = new Vector2(-40.0f + 2.0f * i, 0.5f);

                body.CreateFixture(shape);
            }

            // Chassis
            {
                PolygonShape shape = new PolygonShape(1);
                shape.SetAsBox(2.5f, 1.0f);

                _chassis = BodyFactory.CreateBody(World);
                _chassis.BodyType = BodyType.Dynamic;
                _chassis.Position = pivot + _offset;

                Fixture fixture = _chassis.CreateFixture(shape);
                fixture.CollisionGroup = -1;
            }

            {
                CircleShape shape = new CircleShape(1.6f, 1);

                _wheel = BodyFactory.CreateBody(World);
                _wheel.BodyType = BodyType.Dynamic;
                _wheel.Position = pivot + _offset;

                Fixture fixture = _wheel.CreateFixture(shape);
                fixture.CollisionGroup = -1;
            }

            {
                //_motorJoint = new RevoluteJoint(_wheel, _chassis, pivot + _offset);
                _motorJoint = new RevoluteJoint(_wheel, _chassis, _wheel.GetLocalPoint(_chassis.Position), Vector2.Zero);
                _motorJoint.CollideConnected = false;
                _motorJoint.MotorSpeed = _motorSpeed;
                _motorJoint.MaxMotorTorque = 400.0f;
                _motorJoint.MotorEnabled = _motorOn;
                World.AddJoint(_motorJoint);
            }

            Vector2 wheelAnchor = pivot + new Vector2(0.0f, -0.8f);

            CreateLeg(-1.0f, wheelAnchor);
            CreateLeg(1.0f, wheelAnchor);

            _wheel.SetTransform(_wheel.Position, 120.0f * Settings.Pi / 180.0f);
            CreateLeg(-1.0f, wheelAnchor);
            CreateLeg(1.0f, wheelAnchor);

            _wheel.SetTransform(_wheel.Position, -120.0f * Settings.Pi / 180.0f);
            CreateLeg(-1.0f, wheelAnchor);
            CreateLeg(1.0f, wheelAnchor);
        }
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:80,代码来源:TheoJansenTest.cs

示例12: Start


//.........这里部分代码省略.........
				// R
				Body upperLegR = new Body(FSWorldComponent.PhysicsWorld);
				box = new PolygonShape(1f);
				box.SetAsBox(7.5f / physScale, 22f / physScale);
				fixture = new Fixture(upperLegR, box);
				fixture.Friction = 0.4f;
				fixture.Restitution = 0.1f;
				upperLegR.Position = new FVector2((startX + 8f) / physScale, (startY - 85f) / physScale);
				upperLegR.BodyType = BodyType.Dynamic;
				
				// LowerLeg
				// L
				Body lowerLegL = new Body(FSWorldComponent.PhysicsWorld);
				box = new PolygonShape(1f);
				box.SetAsBox(7.5f / physScale, 22f / physScale);
				fixture = new Fixture(lowerLegL, box);
				fixture.Friction = 0.4f;
				fixture.Restitution = 0.1f;
				lowerLegL.Position = new FVector2((startX - 8f) / physScale, (startY - 120f) / physScale);
				lowerLegL.BodyType = BodyType.Dynamic;
				// R
				Body lowerLegR = new Body(FSWorldComponent.PhysicsWorld);
				box = new PolygonShape(1f);
				box.SetAsBox(7.5f / physScale, 22f / physScale);
				fixture = new Fixture(lowerLegR, box);
				fixture.Friction = 0.4f;
				fixture.Restitution = 0.1f;
				lowerLegR.Position = new FVector2((startX + 8f) / physScale, (startY - 120f) / physScale);
				lowerLegR.BodyType = BodyType.Dynamic;
				
				// JOINTS
				
				// Head to shoulders
				joint = JointFactory.CreateRevoluteJoint(FSWorldComponent.PhysicsWorld, torso1, head, head.GetLocalPoint(new FVector2(startX / physScale, (startY - 15f) / physScale)));
				joint.LowerLimit = -40f * Mathf.Deg2Rad;
				joint.UpperLimit = 40f * Mathf.Deg2Rad;
				joint.LimitEnabled = true;
				joint.CollideConnected = false;
				
				// Upper arm to shoulders
				// L
				joint = JointFactory.CreateRevoluteJoint(FSWorldComponent.PhysicsWorld, torso1, upperArmL, upperArmL.GetLocalPoint(new FVector2((startX - 18f) / physScale, (startY - 20f) / physScale)));
				joint.LowerLimit = -85f * Mathf.Deg2Rad;
				joint.UpperLimit = 130f * Mathf.Deg2Rad;
				joint.LimitEnabled = true;
				joint.CollideConnected = false;
				// R
				joint = JointFactory.CreateRevoluteJoint(FSWorldComponent.PhysicsWorld, torso1, upperArmR, upperArmR.GetLocalPoint(new FVector2((startX + 18f) / physScale, (startY - 20f) / physScale)));
				joint.LowerLimit = -130f * Mathf.Deg2Rad;
				joint.UpperLimit = 85f * Mathf.Deg2Rad;
				joint.LimitEnabled = true;
				joint.CollideConnected = false;
				
				// Lower arm to upper arm
				// L
				joint = JointFactory.CreateRevoluteJoint(FSWorldComponent.PhysicsWorld, upperArmL, lowerArmL, lowerArmL.GetLocalPoint(new FVector2((startX - 45f) / physScale, (startY - 20f) / physScale)));
				joint.LowerLimit = -130f * Mathf.Deg2Rad;
				joint.UpperLimit = 10f * Mathf.Deg2Rad;
				joint.LimitEnabled = true;
				joint.CollideConnected = false;
				// R
				joint = JointFactory.CreateRevoluteJoint(FSWorldComponent.PhysicsWorld, upperArmR, lowerArmR, lowerArmR.GetLocalPoint(new FVector2((startX + 45f) / physScale, (startY - 20f) / physScale)));
				joint.LowerLimit = -10f * Mathf.Deg2Rad;
				joint.UpperLimit = 130f * Mathf.Deg2Rad;
				joint.LimitEnabled = true;
				joint.CollideConnected = false;
开发者ID:frotein,项目名称:TinyUniverse,代码行数:67,代码来源:RagdollTest.cs

示例13: EasyRevoluteJoint

 RevoluteJoint EasyRevoluteJoint(Body bodyA, Body bodyB, Vector2 worldPos)
 {
     return new RevoluteJoint(bodyA, bodyB, bodyA.GetLocalPoint(ref worldPos), bodyB.GetLocalPoint(ref worldPos));
 }
开发者ID:RubisetCie,项目名称:box2c,代码行数:4,代码来源:Form2.cs


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