示例#1
0
 public void StepSimulation(float stepSizeInSeconds)
 {
     if (CharacterProxy != null)
     {
         CharacterProxy.PosX    = m_posX;
         CharacterProxy.PosY    = m_posY;
         CharacterProxy.Jump    = m_jump; m_jump = false;
         CharacterProxy.Gravity = m_gravity;
         CharacterProxy.StepSimulation(stepSizeInSeconds);
     }
     if (CharacterRigidBody != null)
     {
         CharacterRigidBody.PosX    = m_posX;
         CharacterRigidBody.PosY    = m_posY;
         CharacterRigidBody.Jump    = m_jump; m_jump = false;
         CharacterRigidBody.Gravity = m_gravity;
         CharacterRigidBody.Speed   = Speed;
         CharacterRigidBody.StepSimulation(stepSizeInSeconds);
         CharacterRigidBody.Elevate = Elevate;
         Supported      = CharacterRigidBody.Supported;
         GroundVelocity = CharacterRigidBody.GroundVelocity;
     }
 }
示例#2
0
        public void StepSimulation(float stepSizeInSeconds)
        {
            if (CharacterProxy != null)
            {
                CharacterProxy.PosX    = m_posX;
                CharacterProxy.PosY    = m_posY;
                CharacterProxy.Jump    = m_jump; m_jump = false;
                CharacterProxy.Gravity = m_gravity;
                CharacterProxy.StepSimulation(stepSizeInSeconds);
            }
            if (CharacterRigidBody != null)
            {
                CharacterRigidBody.PosX    = m_posX;
                CharacterRigidBody.PosY    = m_posY;
                CharacterRigidBody.Jump    = m_jump; m_jump = false;
                CharacterRigidBody.Gravity = m_gravity;
                CharacterRigidBody.Speed   = Speed;
                CharacterRigidBody.StepSimulation(stepSizeInSeconds);
                CharacterRigidBody.Elevate = Elevate;
                Supported      = CharacterRigidBody.Supported;
                SupportNormal  = CharacterRigidBody.SupportNormal;
                GroundVelocity = CharacterRigidBody.GroundVelocity;

                if (false)
                {
                    // Coordinate system
                    Matrix  worldMatrix = GetPhysicsBody().GetWorldMatrix();
                    Vector3 Side        = CharacterRigidBody.Up.Cross(CharacterRigidBody.Forward);
                    //MyPhysicsDebugDraw.DebugDrawCoordinateSystem(worldMatrix.Translation, CharacterRigidBody.Forward, Side, CharacterRigidBody.Up);

                    //BoundingBoxD
                    //MyPhysicsDebugDraw.DebugDrawAabb(worldMatrix.Translation,Color.LightBlue);

                    //Velocity and Acceleration
                    MyPhysicsDebugDraw.DebugDrawVector3(worldMatrix.Translation, CharacterRigidBody.LinearVelocity, Color.Red, 1.0f);
                    //MyPhysicsDebugDraw.DebugDrawVector3(worldMatrix.Translation, CharacterRigidBody.LinearAcceleration, Color.Blue, 1.0f);

                    // Gravity
                    MyPhysicsDebugDraw.DebugDrawVector3(worldMatrix.Translation, CharacterRigidBody.Gravity, Color.Yellow, 0.1f);

                    // Controller Up
                    //MyPhysicsDebugDraw.DebugDrawVector3(worldMatrix.Translation, CharacterRigidBody.GetControllerUp(), Color.Pink, 1.0f);
                    MyPhysicsDebugDraw.DebugDrawVector3(worldMatrix.Translation, CharacterRigidBody.Up, Color.Pink, 1.0f);

                    Vector3 TestUp = Vector3.Up;
                    MyPhysicsDebugDraw.DebugDrawVector3(worldMatrix.Translation, TestUp, Color.Green, 1.0f);

                    /*
                     * // Capsule Shape draw
                     * float radius = 0.4f;
                     * Vector3 vertexA = Vector3.Zero;
                     * Vector3 vertexB = Vector3.Zero;
                     * CharacterRigidBody.GetPxCapsuleShapeDrawData(ref radius,ref vertexA,ref vertexB);
                     * if ((vertexA != vertexB) && (radius > 0.0f))
                     * {
                     *  HkShape capsuleShape = new HkCapsuleShape(vertexA, vertexB, radius); // only for debug display
                     *
                     *  int index = 0;
                     *  const float alpha = 0.3f;
                     *  MyPhysicsDebugDraw.DrawCollisionShape(capsuleShape, worldMatrix, alpha, ref index);
                     * }
                     */
                }
            }
        }