diff --git a/Physac-cs/Physac.cs b/Physac-cs/Physac.cs index 63a3d43..d5c043e 100644 --- a/Physac-cs/Physac.cs +++ b/Physac-cs/Physac.cs @@ -7,6 +7,7 @@ */ using System; +using System.Numerics; using System.Runtime.InteropServices; using System.Security; using Raylib_cs; diff --git a/Raygui-cs/Raygui.cs b/Raygui-cs/Raygui.cs index e65efa6..5f80c58 100644 --- a/Raygui-cs/Raygui.cs +++ b/Raygui-cs/Raygui.cs @@ -6,6 +6,7 @@ * See LICENSE for details. */ +using System.Numerics; using System.Runtime.InteropServices; using System.Security; using System.Text; diff --git a/Raylib-cs/Raylib.cs b/Raylib-cs/Raylib.cs index b49270c..a8456d7 100644 --- a/Raylib-cs/Raylib.cs +++ b/Raylib-cs/Raylib.cs @@ -13,28 +13,6 @@ using System.Security; namespace Raylib_cs { - // Matrix type (OpenGL style 4x4 - right handed, column major) - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public struct Matrix - { - public float m0; - public float m4; - public float m8; - public float m12; - public float m1; - public float m5; - public float m9; - public float m13; - public float m2; - public float m6; - public float m10; - public float m14; - public float m3; - public float m7; - public float m11; - public float m15; - } - // Color type, RGBA (32bit) [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct Color @@ -328,7 +306,7 @@ namespace Raylib_cs [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct Model { - public Matrix transform; // Local transform matrix + public Matrix4x4 transform; // Local transform matrix public int meshCount; // Number of meshes // meshes refers to a Mesh * @@ -1111,11 +1089,11 @@ namespace Raylib_cs // Returns camera transform matrix (view matrix) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix GetCameraMatrix(Camera3D camera); + public static extern Matrix4x4 GetCameraMatrix(Camera3D camera); // Returns camera 2d transform matrix [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix GetCameraMatrix2D(Camera2D camera); + public static extern Matrix4x4 GetCameraMatrix2D(Camera2D camera); // Returns the screen space position for a 3d world space position [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -2586,7 +2564,7 @@ namespace Raylib_cs // Set shader uniform value (matrix 4x4) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); + public static extern void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix4x4 mat); // Set shader uniform value for texture [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -2594,19 +2572,19 @@ namespace Raylib_cs // Set a custom projection matrix (replaces internal projection matrix) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMatrixProjection(Matrix proj); + public static extern void SetMatrixProjection(Matrix4x4 proj); // Set a custom modelview matrix (replaces internal modelview matrix) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMatrixModelview(Matrix view); + public static extern void SetMatrixModelview(Matrix4x4 view); // Get internal modelview matrix [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix GetMatrixModelview(); + public static extern Matrix4x4 GetMatrixModelview(); // Get internal projection matrix [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix GetMatrixProjection(); + public static extern Matrix4x4 GetMatrixProjection(); // Texture maps generation (PBR) diff --git a/Raylib-cs/Raymath.cs b/Raylib-cs/Raymath.cs index 7682a78..02a91a3 100644 --- a/Raylib-cs/Raymath.cs +++ b/Raylib-cs/Raymath.cs @@ -173,7 +173,7 @@ namespace Raylib_cs // Transforms a Vector3 by a given Matrix [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Transform(Vector3 v, Matrix mat); + public static extern Vector3 Vector3Transform(Vector3 v, Matrix4x4 mat); // Transform a vector by quaternion rotation [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -206,90 +206,90 @@ namespace Raylib_cs // Compute matrix determinant [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float MatrixDeterminant(Matrix mat); + public static extern float MatrixDeterminant(Matrix4x4 mat); // Returns the trace of the matrix (sum of the values along the diagonal) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float MatrixTrace(Matrix mat); + public static extern float MatrixTrace(Matrix4x4 mat); // Transposes provided matrix [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix MatrixTranspose(Matrix mat); + public static extern Matrix4x4 MatrixTranspose(Matrix4x4 mat); // Invert provided matrix [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix MatrixInvert(Matrix mat); + public static extern Matrix4x4 MatrixInvert(Matrix4x4 mat); // Normalize provided matrix [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix MatrixNormalize(Matrix mat); + public static extern Matrix4x4 MatrixNormalize(Matrix4x4 mat); // Returns identity matrix [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix MatrixIdentity(); + public static extern Matrix4x4 MatrixIdentity(); // Add two matrices [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix MatrixAdd(Matrix left, Matrix right); + public static extern Matrix4x4 MatrixAdd(Matrix4x4 left, Matrix4x4 right); // Subtract two matrices (left - right) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix MatrixSubtract(Matrix left, Matrix right); + public static extern Matrix4x4 MatrixSubtract(Matrix4x4 left, Matrix4x4 right); // Returns translation matrix [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix MatrixTranslate(float x, float y, float z); + public static extern Matrix4x4 MatrixTranslate(float x, float y, float z); // Create rotation matrix from axis and angle // NOTE: Angle should be provided in radians [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix MatrixRotate(Vector3 axis, float angle); + public static extern Matrix4x4 MatrixRotate(Vector3 axis, float angle); // Returns xyz-rotation matrix (angles in radians) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix MatrixRotateXYZ(Vector3 ang); + public static extern Matrix4x4 MatrixRotateXYZ(Vector3 ang); // Returns x-rotation matrix (angle in radians) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix MatrixRotateX(float angle); + public static extern Matrix4x4 MatrixRotateX(float angle); // Returns y-rotation matrix (angle in radians) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix MatrixRotateY(float angle); + public static extern Matrix4x4 MatrixRotateY(float angle); // Returns z-rotation matrix (angle in radians) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix MatrixRotateZ(float angle); + public static extern Matrix4x4 MatrixRotateZ(float angle); // Returns scaling matrix [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix MatrixScale(float x, float y, float z); + public static extern Matrix4x4 MatrixScale(float x, float y, float z); // Returns two matrix multiplication // NOTE: When multiplying matrices... the order matters! [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix MatrixMultiply(Matrix left, Matrix right); + public static extern Matrix4x4 MatrixMultiply(Matrix4x4 left, Matrix4x4 right); // Returns perspective projection matrix [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix MatrixFrustum(double left, double right, double bottom, double top, double near, double far); + public static extern Matrix4x4 MatrixFrustum(double left, double right, double bottom, double top, double near, double far); // Returns perspective projection matrix // NOTE: Angle should be provided in radians [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix MatrixPerspective(double fovy, double aspect, double near, double far); + public static extern Matrix4x4 MatrixPerspective(double fovy, double aspect, double near, double far); // Returns orthographic projection matrix [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix MatrixOrtho(double left, double right, double bottom, double top, double near, double far); + public static extern Matrix4x4 MatrixOrtho(double left, double right, double bottom, double top, double near, double far); // Returns camera look-at matrix (view matrix) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up); + public static extern Matrix4x4 MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up); // Returns float array of matrix data [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float16 MatrixToFloatV(Matrix mat); + public static extern float16 MatrixToFloatV(Matrix4x4 mat); // Returns identity quaternion [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -329,11 +329,11 @@ namespace Raylib_cs // Returns a quaternion for a given rotation matrix [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionFromMatrix(Matrix mat); + public static extern Quaternion QuaternionFromMatrix(Matrix4x4 mat); // Returns a matrix for a given quaternion [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix QuaternionToMatrix(Quaternion q); + public static extern Matrix4x4 QuaternionToMatrix(Quaternion q); // Returns rotation quaternion for an angle and axis // NOTE: angle must be provided in radians @@ -355,6 +355,6 @@ namespace Raylib_cs // Transform a quaternion given a transformation matrix [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionTransform(Quaternion q, Matrix mat); + public static extern Quaternion QuaternionTransform(Quaternion q, Matrix4x4 mat); } } diff --git a/Raylib-cs/Rlgl.cs b/Raylib-cs/Rlgl.cs index fd5b1fc..f6858b1 100644 --- a/Raylib-cs/Rlgl.cs +++ b/Raylib-cs/Rlgl.cs @@ -283,7 +283,7 @@ namespace Raylib_cs // Get world coordinates from screen coordinates [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 rlUnproject(Vector3 source, Matrix proj, Matrix view); + public static extern Vector3 rlUnproject(Vector3 source, Matrix4x4 proj, Matrix4x4 view); // Textures data management // Load texture in GPU @@ -355,7 +355,7 @@ namespace Raylib_cs // Draw a 3d mesh with material and transform [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void rlDrawMesh(Mesh mesh, Material material, Matrix transform); + public static extern void rlDrawMesh(Mesh mesh, Material material, Matrix4x4 transform); // Unload mesh data from CPU and GPU [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]