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

C# Physics.Body类代码示例

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

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



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

示例1: SetSkinAndBody

 public override void SetSkinAndBody()
 {
     Body = new Body();
     Skin = new CollisionSkin(null);
     Skin.AddPrimitive(new JigLibX.Geometry.Plane(Vector3.Up, 0f), new MaterialProperties(0.2f, 0.7f, 0.6f));
     PhysicsSystem.CurrentPhysicsSystem.CollisionSystem.AddCollisionSkin(Skin);
 }
开发者ID:shakalandro,项目名称:3DTestGame,代码行数:7,代码来源:PlaneModel.cs


示例2: HeightMapModel

        // TODO: Need to add png parameter
        public HeightMapModel(Game game, Model m, Boolean t, Vector3 pos, float scale)
            : base(game, m, t, pos, scale, true)
        {
            Body = new Body(); // just a dummy. The PhysicObject uses its position to get the draw pos
            Skin = new CollisionSkin(null);

            HeightMapInfo heightMapInfo = this.model.Tag as HeightMapInfo;
            Array2D field = new Array2D(heightMapInfo.heights.GetUpperBound(0), heightMapInfo.heights.GetUpperBound(1));

            for (int x = 0; x < heightMapInfo.heights.GetUpperBound(0); x++)
            {
                for (int z = 0; z < heightMapInfo.heights.GetUpperBound(1); z++)
                {
                    field.SetAt(x, z, heightMapInfo.heights[x, z]);
                }
            }

            // move the body. The body (because its not connected to the collision
            // skin) is just a dummy. But the base class shoudl know where to
            // draw the model.
            Body.MoveTo(this.Position, Matrix.Identity);

            Skin.AddPrimitive(new Heightmap(field, 0f, 0f, 1, 1), new MaterialProperties(0.7f, 0.7f, 0.6f));

            PhysicsSystem.CurrentPhysicsSystem.CollisionSystem.AddCollisionSkin(this.Skin);
        }
开发者ID:shakalandro,项目名称:3DTestGame,代码行数:27,代码来源:HeightMapModel.cs


示例3: BoostController

 public BoostController(Body body, Vector3 force, Vector3 forcePos, Vector3 torque)
 {
     Body = body;
     Force = force;
     ForcePosition = forcePos;
     Torque = torque;
 }
开发者ID:colbybhearn,项目名称:3DPhysics,代码行数:7,代码来源:BoostController.cs


示例4: Gobject

 /// <summary>
 /// Default Constructor
 /// Initalizes the Body and a CollisionSkin
 /// No Primatives are added to the Body
 /// </summary>
 /// <param name="position">Initial Body Position</param>
 /// <param name="scale">Scale</param>
 public Gobject()
 {
     Body = new Body();
     Skin = new CollisionSkin(Body);
     Body.CollisionSkin = Skin;
     Body.ExternalData = this;
 }
开发者ID:colbybhearn,项目名称:3DPhysics,代码行数:14,代码来源:Gobject.cs


示例5: HeightmapObject

        public HeightmapObject(Game game, Model model,Vector2 shift)
            : base(game, model)
        {
            body = new Body(); // just a dummy. The PhysicObject uses its position to get the draw pos
            collision = new CollisionSkin(null);

            HeightMapInfo heightMapInfo = model.Tag as HeightMapInfo;
            Array2D field = new Array2D(heightMapInfo.heights.GetUpperBound(0), heightMapInfo.heights.GetUpperBound(1));

            for (int x = 0; x < heightMapInfo.heights.GetUpperBound(0); x++)
            {
                for (int z = 0; z < heightMapInfo.heights.GetUpperBound(1); z++)
                {
                    field.SetAt(x,z,heightMapInfo.heights[x,z]);
                }
            }

            // move the body. The body (because its not connected to the collision
            // skin) is just a dummy. But the base class shoudl know where to
            // draw the model.
            body.MoveTo(new Vector3(shift.X,0,shift.Y), Matrix.Identity);

            collision.AddPrimitive(new Heightmap(field, shift.X, shift.Y, 1, 1), new MaterialProperties(0.7f,0.7f,0.6f));

            PhysicsSystem.CurrentPhysicsSystem.CollisionSystem.AddCollisionSkin(collision);
        }
开发者ID:shakalandro,项目名称:3DTestGame,代码行数:26,代码来源:HeightmapObject.cs


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


示例7: ToXNA

 public static Matrix ToXNA(Body body, Transform transform)
 {
     Vector3 rot = transform.GetRotation();
     Matrix mat = body.Orientation * Matrix.CreateRotationY(rot.Y);
     mat.Translation = body.Position;
     return mat;
 }
开发者ID:MattVitelli,项目名称:IslandAdventure,代码行数:7,代码来源:JitterConverter.cs


