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


C# Body.EnableBody方法代码示例

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


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

示例1: BowlingPin

        public BowlingPin(Game game, Model model, Matrix orientation, Vector3 position)
            : base(game, model)
        {
            body = new Body();
            collision = new CollisionSkin(body);

            // add a capsule for the main corpus
            Primitive capsule = new Capsule(Vector3.Zero, Matrix.Identity, 0.1f, 1.3f);
            // add a small box at the buttom
            Primitive box = new Box(new Vector3(-0.1f,-0.1f,-0.1f), Matrix.Identity, Vector3.One * 0.2f);
            // add a sphere in the middle
            Primitive sphere = new Sphere(new Vector3(0.0f, 0.0f, 0.3f), 0.3f);

            collision.AddPrimitive(capsule, new MaterialProperties(0.1f, 0.5f, 0.5f));
            collision.AddPrimitive(box, new MaterialProperties(0.1f, 0.5f, 0.5f));
            collision.AddPrimitive(sphere, new MaterialProperties(0.1f, 0.5f, 0.5f));

            body.CollisionSkin = this.collision;
            Vector3 com = SetMass(0.5f);

            body.MoveTo(position, orientation);
            collision.ApplyLocalTransform(new Transform(-com, Matrix.Identity));

            body.EnableBody();
            this.scale = Vector3.One * 10.0f;
        }
开发者ID:shakalandro,项目名称:3DTestGame,代码行数:26,代码来源:BowlingPin.cs

示例2: Missile

        public Missile(ParentGame game, Model modelObj, Texture2D[] modelTextures, DrawingClass drawClass, GameplayScreen Screen)
            : base(game, modelObj, modelTextures)
        {
            this.drawClass = drawClass;
            this.Screen = Screen;

            _body = new Body();
            _skin = new CollisionSkin(_body);
            _body.CollisionSkin = _skin;

            Box box = new Box(Vector3.Zero, Matrix.Identity, new Vector3(1f,1f,4f));
            _skin.AddPrimitive(box, new MaterialProperties(0.8f, 0.8f, 0.7f));

            Vector3 com = SetMass(2.0f);

            _body.MoveTo(position, Matrix.Identity);
            _skin.ApplyLocalTransform(new Transform(-com, Matrix.Identity));
            _body.EnableBody();

            Body.ExternalData = this;

            Vector3 pos = position;
            Vector3 forwardVec = Body.Orientation.Forward;
            forwardVec.Normalize();

            pos -= forwardVec * 10;
            // Use the particle emitter helper to output our trail particles.
            trailEmitter = new ParticleEmitter(drawClass.projectileTrailParticles,
                                               trailParticlesPerSecond, position);

            rgob = new RagdollObject(parentGame, null, null, null, RagdollObject.RagdollType.Simple, 1.0f, 3);
            rgob.Position = position;
            //rgob.PutToSleep();

            //rgob.limbs[0].PhysicsBody.AngularVelocity = (new Vector3(1, 1, 0) * 2000);

            RagdollTransforms = new List<Matrix>();

            RagdollTransforms = rgob.GetWorldMatrix();

            foreach (JigLibX.Objects.PhysicObject lim in rgob.limbs)
                DisableCollisions(lim.PhysicsBody, Body);

            foreach (JigLibX.Objects.PhysicObject lim in rgob.limbs)
                foreach (BuildingPiece pic in Screen.PieceList)
                    DisableCollisions(lim.PhysicsBody, pic.Body);

            foreach (JigLibX.Objects.PhysicObject lim in rgob.limbs)
                foreach (Building bld in Screen.Buildings)
                    DisableCollisions(lim.PhysicsBody, bld.Body);

            foreach (JigLibX.Objects.PhysicObject lim in rgob.limbs)
                DisableCollisions(lim.PhysicsBody, Screen.terrainActor.Body);

            foreach (JigLibX.Objects.PhysicObject limb0 in rgob.limbs)
                foreach (Missile mis in Screen.BulletList)
                    foreach (JigLibX.Objects.PhysicObject limb1 in mis.rgob.limbs)
                        DisableCollisions(limb1.PhysicsBody, limb0.PhysicsBody);
        }
