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


C# RigidBody.SetMassProperties方法代码示例

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


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

示例1: AddGround

        //protected CarObject car = null;
        public void AddGround(bool solid)
        {
            if (solid)
            {
                ground = new RigidBody(new BoxShape(3600, 1f));
                //ground.SetMassProperties(float.MaxValue, float.MaxValue, false);
                ground.Position = new JVector(0, 0);
                ground.IsStatic = true;
                Demo.World.AddBody(ground);
                ground.Material.DynamicFriction = 1.0f;
                ground.Material.StaticFriction = 1.0f;
                ground.Material.Restitution = 0.0f;
            }
            else
            {
                List<JVector> groundLine = new List<JVector> { new JVector(-40f, 0f), new JVector(40f, 0f) };

                ground = new RigidBody(new BoxShape(new JVector(1.0f, 1.0f)));
                ground.Position = new JVector(0, -10);
                ground.Orientation = 0;
                ground.IsStatic = true;
                ground.SetMassProperties(float.MaxValue, float.MaxValue, false);
                Demo.World.AddBody(ground);
                ground.Material.DynamicFriction = 1.0f;
                ground.Material.Restitution = 0.0f;
            }
        }
开发者ID:reidyd,项目名称:jitterphysics,代码行数:28,代码来源:Scene.cs

示例2: createBody

        private void createBody()
        {
            //ToDo: set the size in a more adjustable way.
            body = new RigidBody(new BoxShape(1.0f, 0.5f, 0.5f));
            body.Position = new JVector(Position3.X, Position3.Y, Position3.Z);

            JMatrix innertia = JMatrix.Identity;
            body.SetMassProperties(innertia, 1, true);
            body.IsActive = true;
            body.AffectedByGravity = true;
        }
开发者ID:jpires,项目名称:gta2net,代码行数:11,代码来源:Pedestrian.cs

示例3: Update

        protected override void Update(GameTime gameTime)
        {
            GamePadState padState = GamePad.GetState(PlayerIndex.One);
            KeyboardState keyState = Keyboard.GetState();
            MouseState mouseState = Mouse.GetState();

            // let the user escape the demo
            if (PressedOnce(Keys.Escape, Buttons.Back)) this.Exit();

            // change threading mode
            if (PressedOnce(Keys.M, Buttons.A)) multithread = !multithread;

            #region drag and drop physical objects with the mouse
            if (mouseState.LeftButton == ButtonState.Pressed &&
                mousePreviousState.LeftButton == ButtonState.Released)
            {

            }

            if (mouseState.LeftButton == ButtonState.Pressed)
            {

            }
            else
            {

            }
            #endregion

            #region create random primitives
            Random r = new Random();

            if (keyState.IsKeyDown(Keys.Space) && !keyboardPreviousState.IsKeyDown(Keys.Space))
            {
                //RigidBody body = new RigidBody(new CapsuleShape(2, 0.5f))
                var pointList = new List<JVector>();
                //var a = 0f;
                //for (int i = 0; i < 18; i++)
                //{
                //    pointList.Add(new JVector((float)Math.Sin(a) * 2f, (float)Math.Cos(a) * 2f));
                //    a += 0.34906585f;
                //}
                Random rand = new Random();
                for (int i = 0; i < rand.Next(50, 100); i++)
                {
                    pointList.Add(new JVector((float)rand.NextDouble() * 2f - 1f, (float)rand.NextDouble() * 2f - 1f));
                }

                //RigidBody body = new RigidBody(new ConvexHullShape(pointList))
                RigidBody body = new RigidBody(new CapsuleShape(2, 0.5f))
                {
                    EnableDebugDraw = true,
                    //Position = new JVector((float)rand.NextDouble(), 0),
                    AngularVelocity = 0,
                    LinearVelocity = new JVector(0, -1),
                    Orientation = 0.001f + (float)rand.NextDouble(),
                    Material = new Material()
                    {
                        DynamicFriction = 1f,
                        StaticFriction = 1f,
                        Restitution = 0f,
                    },
                };
                World.AddBody(body);

                body.SetMassProperties(1, 1, false);
            }
            #endregion

            #region switch through physic scenes
            if (PressedOnce(Keys.Add, Buttons.X))
            {
                DestroyCurrentScene();
                currentScene++;
                currentScene = currentScene % PhysicScenes.Count;
                PhysicScenes[currentScene].Build();
            }

            if (PressedOnce(Keys.Subtract, Buttons.Y))
            {
                DestroyCurrentScene();
                currentScene += PhysicScenes.Count - 1;
                currentScene = currentScene % PhysicScenes.Count;
                PhysicScenes[currentScene].Build();
            }
            #endregion

            UpdateDisplayText(gameTime);

            float step = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (step > 1.0f / 100.0f) step = 1.0f / 100.0f;
            World.Step(step, false);

            gamePadPreviousState = padState;
            keyboardPreviousState = keyState;
            mousePreviousState = mouseState;

            base.Update(gameTime);
        }
开发者ID:jumonb,项目名称:hideandsneeze,代码行数:100,代码来源:JitterDemo.cs


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