示例8: Initialise

        public override void Initialise()
        {
            base.Initialise();

            // Create new bodey and collision skin
            m_Body = new Body();
            m_Skin = new CollisionSkin(m_Body);

            if (m_Body != null)
            {
                // Set skin to the body
                m_Body.CollisionSkin = m_Skin;

                // Check the skin was successfully created and add this 
                // custom dice as a primitive to the collision skin
                if (m_Skin != null)
                {
                    Box box = new Box(Vector3.Zero, Matrix.Identity, transform.Scale);
                    m_Skin.AddPrimitive(box, (int)MaterialTable.MaterialID.BouncyNormal);

                    // Set mass
                    m_Mass = SetMass(1.0f);

                    // Move the body to correct position initially
                    m_Body.MoveTo(transform.Position, Matrix.Identity);

                    // Apply transform to skin
                    m_Skin.ApplyLocalTransform(new JigLibX.Math.Transform(-m_Mass, Matrix.Identity));

                    // Enable body
                    EnableBody();
                }
            }
        }
开发者ID:Imortilize,项目名称:Psynergy-Engine,代码行数:34,代码来源:CustomDiceJibLibX.cs


示例9: Setup

        void Setup(HeightMapInfo heightMapInfo, Vector2 shift)
        {
            // A dummy. The physics object uses its position to get draw pos
            Body = new Body();

            CollisionSkin = new CollisionSkin(null);

            info = heightMapInfo;
            Array2D field = new Array2D(heightMapInfo.Heights.GetUpperBound(0), heightMapInfo.Heights.GetUpperBound(1));

            for (int x = 0; x < heightMapInfo.Heights.GetUpperBound(0); ++x)
            {
                for (int z = 0; z < heightMapInfo.Heights.GetUpperBound(1); ++z)
                {
                    field.SetAt(x, z, heightMapInfo.Heights[x, z]);
                }
            }

            // Move dummy body. The body isn't connected to the collision skin.
            // But the base class should know where to draw the model.
            Body.MoveTo(new Vector3(shift.X, 0, shift.Y), Matrix.Identity);

            CollisionSkin.AddPrimitive(new Heightmap(field, shift.X, shift.Y, 1, 1), new MaterialProperties(0.7f, 0.7f, 0.6f));

            PhysicsSystem.CurrentPhysicsSystem.CollisionSystem.AddCollisionSkin(CollisionSkin);
        }
开发者ID:JllyGrnGiant,项目名称:game_demo,代码行数:26,代码来源:HeightMapObject.cs


示例10: HeightmapObject

        public HeightmapObject(Model model,Vector2 shift, Vector3 position)
            : base()
        {
            Body = new Body(); // just a dummy. The PhysicObject uses its position to get the draw pos
            Skin = new CollisionSkin(null);

            HeightMapInfo heightMapInfo = model.Tag as HeightMapInfo;
            Array2D field = new Array2D(heightMapInfo.heights.GetLength(0), heightMapInfo.heights.GetLength(1));

            for (int x = 0; x < heightMapInfo.heights.GetLength(0); x++)
            {
                for (int z = 0; z < heightMapInfo.heights.GetLength(1); z++)
                {
                    field.SetAt(x,z,heightMapInfo.heights[x,z]);
                }
            }

            // move the body. The body (because its not connected to the collision
            // skin) is just a dummy. But the base class shoudl know where to
            // draw the model.
            Body.MoveTo(new Vector3(shift.X,0,shift.Y), Matrix.Identity);

            Skin.AddPrimitive(new Heightmap(field, shift.X, shift.Y, heightMapInfo.terrainScale, heightMapInfo.terrainScale), new MaterialProperties(0.7f, 0.7f, 0.6f));

            PhysicsSystem.CurrentPhysicsSystem.CollisionSystem.AddCollisionSkin(Skin);
            CommonInit(position, new Vector3(1,1,1), model, false, 0);
        }
开发者ID:colbybhearn,项目名称:3DPhysics,代码行数:27,代码来源:HeightmapObject.cs


示例11: DisableCollisions

 private void DisableCollisions(Body rb0, Body rb1)
 {
     if ((rb0.CollisionSkin == null) || (rb1.CollisionSkin == null))
         return;
     rb0.CollisionSkin.NonCollidables.Add(rb1.CollisionSkin);
     rb1.CollisionSkin.NonCollidables.Add(rb0.CollisionSkin);
 }
开发者ID:MattVitelli,项目名称:Nosferatu,代码行数:7,代码来源:Ragdoll.cs


示例12: HeightMapModel2

        public HeightMapModel2(Game game, HeightMap info, Boolean t, Vector3 pos, float scale)
            : base(game , null, t, pos, scale)
        {
            // Game game, Model m, Boolean t, Vector3 pos, float scale, Boolean solid
            //Game game, HeightMap m, Boolean t, Vector3 pos, float scale

            this.Visible = false;
            Body = new Body();
            Skin = new CollisionSkin(null);
            //Skin.CollisionType = (int)CollisionTypes.Terrain;

            Array2D field = new Array2D(info.heights.GetUpperBound(0), info.heights.GetUpperBound(1));

            for (int x = 0; x < info.heights.GetUpperBound(0); x++)
            {
                for (int z = 0; z < info.heights.GetUpperBound(1); z++)
                {
                    field.SetAt(x, z, info.heights[x, z]);
                }
            }

            Body.MoveTo(new Vector3(info.heightmapPosition.X, info.heightmapPosition.Y, info.heightmapPosition.Y), Matrix.Identity);

            Skin.AddPrimitive(new Heightmap(field, info.heightmapPosition.X, info.heightmapPosition.Y, scale, scale), (int)MaterialTable.MaterialID.NotBouncyRough);

            Body.Immovable = true;

            PhysicsSystem.CurrentPhysicsSystem.CollisionSystem.AddCollisionSkin(Skin);
        }