开发者ID:alittle1234,项目名称:XNA_Project,代码行数:59,代码来源:Missile.cs

示例3: SphereObject

 public SphereObject(Game game, Model model,float radius, Matrix orientation, Vector3 position)
     : base(game, model)
 {
     body = new Body();
     collision = new CollisionSkin(body);
     collision.AddPrimitive(new Sphere(Vector3.Zero * 5.0f,radius), new MaterialProperties(0.5f,0.7f,0.6f));
     body.CollisionSkin = this.collision;
     Vector3 com = SetMass(10.0f);
     body.MoveTo(position + com, orientation);
        // collision.ApplyLocalTransform(new Transform(-com, Matrix.Identity));
     body.EnableBody();
     this.scale = Vector3.One * radius;
 }
开发者ID:shakalandro,项目名称:3DTestGame,代码行数:13,代码来源:SphereObject.cs

示例4: BoxObject

        public BoxObject(Game game,Model model,Vector3 sideLengths, Matrix orientation, Vector3 position)
            : base(game,model)
        {
            body = new Body();
            collision = new CollisionSkin(body);

            collision.AddPrimitive(new Box(- 0.5f * sideLengths, orientation, sideLengths), new MaterialProperties(0.8f, 0.8f, 0.7f));
            body.CollisionSkin = this.collision;
            Vector3 com = SetMass(1.0f);
            body.MoveTo(position, Matrix.Identity);
            collision.ApplyLocalTransform(new Transform(-com, Matrix.Identity));
            body.EnableBody();
            this.scale = sideLengths;
        }
开发者ID:alittle1234,项目名称:XNA_Project,代码行数:14,代码来源:BoxObject.cs

示例5: CapsuleObject

        public CapsuleObject(Game game, Model model,float radius,float length, Matrix orientation, Vector3 position)
            : base(game, model)
        {
            body = new Body();
            collision = new CollisionSkin(body);
            collision.AddPrimitive(new Capsule(Vector3.Transform(new Vector3(-0.5f,0,0), orientation),orientation,radius,length),(int)MaterialTable.MaterialID.BouncyNormal);
            body.CollisionSkin = this.collision;
            Vector3 com = SetMass(10.0f);
            body.MoveTo(position + com, Matrix.Identity);

            collision.ApplyLocalTransform(new Transform(-com,Matrix.Identity));

            body.EnableBody();
            this.scale = new Vector3(radius, radius, length / 2);
        }
开发者ID:shakalandro,项目名称:3DTestGame,代码行数:15,代码来源:CapsuleObject.cs

示例6: CylinderObject

        public CylinderObject(Game game, float radius, float length, Vector3 position, Model model)
            : base(game, model)
        {
            body = new Body();
            collision = new CollisionSkin(body);

            if (length - 2.0f * radius < 0.0f)
                throw new ArgumentException("Radius must be at least half length");

            Capsule middle = new Capsule(Vector3.Zero, Matrix.Identity, radius, length - 2.0f * radius);

            float sideLength = 2.0f * radius / (float) Math.Sqrt(2.0d);

            Vector3 sides = new Vector3(-0.5f * sideLength, -0.5f * sideLength, -radius);

            Box supply0 = new Box(sides, Matrix.Identity,
                new Vector3(sideLength, sideLength, length));

            Box supply1 = new Box(Vector3.Transform(sides,Matrix.CreateRotationZ(MathHelper.PiOver4)),
                Matrix.CreateRotationZ(MathHelper.PiOver4), new Vector3(sideLength, sideLength, length));

            collision.AddPrimitive(middle, new MaterialProperties(0.8f, 0.8f, 0.7f));
            collision.AddPrimitive(supply0, new MaterialProperties(0.8f, 0.8f, 0.7f));
            collision.AddPrimitive(supply1, new MaterialProperties(0.8f, 0.8f, 0.7f));

            body.CollisionSkin = this.collision;

            Vector3 com = SetMass(1.0f);
            collision.ApplyLocalTransform(new Transform(-com, Matrix.Identity));

            #region Manually set body inertia
            float cylinderMass = body.Mass;

            float comOffs = (length - 2.0f * radius) * 0.5f; ;

            float Ixx = 0.5f * cylinderMass * radius * radius + cylinderMass * comOffs * comOffs;
            float Iyy = 0.25f * cylinderMass * radius * radius + (1.0f / 12.0f) * cylinderMass * length * length + cylinderMass * comOffs * comOffs;
            float Izz = Iyy;

            body.SetBodyInertia(Ixx, Iyy, Izz);
            #endregion

            body.MoveTo(position, Matrix.CreateRotationX(MathHelper.PiOver2));

            body.EnableBody();

            this.scale = new Vector3(radius, radius, length * 0.5f);
        }
