示例#1
0
        public override MatrixD GetHeadMatrix(bool includeY, bool includeX = true, bool forceHeadAnim = false, bool forceHeadBone = false)
        {
            var world = PositionComp.WorldMatrix;

            float headX = m_headLocalXAngle;
            float headY = m_headLocalYAngle;

            if (!includeX)
            {
                headX = DEFAULT_FPS_CAMERA_X_ANGLE;
            }

            MatrixD matrixRotation = MatrixD.CreateFromAxisAngle(Vector3D.Right, MathHelper.ToRadians(headX));

            if (includeY)
            {
                matrixRotation = matrixRotation * Matrix.CreateFromAxisAngle(Vector3.Up, MathHelper.ToRadians(headY));
            }

            world = matrixRotation * world;
            Vector3D headPosition = world.Translation;

            if (m_headLocalPosition != Vector3.Zero)
            {
                headPosition = Vector3D.Transform(m_headLocalPosition + m_playerHeadSpring, PositionComp.WorldMatrix);
            }
            else if (Pilot != null)
            {
                var headMatrix = Pilot.GetHeadMatrix(includeY, includeX, forceHeadAnim, IsInFirstPersonView);
                headPosition = headMatrix.Translation + headMatrix.Backward * 0.15f + m_playerHeadSpring;
            }

            world.Translation = headPosition;
            if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW && MyDebugDrawSettings.DEBUG_DRAW_CHARACTER_MISC)
            {
                VRageRender.MyRenderProxy.DebugDrawSphere(world.Translation, 0.05f, Color.Yellow, 1f, false);
                VRageRender.MyRenderProxy.DebugDrawText3D(world.Translation, "Cockpit camera", Color.Yellow, 0.5f, false);
            }

            return(world);
        }