Пример #1
0
        internal static void PrepareStateMatrix(GpuStateStruct* GpuState, ref Matrix4f WorldViewProjectionMatrix)
        {
            // DRAW BEGIN COMMON
            {
                if (GpuState->VertexState.Type.Transform2D)
                //if (true)
                {
                    WorldViewProjectionMatrix = Matrix4f.Ortho(0, 512, 272, 0, 0, -0xFFFF);
                    //WorldViewProjectionMatrix = Matrix4f.Ortho(0, 480, 272, 0, 0, -0xFFFF);
                }
                else
                {
                    if (float.IsNaN(GpuState->VertexState.WorldMatrix.Values[0]))
                    {
                        //Console.Error.WriteLine("Invalid WorldMatrix");
                        //Console.Error.WriteLine("Projection:");
                        //GpuState->VertexState.ProjectionMatrix.Dump();
                        //Console.Error.WriteLine("View:");
                        //GpuState->VertexState.ViewMatrix.Dump();
                        //Console.Error.WriteLine("World:");
                        //GpuState->VertexState.WorldMatrix.Dump();
                    }

                    GpuState->VertexState.ViewMatrix.SetLastColumn();
                    GpuState->VertexState.WorldMatrix.SetLastColumn();

                    WorldViewProjectionMatrix =
                        Matrix4f.Identity
                        .Multiply(GpuState->VertexState.WorldMatrix.Matrix4)
                        .Multiply(GpuState->VertexState.ViewMatrix.Matrix4)
                        .Multiply(GpuState->VertexState.ProjectionMatrix.Matrix4)
                    ;
                }
            }
        }
Пример #2
0
 public Matrix4f Multiply(Matrix4f that)
 {
     return StaticMultiply(this, that);
 }
Пример #3
0
 public static Matrix4f StaticMultiply(Matrix4f Left, Matrix4f Right)
 {
     var New = Matrix4f.Identity;
     for (int Column = 0; Column < 4; Column++)
     {
         for (int Row = 0; Row < 4; Row++)
         {
             float Dot = 0;
             for (int Index = 0; Index < 4; Index++) Dot += Left[Index, Row] * Right[Column, Index];
             New[Column, Row] = Dot;
         }
     }
     return New;
 }