开发者ID:tuannsofta,项目名称:kinect4bag,代码行数:48,代码来源:CylinderObject.cs

示例7: Cuboid

      public Cuboid(Vector dimension)
      {
         Dimension = dimension;

         PhysicsBody = new Body();
         collisionSkin = new CollisionSkin(PhysicsBody);
         PhysicsBody.CollisionSkin = collisionSkin;

         var box = new Box(Vector3.Zero, Microsoft.Xna.Framework.Matrix.Identity, Dimension.ToXna());
         collisionSkin.AddPrimitive(box, new MaterialProperties(0.1f, 0.4f, 0.9f));
         
         var com = ApplyMass(1.0f);
         //  PhysicsBody.MoveTo(Utils.VectorBalderToXna(this.Position), Microsoft.Xna.Framework.Matrix.Identity);
         collisionSkin.ApplyLocalTransform(new JigLibX.Math.Transform(-com, Microsoft.Xna.Framework.Matrix.Identity));
         PhysicsBody.EnableBody();
      }
开发者ID:amoldeshpande,项目名称:slartoolkit,代码行数:16,代码来源:Cuboid.cs

示例8: BuildingPiece

        public BuildingPiece(ParentGame game, Model modelObj, Texture2D[] modelTextures,
            DrawingClass drawClass, GameplayScreen Screen, float Length, float Width, float Height)
            : base(game, modelObj, modelTextures)
        {
            // Use the particle emitter helper to output our trail particles.
            trailEmitter = new ParticleEmitter(drawClass.smokePlumeParticles,
                                               3, position);

            fireEmitter = new ParticleEmitter(drawClass.fireParticles,
                                               30, position);

            this.Screen = Screen;
            this.drawClass = drawClass;

            _body = new Body();
            _skin = new CollisionSkin(_body);
            _body.CollisionSkin = _skin;

            //Box box = new Box(Vector3.Zero, Matrix.Identity, new Vector3(10f, 7f, 7f));
            Box box = new Box(Vector3.Zero, Matrix.Identity, new Vector3(Length, Width, Height));
            if (Length > Width && Length > Height)
                boundSphere.Radius = Length;
            else if (Width > Length && Width > Height)
                boundSphere.Radius = Width;
            else
                boundSphere.Radius = Height;
            _skin.AddPrimitive(box, new MaterialProperties(0.8f, 0.8f, 0.7f));

            Vector3 com = SetMass(3.0f);

            _body.MoveTo(position, Matrix.Identity);
            _skin.ApplyLocalTransform(new Transform(-com, Matrix.Identity));
            _body.EnableBody();

            Body.ExternalData = this;

            SetBody(rotation);

            Body.AllowFreezing = true;
            Body.SetDeactivationTime(1);

            foreach (BuildingPiece pic in Screen.PieceList)
                DisableCollisions(this.Body, pic.Body);

            foreach (Building bld in Screen.Buildings)
                DisableCollisions(this.Body, bld.Body);
        }
开发者ID:alittle1234,项目名称:XNA_Project,代码行数:47,代码来源:BuildingPiece.cs

示例9: BoxActor

        public BoxActor(Game game, Vector3 position, Vector3 scale)
            : base(game)
        {
            this.position = position;
            this.scale = scale;
            _body = new Body();
            _skin = new CollisionSkin(_body);
            _body.CollisionSkin = _skin;

            Box box = new Box(Vector3.Zero, Matrix.Identity, scale);
            _skin.AddPrimitive(box, new MaterialProperties(0.8f, 0.8f, 0.7f));

            Vector3 com = SetMass(1.0f);

            _body.MoveTo(position, Matrix.Identity);
            _skin.ApplyLocalTransform(new JigLibX.Math.Transform(-com, Matrix.Identity));
            _body.EnableBody();
        }