开发者ID:shakalandro,项目名称:3DTestGame,代码行数:29,代码来源:HeightMapModel2.cs


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


示例14: Gobject

        private bool CollidedRecently = true; // we want the object to update immediately once created

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Default Constructor
        /// Initalizes the Body and a CollisionSkin
        /// No Primatives are added to the Body
        /// </summary>
        /// <param name="position">Initial Body Position</param>
        /// <param name="scale">Scale</param>
        public Gobject()
        {
            Body = new Body();
            Skin = new CollisionSkin(Body);
            Body.CollisionSkin = Skin;
            Body.ExternalData = this;
            Body.CollisionSkin.callbackFn += new CollisionCallbackFn(CollisionSkin_callbackFn);
        }
开发者ID:colbybhearn,项目名称:3DPhysics,代码行数:21,代码来源:Gobject.cs


示例15: PlaneObject

 public PlaneObject(Game game, Model model, float d)
     : base(game, model)
 {
     body = new Body();
     collision = new CollisionSkin(null);
     collision.AddPrimitive(new JigLibX.Geometry.Plane(Vector3.Up, d), new MaterialProperties(0.2f, 0.7f, 0.6f));
     PhysicsSystem.CurrentPhysicsSystem.CollisionSystem.AddCollisionSkin(collision);
 }
开发者ID:sikora507,项目名称:OpenC1,代码行数:8,代码来源:PlaneObject.cs


示例16: PlaneObject

 public PlaneObject(Model model,float d, Vector3 position, int asset)
     : base()
 {
     Body = new Body();
     Skin = new CollisionSkin(null);
     Skin.AddPrimitive(new JigLibX.Geometry.Plane(Vector3.Up, d), new MaterialProperties(0.2f, 0.7f, 0.6f));
     PhysicsSystem.CurrentPhysicsSystem.CollisionSystem.AddCollisionSkin(Skin);
     CommonInit(position, new Vector3(1,1,1), model, false, asset);
 }
开发者ID:colbybhearn,项目名称:3DPhysics,代码行数:9,代码来源:PlaneObject.cs


示例17: Weapon

 public Weapon(string modelName, Body body, Transform transform, Scene scene)
 {
     this.ignorePred = new IgnoreSkinPredicate(body);
     this.scene = scene;
     this.fpsModel = new ViewModel(modelName);
     fpsModel.SetTransform(transform);
     Matrix weaponTransform = Matrix.CreateScale(0.1f) * Matrix.CreateRotationX(-MathHelper.PiOver2) * Matrix.CreateRotationY(MathHelper.PiOver2);
     fpsModel.SetCustomMatrix(weaponTransform);
     fpsModel.GetAnimationLayer().SetActiveAnimation("Pistol_Idle", true);//.SetAnimationLayer("Pistol_Idle", 1);
 }
开发者ID:MattVitelli,项目名称:IslandAdventure,代码行数:10,代码来源:Weapon.cs


示例18: Setup

 // Setup everything
 void Setup()
 {
     // We can't use InitializeBody() here because we want to add a
     // plane and not have it fall
     Body = new Body();
     CollisionSkin = new CollisionSkin(null);
     CollisionSkin.AddPrimitive(
         new JigLibX.Geometry.Plane(Vector3.Up, 0.0f),
         new MaterialProperties(0.2f, 0.7f, 0.6f));
     PhysicsSystem.CurrentPhysicsSystem.CollisionSystem.AddCollisionSkin(CollisionSkin);
 }
开发者ID:JllyGrnGiant,项目名称:game_demo,代码行数:12,代码来源:PlaneObject.cs


示例19: Initialize

        public virtual void Initialize(Body body)
        {
            EnableController();
            m_Body = body;

            if (m_Body != null)
            {
                // Update downwards force ( mass based )
                //m_ConstantForces = (Vector3.Down * m_Body.Mass * 100);
            }
        }
开发者ID:Imortilize,项目名称:Psynergy-Engine,代码行数:11,代码来源:PhysicsController.cs


示例20: ZoneObject

 public ZoneObject(string id, ObjectType objectType,
     Transform3D transform, Effect effect, Color color, float alpha, bool isImpenetrable)
     : base(id, objectType, transform, effect, color, alpha)
 {
     //set body and skin for this zone
     this.body = new Body();
     this.body.ExternalData = this;
     this.collision = new CollisionSkin(this.body);
     this.body.CollisionSkin = this.collision;
     this.isImpenetrable = isImpenetrable; //we cant move through it
 }
开发者ID:SongmanW,项目名称:Group-Project-2016-Team-Magia,代码行数:11,代码来源:ZoneObject.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Jint.Engine类代码示例发布时间:2022-05-26
下一篇:
C# Geometry.Segment类代码示例发布时间: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