Download Now

    Reference TMatrix4x4

    Declared in Codebot.Geometry.pas on line 218

    TMatrix4x4 is used to transform vertices
      TMatrix4x4 = record
      public
        { Returns true if all fields match another matrix }
        function Equals(const Value: TMatrix4x4): Boolean;
        { Reset to the identity matrix }
        procedure Identity;
        { Returns true if the matrix has an inverse }
        function CanInvert: Boolean;
        { Invert the matrix in place returning false if it cannot be inverted }
        function Invert: Boolean;
        { Swap rows and columns }
        procedure Transpose;
        { Rotate in radians around each axis using DefaultRotationOrder }
        procedure Rotate(X, Y, Z: Float); overload;
        { Rotate in radians around each axis using a rotation order }
        procedure Rotate(X, Y, Z: Float; Order: TRotationOrder); overload;
        { Rotate in radians around a pivot point using DefaultRotationOrder }
        procedure RotateAt(X, Y, Z: Float; const Pivot: TVec3); overload;
        { Rotate in radians around a pivot point using a rotation order }
        procedure RotateAt(X, Y, Z: Float; const Pivot: TVec3; Order: TRotationOrder); overload;
        { Scale along each axis }
        procedure Scale(X, Y, Z: Float);
        { Scale along each axis around a pivot point }
        procedure ScaleAt(X, Y, Z: Float; const Pivot: TVec3);
        { Move along each axis }
        procedure Translate(X, Y, Z: Float);
        { Transform a 2d point treating Z as zero }
        function Transform(const V: TVec2): TVec2; overload;
        { Transform a 3d point }
        function Transform(const V: TVec3): TVec3; overload;
        { Multiply this matrix by another matrix }
        function Transform(const M: TMatrix4x4): TMatrix4x4; overload;
        { Project transforms a point by the matrix, including the perspective
          divide, and maps it to window coordinates with the origin at the top left.
          Returns False when the point is behind the camera. }
        function Project(const V: TVec3; Width, Height: Float; out P: TVec2): Boolean;
        { Set a perspective projection given a vertical field of view in degrees }
        procedure Perspective(FoV, AspectRatio, NearPlane, FarPlane: Float);
        { Set a perspective projection given the bounds of the near plane }
        procedure Frustum(Left, Right, Top, Bottom, NearPlane, FarPlane: Float);
        { Set an orthographic projection }
        procedure Ortho(Left, Right, Top, Bottom, NearPlane, FarPlane: Float);
        { Set a view matrix looking from eye toward center }
        procedure LookAt(Eye, Center, Up: TVec3);
        M: array[0..3, 0..3] of Float;
        M0: array[0..3] of Float;
        M1: array[0..3] of Float;
        M2: array[0..3] of Float;
        M3: array[0..3] of Float;
        V: array[0..15] of Float;
      end;

    See also

    Float in Codebot.System.pas