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


C# Body.SetMassFromShapes方法代码示例

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


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

示例1: ShapeEditing

		public ShapeEditing()
		{
			{
				PolygonDef sd = new PolygonDef();
				sd.SetAsBox(50.0f, 10.0f);

				BodyDef bd = new BodyDef();
				bd.Position.Set(0.0f, -10.0f);

				Body ground = _world.CreateBody(bd);
				ground.CreateShape(sd);
			}

			BodyDef bodydef = new BodyDef();
			bodydef.Position.Set(0.0f, 10.0f);
			_body = _world.CreateBody(bodydef);

			PolygonDef sd_ = new PolygonDef();
			sd_.SetAsBox(4.0f, 4.0f, new Vec2(0.0f, 0.0f), 0.0f);
			sd_.Density = 10.0f;
			_shape1 = _body.CreateShape(sd_);
			_body.SetMassFromShapes();

			_shape2 = null;
		}
开发者ID:colgreen,项目名称:box2dx,代码行数:25,代码来源:ShapeEditing.cs

示例2: DistanceTest

		public DistanceTest()
		{
			PolygonDef sd = new PolygonDef();
			sd.SetAsBox(1.0f, 1.0f);
			sd.Density = 0.0f;

			BodyDef bd = new BodyDef();
			bd.Position.Set(0.0f, 10.0f);
			_body1 = _world.CreateBody(bd);
			_shape1 = _body1.CreateShape(sd);

			PolygonDef sd2 = new PolygonDef();
			sd2.VertexCount = 3;
			sd2.Vertices[0].Set(-1.0f, 0.0f);
			sd2.Vertices[1].Set(1.0f, 0.0f);
			sd2.Vertices[2].Set(0.0f, 15.0f);
			sd2.Density = 1.0f;

			BodyDef bd2 = new BodyDef();

			bd2.Position.Set(0.0f, 10.0f);

			_body2 = _world.CreateBody(bd2);
			_shape2 = _body2.CreateShape(sd2);
			_body2.SetMassFromShapes();

			_world.Gravity = new Vec2(0.0f, 0.0f);
		}
开发者ID:colgreen,项目名称:box2dx,代码行数:28,代码来源:DistanceTest.cs

示例3: Projectile

        public Projectile(Player creator, float x, float y, float width, float height)
            : base(creator, 0, 0)
        {
            /* Create New Projectile Body */
            BodyDef def = new BodyDef();
            def.IsBullet = true;
            def.Position = creator.body.GetPosition() + new Vec2(x, y);
            projectile = creator.body.GetWorld().CreateBody(def);

            /* Create a fixture for the projectile */
            PolygonDef fixdef = new PolygonDef();
            fixdef.Density = 1.0f;
            fixdef.SetAsBox(width / 2, height / 2);
            fixdef.Filter.GroupIndex = creator.ID;
            fixture = projectile.CreateFixture(fixdef);
            fixture.Filter.CategoryBits = 0x0004;
            fixture.Filter.MaskBits = 0xFFFF;

            /* Made a 2nd fixture, one to observe all collisions */
            fixdef.IsSensor = true;
            fix2 = projectile.CreateFixture(fixdef);
            fix2.UserData = this;

            /* Finally, give this projectile some mass */
            projectile.SetMassFromShapes();

            /* Also, make sure we destroy the projectile when it is time */
            this.OnDestroy += Cleanup;
        }
开发者ID:CloneDeath,项目名称:PokemonSmash,代码行数:29,代码来源:Projectile.cs

示例4: PolyCollision

		public PolyCollision()
		{
			_localPoints[0].state = ContactState.ContactRemoved;
			_localPoints[1].state = ContactState.ContactRemoved;

			{
				PolygonDef sd = new PolygonDef();
				sd.Vertices[0].Set(-9.0f, -1.1f);
				sd.Vertices[1].Set(7.0f, -1.1f);
				sd.Vertices[2].Set(5.0f, -0.9f);
				sd.Vertices[3].Set(-11.0f, -0.9f);
				sd.VertexCount = 4;
				sd.Density = 0.0f;

				BodyDef bd = new BodyDef();
				bd.Position.Set(0.0f, 10.0f);
				_body1 = _world.CreateBody(bd);
				_body1.CreateShape(sd);
			}

			{
				PolygonDef sd = new PolygonDef();
				sd.SetAsBox(0.5f, 0.5f);
				sd.Density = 1.0f;

				BodyDef bd = new BodyDef();
				bd.Position.Set(0.0f, 10.0f);
				_body2 = _world.CreateBody(bd);
				_body2.CreateShape(sd);
				_body2.SetMassFromShapes();
			}

			_world.Gravity = Vec2.Zero;
		}