开发者ID:Cnidarias,项目名称:dreidengine,代码行数:18,代码来源:BoxActor.cs

示例10: GameObject

        public GameObject(Game game, Vector3 pos, Vector3 rot, Model model, bool textured, Matrix[] transforms, float scale , bool immovable)
            : base(game)
        {
            m_GOPos = pos;
            m_GORot = rot;
            m_GOModel = model;
            m_GOModelTransforms = transforms;
            m_GOScale = scale;
            m_textured = textured;
            m_body = new Body();
            m_body.Immovable = immovable;
            m_body.Position = pos;

            this.m_skin = new CollisionSkin(m_body);
            this.m_body.CollisionSkin = this.m_skin;

            this.m_body.MoveTo(this.m_GOPos, Matrix.Identity);
            m_body.EnableBody();
        }
开发者ID:kaoabi,项目名称:GP3_CourseworkGame,代码行数:19,代码来源:GameObject.cs

示例11: TestObject

        public TestObject(Game game,Model model)
            : base(game,model)
        {
            body = new Body();
            collision = new CollisionSkin(body);

            Box boxMiddle = new Box(new Vector3(-3, 0 ,-0.5f), Matrix.Identity, new Vector3(6,1,1));
            Box boxLeft = new Box(new Vector3(-3, -3f, -0.5f), Matrix.Identity, new Vector3(1, 4, 1));
            Box boxRight = new Box(new Vector3(2, -3f, -0.5f), Matrix.Identity, new Vector3(1, 4, 1));

            collision.AddPrimitive(boxMiddle, new MaterialProperties(0.2f, 0.7f, 0.6f));
            collision.AddPrimitive(boxLeft, new MaterialProperties(0.2f, 0.7f, 0.6f));
            collision.AddPrimitive(boxRight, new MaterialProperties(0.2f, 0.7f, 0.6f));

            body.CollisionSkin = this.collision;

            Vector3 com = SetMass(1.0f);
               // collision.ApplyLocalTransform(new Transform(-com, Matrix.Identity));

            body.MoveTo(Vector3.Up * 10, Matrix.Identity);

            //body.Immovable = true;
            body.EnableBody();
        }
开发者ID:shakalandro,项目名称:3DTestGame,代码行数:24,代码来源:TestObject.cs

示例12: InitializeBody

 /// <summary>
 /// The body needs to initialization for it to have physical properties.
 /// </summary>
 protected void InitializeBody()
 {
     Body = new Body();
     CollisionSkin = new CollisionSkin(Body);
     Body.CollisionSkin = this.CollisionSkin;
     Body.EnableBody();  // Enable the body such that it can have a physical reaction to things.
 }
开发者ID:alt234,项目名称:CEngine,代码行数:10,代码来源:PhysicsObject.cs