开发者ID:colgreen,项目名称:box2dx,代码行数:34,代码来源:PolyCollision.cs

示例5: TimeOfImpact

		public TimeOfImpact()
		{
			{
				PolygonDef sd = new PolygonDef();
				sd.Density = 0.0f;

				sd.SetAsBox(0.1f, 10.0f, new Vec2(10.0f, 0.0f), 0.0f);

				BodyDef bd = new BodyDef();
				bd.Position.Set(0.0f, 20.0f);
				bd.Angle = 0.0f;
				_body1 = _world.CreateBody(bd);
				_shape1 = _body1.CreateShape(sd);
			}

			{
				PolygonDef sd = new PolygonDef();
				sd.SetAsBox(0.25f, 0.25f);
				sd.Density = 1.0f;

				BodyDef bd = new BodyDef();
				bd.Position.Set(9.6363468f, 28.050615f);
				bd.Angle = 1.6408679f;
				_body2 = _world.CreateBody(bd);
				_shape2 = (PolygonShape)_body2.CreateShape(sd);
				_body2.SetMassFromShapes();
			}
		}
开发者ID:colgreen,项目名称:box2dx,代码行数:28,代码来源:TimeOfImpact.cs

示例6: RaycastTest

		public RaycastTest()
		{
			Body ground = null;
			{
				BodyDef bd = new BodyDef();
				bd.Position.Set(0.0f, -10.0f);
				ground = _world.CreateBody(bd);

				PolygonDef sd = new PolygonDef();
				sd.SetAsBox(50.0f, 10.0f);
				ground.CreateShape(sd);
			}

			{
				BodyDef bd = new BodyDef();
				bd.Position.Set(0.0f, 1.0f);
				laserBody = _world.CreateBody(bd);

				PolygonDef sd = new PolygonDef();
				sd.SetAsBox(5.0f, 1.0f);
				sd.Density = 4.0f;
				laserBody.CreateShape(sd);
				laserBody.SetMassFromShapes();

				Body body;
				//Create a few shapes
				bd.Position.Set(-5.0f, 10.0f);
				body = _world.CreateBody(bd);

				CircleDef cd = new CircleDef();
				cd.Radius = 3;
				body.CreateShape(cd);

				bd.Position.Set(5.0f, 10.0f);
				body = _world.CreateBody(bd);

				body.CreateShape(cd);
			}
		}
开发者ID:colgreen,项目名称:box2dx,代码行数:39,代码来源:RaycastTest.cs

示例7: Keyboard

		public override void Keyboard(System.Windows.Forms.Keys key)
		{
			switch (key)
			{
				case System.Windows.Forms.Keys.B:
					if (_bullet != null)
					{
						_world.DestroyBody(_bullet);
						_bullet = null;
					}
					{
						CircleDef sd = new CircleDef();
						sd.Density = 20.0f;
						sd.Radius = 0.25f;
						sd.Restitution = 0.05f;

						BodyDef bd = new BodyDef();
						bd.IsBullet = true;
						bd.Position.Set(-31.0f, 5.0f);

						_bullet = _world.CreateBody(bd);
						_bullet.CreateFixture(sd);
						_bullet.SetMassFromShapes();

						_bullet.SetLinearVelocity(new Vec2(400.0f, 0.0f));
					}
					break;
			}
		}
开发者ID:ajmaya,项目名称:box2dx,代码行数:29,代码来源:VerticalStack.cs

示例8: LoadContent

        protected override void LoadContent()
        {
            poligonDef = new PolygonDef();

            poligonDef.VertexCount = CollisionBody.Length;

            poligonDef.Vertices = CollisionBody;

            poligonDef.Density = 2000f;

            poligonDef.Friction = 100f;

            BodyDef bodyDef = new BodyDef();

            bodyDef.Position = new Vec2(Position.X, Position.Y);

            Body = Game1.world.CreateBody(bodyDef);

            PolygonShape shape = (PolygonShape)Body.CreateShape(poligonDef);

            Body.SetMassFromShapes();

            base.LoadContent();
        }
开发者ID:RadekBednar,项目名称:RacingGame,代码行数:24,代码来源:Object.cs

示例9: ElasticBody

		// Main...
		public ElasticBody()
		{
			// Bottom static body
			{
				PolygonDef sd = new PolygonDef();
				sd.SetAsBox(50.0f, 2.0f);
				sd.Friction = 0.1f;
				sd.Restitution = 0.1f;
				BodyDef bd = new BodyDef();
				bd.Position.Set(-1.0f, -7.5f);
				_ground = _world.CreateBody(bd);
				_ground.CreateShape(sd);
			}
			// Upper static body
			{
				PolygonDef sd = new PolygonDef();
				sd.SetAsBox(20.0f, 0.50f, new Vec2(0.0f, 0.0f), 0.047f * Box2DX.Common.Settings.Pi);
				sd.Friction = 0.01f;
				sd.Restitution = 0.001f;
				BodyDef bd = new BodyDef();
				bd.Position.Set(-20.0f, 93.0f);
				Body g = _world.CreateBody(bd);
				g.CreateShape(sd);
				sd.SetAsBox(15.0f, 0.50f, new Vec2(-15.0f, 12.5f), 0.0f);
				g.CreateShape(sd);

				sd.SetAsBox(20.0f, 0.5f, new Vec2(0.0f, -25.0f), -0.5f);
				g.CreateShape(sd);
			}
			// Left channel left wall
			{
				PolygonDef sd = new PolygonDef();
				sd.SetAsBox(0.7f, 55.0f);
				sd.Friction = 0.1f;
				sd.Restitution = 0.1f;
				BodyDef bd = new BodyDef();
				bd.Position.Set(-49.3f, 50.0f);
				Body g = _world.CreateBody(bd);
				g.CreateShape(sd);
			}
			// Right wall
			{
				PolygonDef sd = new PolygonDef();
				sd.SetAsBox(0.7f, 55.0f);
				sd.Friction = 0.1f;
				sd.Restitution = 0.1f;
				BodyDef bd = new BodyDef();
				bd.Position.Set(45.0f, 50.0f);
				Body g = _world.CreateBody(bd);
				g.CreateShape(sd);
			}
			// Left channel right upper wall  
			{
				PolygonDef sd = new PolygonDef();
				sd.SetAsBox(0.5f, 20.0f);
				sd.Friction = 0.05f;
				sd.Restitution = 0.01f;
				BodyDef bd = new BodyDef();
				bd.Position.Set(-42.0f, 70.0f);
				bd.Angle = -0.03f * Box2DX.Common.Settings.Pi;
				Body g = _world.CreateBody(bd);
				g.CreateShape(sd);
			}
			// Left channel right lower wall
			{
				PolygonDef sd = new PolygonDef();
				sd.SetAsBox(0.50f, 23.0f);
				sd.Friction = 0.05f;
				sd.Restitution = 0.01f;
				BodyDef bd = new BodyDef();
				bd.Position.Set(-44.0f, 27.0f);
				Body g = _world.CreateBody(bd);
				g.CreateShape(sd);
				// Bottom motors
				CircleDef cd = new CircleDef();
				cd.Radius = 3.0f;
				cd.Density = 15.0f;
				cd.Friction = 1.0f;
				cd.Restitution = 0.2f;
				// 1. 
				bd.Position.Set(-40.0f, 2.5f);
				Body body = _world.CreateBody(bd);
				body.CreateShape(cd);
				body.SetMassFromShapes();
				RevoluteJointDef jr = new RevoluteJointDef();
				jr.Initialize(g, body, body.GetWorldCenter() + new Vec2(0.0f, 1.0f));
				jr.MaxMotorTorque = 30000.0f;
				jr.EnableMotor = true;
				jr.MotorSpeed = 20.0f;
				_world.CreateJoint(jr);
				// 1. left down
				bd.Position.Set(-46.0f, -2.5f);
				cd.Radius = 1.5f; jr.MotorSpeed = -20.0f;
				body = _world.CreateBody(bd);
				body.CreateShape(cd);
				sd.SetAsBox(2.0f, 0.50f);
				body.CreateShape(sd);
				body.SetMassFromShapes();
				jr.Initialize(g, body, body.GetWorldCenter());
//.........这里部分代码省略.........
开发者ID:colgreen,项目名称:box2dx,代码行数:101,代码来源:ElasticBody.cs

示例10: TheoJansen

		public TheoJansen()
		{
			_offset.Set(0.0f, 8.0f);
			_motorSpeed = 2.0f;
			_motorOn = true;
			Vec2 pivot = new Vec2(0.0f, 0.8f);

			{
				PolygonDef sd = new PolygonDef();
				sd.SetAsBox(50.0f, 10.0f);

				BodyDef bd = new BodyDef();
				bd.Position.Set(0.0f, -10.0f);
				Body ground = _world.CreateBody(bd);
				ground.CreateShape(sd);

				sd.SetAsBox(0.5f, 5.0f, new Vec2(-50.0f, 15.0f), 0.0f);
				ground.CreateShape(sd);

				sd.SetAsBox(0.5f, 5.0f, new Vec2(50.0f, 15.0f), 0.0f);
				ground.CreateShape(sd);
			}

			for (int i = 0; i < 40; ++i)
			{
				CircleDef sd = new CircleDef();
				sd.Density = 1.0f;
				sd.Radius = 0.25f;

				BodyDef bd = new BodyDef();
				bd.Position.Set(-40.0f + 2.0f * i, 0.5f);

				Body body = _world.CreateBody(bd);
				body.CreateShape(sd);
				body.SetMassFromShapes();
			}

			{
				PolygonDef sd = new PolygonDef();
				sd.Density = 1.0f;
				sd.SetAsBox(2.5f, 1.0f);
				sd.Filter.GroupIndex = -1;
				BodyDef bd = new BodyDef();
				bd.Position = pivot + _offset;
				_chassis = _world.CreateBody(bd);
				_chassis.CreateShape(sd);
				_chassis.SetMassFromShapes();
			}

			{
				CircleDef sd = new CircleDef();
				sd.Density = 1.0f;
				sd.Radius = 1.6f;
				sd.Filter.GroupIndex = -1;
				BodyDef bd = new BodyDef();
				bd.Position = pivot + _offset;
				_wheel = _world.CreateBody(bd);
				_wheel.CreateShape(sd);
				_wheel.SetMassFromShapes();
			}

			{
				RevoluteJointDef jd = new RevoluteJointDef();
				jd.Initialize(_wheel, _chassis, pivot + _offset);
				jd.CollideConnected = false;
				jd.MotorSpeed = _motorSpeed;
				jd.MaxMotorTorque = 400.0f;
				jd.EnableMotor = _motorOn;
				_motorJoint = (RevoluteJoint)_world.CreateJoint(jd);
			}

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

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

			_wheel.SetXForm(_wheel.GetPosition(), 120.0f * Box2DX.Common.Settings.Pi / 180.0f);
			CreateLeg(-1.0f, wheelAnchor);
			CreateLeg(1.0f, wheelAnchor);

			_wheel.SetXForm(_wheel.GetPosition(), -120.0f * Box2DX.Common.Settings.Pi / 180.0f);
			CreateLeg(-1.0f, wheelAnchor);
			CreateLeg(1.0f, wheelAnchor);
		}
开发者ID:colgreen,项目名称:box2dx,代码行数:86,代码来源:TheoJansen.cs

示例11: Car

		public Car()
		{
			{	// car body
				PolygonDef poly1 = new PolygonDef(), poly2 = new PolygonDef();

				// bottom half
				poly1.VertexCount = 5;
				poly1.Vertices[4].Set(-2.2f, -0.74f);
				poly1.Vertices[3].Set(-2.2f, 0);
				poly1.Vertices[2].Set(1.0f, 0);
				poly1.Vertices[1].Set(2.2f, -0.2f);
				poly1.Vertices[0].Set(2.2f, -0.74f);
				poly1.Filter.GroupIndex = -1;

				poly1.Density = 20.0f;
				poly1.Friction = 0.68f;
				poly1.Filter.GroupIndex = -1;

				// top half
				poly2.VertexCount = 4;
				poly2.Vertices[3].Set(-1.7f, 0);
				poly2.Vertices[2].Set(-1.3f, 0.7f);
				poly2.Vertices[1].Set(0.5f, 0.74f);
				poly2.Vertices[0].Set(1.0f, 0);
				poly2.Filter.GroupIndex = -1;

				poly2.Density = 5.0f;
				poly2.Friction = 0.68f;
				poly2.Filter.GroupIndex = -1;

				BodyDef bd = new BodyDef();
				bd.Position.Set(-35.0f, 2.8f);

				_vehicle = _world.CreateBody(bd);
				_vehicle.CreateShape(poly1);
				_vehicle.CreateShape(poly2);
				_vehicle.SetMassFromShapes();
			}

			{	// vehicle wheels
				CircleDef circ = new CircleDef();
				circ.Density = 40.0f;
				circ.Radius = 0.38608f;
				circ.Friction = 0.8f;
				circ.Filter.GroupIndex = -1;

				BodyDef bd = new BodyDef();
				bd.AllowSleep = false;
				bd.Position.Set(-33.8f, 2.0f);

				_rightWheel = _world.CreateBody(bd);
				_rightWheel.CreateShape(circ);
				_rightWheel.SetMassFromShapes();

				bd.Position.Set(-36.2f, 2.0f);
				_leftWheel = _world.CreateBody(bd);
				_leftWheel.CreateShape(circ);
				_leftWheel.SetMassFromShapes();
			}

			{	// join wheels to chassis
				Vec2 anchor = new Vec2();
				RevoluteJointDef jd = new RevoluteJointDef();
				jd.Initialize(_vehicle, _leftWheel, _leftWheel.GetWorldCenter());
				jd.CollideConnected = false;
				jd.EnableMotor = true;
				jd.MaxMotorTorque = 10.0f;
				jd.MotorSpeed = 0.0f;
				_leftJoint = (RevoluteJoint)_world.CreateJoint(jd);

				jd.Initialize(_vehicle, _rightWheel, _rightWheel.GetWorldCenter());
				jd.CollideConnected = false;
				_rightJoint = (RevoluteJoint)_world.CreateJoint(jd);
			}

			{	// ground
				PolygonDef box = new PolygonDef();
				box.SetAsBox(19.5f, 0.5f);
				box.Friction = 0.62f;

				BodyDef bd = new BodyDef();
				bd.Position.Set(-25.0f, 1.0f);

				Body ground = _world.CreateBody(bd);
				ground.CreateShape(box);
			}

			{	// more ground
				PolygonDef box = new PolygonDef();
				BodyDef bd = new BodyDef();

				box.SetAsBox(9.5f, 0.5f, Vec2.Zero, 0.1f * Box2DX.Common.Settings.Pi);
				box.Friction = 0.62f;
				bd.Position.Set(27.0f - 30.0f, 3.1f);

				Body ground = _world.CreateBody(bd);
				ground.CreateShape(box);
			}

			{	// more ground
//.........这里部分代码省略.........
开发者ID:colgreen,项目名称:box2dx,代码行数:101,代码来源:Car.cs

示例12: InitPhysics

        public virtual void InitPhysics()
        {
            if (_physBody != null)
            {
                Log.Instance.Log("WARNING: Call to InitPhysics had no effect.  Actor has already had physics initialized.");
                return;
            }

            ShapeType shapeType = ShapeType.Box;
            Box2D.World physicsWorld = Angel.World.Instance.PhysicsWorld;

            ShapeDef shape;
            switch (shapeType)
            {
                case ShapeType.Box:
                    PolygonDef box = new PolygonDef();
                    box.SetAsBox(0.5f * Size.X, 0.5f * Size.Y);
                    shape = box;
                    break;
                case ShapeType.Circle:
                    CircleDef circle = new CircleDef();
                    circle.Radius = 0.5f * Size.X;
                    shape = circle;
                    break;
                default:
                    Log.Instance.Log("InitPhysics(): Invalid shape type given");
                    return;
            }

            shape.Density = _fDensity;
            shape.Friction = _fFriction;
            shape.Restitution = _fRestitution;
            shape.IsSensor = _bIsSensor;
            if (_iCollisionFlags != -1)
            {
                //shape->maskBits = (short)collisionFlags;
                //shape->categoryBits = (short)collisionFlags;
            }

            // InitShape( shape );

            BodyDef bodyDef = new BodyDef();
            bodyDef.UserData = this;
            bodyDef.Position = this.Position;
            bodyDef.Angle = MathHelper.ToRadians(-Rotation);
            bodyDef.FixedRotation = _bFixedRotation;

            _physBody = physicsWorld.CreateBody(bodyDef);
            _physBody.CreateShape(shape);
            _physBody.SetMassFromShapes();

            CustomInitPhysics();
        }
开发者ID:darrentorpey,项目名称:define_yourself,代码行数:53,代码来源:PhysicsActor.cs

示例13: LaunchBomb

		public void LaunchBomb()
		{
			if (_bomb != null)
			{
				_world.DestroyBody(_bomb);
				_bomb = null;
			}

			BodyDef bd = new BodyDef();
			bd.AllowSleep = true;
			bd.Position.Set(Box2DX.Common.Math.Random(-15.0f, 15.0f), 30.0f);
			bd.IsBullet = true;
			_bomb = _world.CreateBody(bd);
			_bomb.SetLinearVelocity(-5.0f * bd.Position);

			CircleDef sd = new CircleDef();
			sd.Radius = 0.3f;
			sd.Density = 20.0f;
			sd.Restitution = 0.1f;
			_bomb.CreateShape(sd);

			_bomb.SetMassFromShapes();
		}
开发者ID:colgreen,项目名称:box2dx,代码行数:23,代码来源:Test.cs

示例14: Biped

        public Biped(World w, Vec2 position)
        {
            m_world = w;

            BipedDef def = new BipedDef();
            BodyDef bd;

            // create body parts
            bd = def.LFootDef;
            bd.Position += position;
            LFoot = w.CreateBody(bd);
            LFoot.CreateShape(def.LFootPoly);
            LFoot.SetMassFromShapes();

            bd = def.RFootDef;
            bd.Position += position;
            RFoot = w.CreateBody(bd);
            RFoot.CreateShape(def.RFootPoly);
            RFoot.SetMassFromShapes();

            bd = def.LCalfDef;
            bd.Position += position;
            LCalf = w.CreateBody(bd);
            LCalf.CreateShape(def.LCalfPoly);
            LCalf.SetMassFromShapes();

            bd = def.RCalfDef;
            bd.Position += position;
            RCalf = w.CreateBody(bd);
            RCalf.CreateShape(def.RCalfPoly);
            RCalf.SetMassFromShapes();

            bd = def.LThighDef;
            bd.Position += position;
            LThigh = w.CreateBody(bd);
            LThigh.CreateShape(def.LThighPoly);
            LThigh.SetMassFromShapes();

            bd = def.RThighDef;
            bd.Position += position;
            RThigh = w.CreateBody(bd);
            RThigh.CreateShape(def.RThighPoly);
            RThigh.SetMassFromShapes();

            bd = def.PelvisDef;
            bd.Position += position;
            Pelvis = w.CreateBody(bd);
            Pelvis.CreateShape(def.PelvisPoly);
            Pelvis.SetMassFromShapes();

            bd = def.PelvisDef;
            bd.Position += position;
            Stomach = w.CreateBody(bd);
            Stomach.CreateShape(def.StomachPoly);
            Stomach.SetMassFromShapes();

            bd = def.ChestDef;
            bd.Position += position;
            Chest = w.CreateBody(bd);
            Chest.CreateShape(def.ChestPoly);
            Chest.SetMassFromShapes();

            bd = def.NeckDef;
            bd.Position += position;
            Neck = w.CreateBody(bd);
            Neck.CreateShape(def.NeckPoly);
            Neck.SetMassFromShapes();

            bd = def.HeadDef;
            bd.Position += position;
            Head = w.CreateBody(bd);
            Head.CreateShape(def.HeadCirc);
            Head.SetMassFromShapes();

            bd = def.LUpperArmDef;
            bd.Position += position;
            LUpperArm = w.CreateBody(bd);
            LUpperArm.CreateShape(def.LUpperArmPoly);
            LUpperArm.SetMassFromShapes();

            bd = def.RUpperArmDef;
            bd.Position += position;
            RUpperArm = w.CreateBody(bd);
            RUpperArm.CreateShape(def.RUpperArmPoly);
            RUpperArm.SetMassFromShapes();

            bd = def.LForearmDef;
            bd.Position += position;
            LForearm = w.CreateBody(bd);
            LForearm.CreateShape(def.LForearmPoly);
            LForearm.SetMassFromShapes();

            bd = def.RForearmDef;
            bd.Position += position;
            RForearm = w.CreateBody(bd);
            RForearm.CreateShape(def.RForearmPoly);
            RForearm.SetMassFromShapes();

            bd = def.LHandDef;
            bd.Position += position;
//.........这里部分代码省略.........
开发者ID:CaptBrick,项目名称:Playground,代码行数:101,代码来源:Biped.cs

示例15: AddToWorld

        public void AddToWorld()
        {
            body = world.CreateBody(bodyDef);
            foreach (ShapeDef shape in shapes)
                body.CreateShape(shape);
            body.SetMassFromShapes();
            body.SetUserData(this);

            foreach (Controller controller in controllers)
            {
                controller.AddBody(body);
                world.AddController(controller);
            }

            foreach (PhysicsObject child in children)
                child.AddToWorld();
        }
开发者ID:danielpcox,项目名称:Crisis-at-Swiss-Station,代码行数:17,代码来源:PhysicsObject.cs


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