示例13: Initialize

        public override void Initialize()
        {
            Body = new Body();
            Skin = new CollisionSkin(Body);
            Body.CollisionSkin = Skin;

            radius = 12;
            float length = 3;

            //Capsule middle = new Capsule(Vector3.Zero, Matrix.Identity, radius, length - 2.0f * radius);

            float sideLength = 2.0f * radius / (float)Math.Sqrt(2.0d);

            Vector3 sides = new Vector3(-0.5f * sideLength, -0.5f * sideLength, -radius);

            Box supply0 = new Box(sides, Matrix.Identity,
                new Vector3(sideLength, sideLength, length));

            Box supply1 = new Box(Vector3.Transform(sides, Matrix.CreateRotationZ(MathHelper.PiOver4)),
                Matrix.CreateRotationZ(MathHelper.PiOver4), new Vector3(sideLength, sideLength, length));

            Box supply2 = new Box(Vector3.Transform(sides, Matrix.CreateRotationZ( (MathHelper.PiOver4 * 0.5f) )),
                Matrix.CreateRotationZ( (MathHelper.PiOver4 * 0.5f) ), new Vector3(sideLength, sideLength, length));

            Box supply3 = new Box(Vector3.Transform(sides, Matrix.CreateRotationZ((MathHelper.PiOver4 * 1.5f))),
                Matrix.CreateRotationZ((MathHelper.PiOver4 * 1.5f)), new Vector3(sideLength, sideLength, length));

            //Skin.AddPrimitive(middle, new MaterialProperties(0.8f, 0.8f, 0.7f));
            Skin.AddPrimitive(supply0, new MaterialProperties(0.8f, 0.8f, 0.7f));
            Skin.AddPrimitive(supply1, new MaterialProperties(0.8f, 0.8f, 0.7f));
            Skin.AddPrimitive(supply2, new MaterialProperties(0.8f, 0.8f, 0.7f));
            Skin.AddPrimitive(supply3, new MaterialProperties(0.8f, 0.8f, 0.7f));

            Vector3 com = SetMass(1.0f);

            Body.MoveTo(position, Matrix.Identity);
            Skin.ApplyLocalTransform(new Transform(-com, Matrix.Identity));

            #region Manually set body inertia
            float cylinderMass = Body.Mass;

            float comOffs = (length - 2.0f * radius) * 0.5f; ;

            float Ixx = 0.5f * cylinderMass * radius * radius + cylinderMass * comOffs * comOffs;
            float Iyy = 0.25f * cylinderMass * radius * radius + (1.0f / 12.0f) * cylinderMass * length * length + cylinderMass * comOffs * comOffs;
            float Izz = Iyy;

            Body.SetBodyInertia(Ixx, Iyy, Izz);
            #endregion

            Body.EnableBody();

            Body.ExternalData = this;

            SetBody(rotation);
        }
开发者ID:alittle1234,项目名称:XNA_Project,代码行数:56,代码来源:Ring.cs

示例14: PlayerPhysicsObject

        public PlayerPhysicsObject(Vector3 size, Matrix orientation, Vector3 pos)
        {
            body = new Body();
            collision = new CollisionSkin(body);

            collision.AddPrimitive(new Sphere(pos, size.Y), (int)MaterialTable.MaterialID.NotBouncyNormal);

            body.CollisionSkin = this.collision;

            Vector3 com = SetMass(1.0f);
            body.MoveTo(pos, Matrix.Identity);
            collision.ApplyLocalTransform(new Transform(-com, Matrix.Identity));
            body.EnableBody();

            //body.SetBodyInvInertia(0.0f, 0.0f, 0.0f);
            body.AllowFreezing = false;
        }
开发者ID:Bunkerbewohner,项目名称:Towers,代码行数:17,代码来源:PlayerPhysicsObject.cs

示例15: Initialize

        public virtual void Initialize()
        {
            _body = new Body();
            _skin = new CollisionSkin(_body);
            _body.CollisionSkin = _skin;

            // l w h
            //Box box = new Box(Vector3.Zero, Matrix.Identity, new Vector3(9f, 9f, 39f));
            //if (Type == "DEPOT")
            //    box = new Box(Vector3.Zero, Matrix.Identity, new Vector3(20, 15, 11f));

            Box box = new Box(Vector3.Zero, Matrix.Identity, new Vector3(9f, 39f, 9f));
            boundSphere.Radius = 39;
            if (Type == "DEPOT")
            {
                box = new Box(Vector3.Zero, Matrix.Identity, new Vector3(20, 11, 15f));
                boundSphere.Radius = 20;
            }

            _skin.AddPrimitive(box, new MaterialProperties(1, 1, 1));

            Vector3 com = SetMass(1);

            //_body.MoveTo(position, Matrix.Identity);
            _skin.ApplyLocalTransform(new Transform(-com, Matrix.Identity));
            _body.EnableBody();

            Body.ExternalData = this;

            SetBody(rotation);

            DisableCollisions(Screen.terrainActor.Body, Body);
        }
开发者ID:alittle1234,项目名称:XNA_Project,代码行数:33,代码来源:Building.cs


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