BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Properties | List of all members
BrawlLib.Internal.Matrix Struct Reference
Inheritance diagram for BrawlLib.Internal.Matrix:

Public Member Functions

 Matrix (SerializationInfo info, StreamingContext ctxt)
 
void GetObjectData (SerializationInfo info, StreamingContext context)
 
Matrix Copy ()
 
 Matrix (float *values)
 
 Matrix (params float[] values)
 
Matrix Reverse ()
 
Vector3 GetPoint ()
 
Vector3 GetScale ()
 
void Translate (Vector3 v)
 
void Translate (float x, float y, float z)
 
Vector3 Multiply (Vector3 v)
 
Vector3 MultiplyInverse (Vector3 v)
 
void RotateX (float x)
 
void RotateY (float y)
 
void RotateZ (float z)
 
Matrix GetRotationMatrix ()
 
Vector4 GetQuaternion1 ()
 
Vector4 GetQuaternion2 ()
 
Vector4 GetQuaternion3 ()
 
Vector3 GetAngles ()
 
FrameState Derive ()
 
Matrix Invert ()
 
override bool Equals (object obj)
 
override int GetHashCode ()
 
override string ToString ()
 

Static Public Member Functions

static Matrix ScaleMatrix (Vector3 scale)
 
static Matrix ScaleMatrix (float x, float y, float z)
 
static Matrix TranslationMatrix (Vector3 v)
 
static Matrix TranslationMatrix (float x, float y, float z)
 
static Matrix ReverseTranslationMatrix (Vector3 v)
 
static Matrix ReverseTranslationMatrix (float x, float y, float z)
 
static Matrix InfluenceMatrix (List< BoneWeight > weights)
 
static Matrix ReverseInfluenceMatrix (List< BoneWeight > weights)
 
static Matrix RotationAboutX (float angle)
 
static Matrix RotationAboutY (float angle)
 
static Matrix RotationAboutZ (float angle)
 
static Matrix RotationMatrix (Vector3 angles)
 
static Matrix RotationMatrix (float x, float y, float z)
 
static Matrix ReverseRotationMatrix (Vector3 angles)
 
static Matrix ReverseRotationMatrix (float x, float y, float z)
 
static Vector2 operator* (Matrix m, Vector2 v)
 
static Vector3 operator* (Vector3 v, Matrix m)
 
static Vector3 operator* (Matrix m, Vector3 v)
 
static Vector4 operator* (Matrix m, Vector4 v)
 
static Matrix operator* (Matrix m1, Matrix m2)
 
static Matrix operator+ (Matrix m1, Matrix m2)
 
static Matrix operator- (Matrix m1, Matrix m2)
 
static Matrix operator* (Matrix m, float f)
 
static Matrix operator/ (Matrix m, float f)
 
static bool operator== (Matrix m1, Matrix m2)
 
static bool operator!= (Matrix m1, Matrix m2)
 
static Matrix operator- (Matrix m)
 
static operator Matrix (Matrix34 m)
 
static operator Matrix34 (Matrix m)
 
static Matrix OrthographicMatrix (Vector4 dimensions, Vector2 depth)
 
static Matrix OrthographicMatrix (Vector4 dimensions, float nearZ, float farZ)
 
static Matrix OrthographicMatrix (float w, float h, float nearZ, float farZ)
 
static Matrix OrthographicMatrix (float left, float right, float top, float bottom, float nearZ, float farZ)
 
static Matrix ReverseOrthographicMatrix (Vector4 dimensions, Vector2 depth)
 
static Matrix ReverseOrthographicMatrix (Vector4 dimensions, float nearZ, float farZ)
 
static Matrix ReverseOrthographicMatrix (float w, float h, float nearZ, float farZ)
 
static Matrix ReverseOrthographicMatrix (float left, float right, float top, float bottom, float nearZ, float farZ)
 
static Matrix PerspectiveMatrix (float fovY, float aspect, float nearZ, float farZ)
 
static Matrix ReversePerspectiveMatrix (float fovY, float aspect, float nearZ, float farZ)
 
static Matrix TransformMatrix (Vector3 scale, Vector3 rotate, Vector3 translate)
 
static Matrix ReverseTransformMatrix (Vector3 scale, Vector3 rotation, Vector3 translation)
 
static Matrix QuaternionTransformMatrix (Vector3 scale, Vector4 rotate, Vector3 translate)
 
static Matrix ReverseQuaternionTransformMatrix (Vector3 scale, Vector4 rotate, Vector3 translate)
 
static Matrix AxisAngleMatrix (Vector3 point1, Vector3 point2)
 
static Matrix Lookat (Vector3 eye, Vector3 target, float roll)
 
static Matrix ReverseLookat (Vector3 eye, Vector3 target, float roll)
 
static Matrix Invert (Matrix mat)
 

Static Public Attributes

static readonly Matrix Identity = ScaleMatrix(1.0f, 1.0f, 1.0f)
 

Properties

Vector4 Row0 [get, set]
 
Vector4 Row1 [get, set]
 
Vector4 Row2 [get, set]
 
Vector4 Row3 [get, set]
 
Vector4 Col0 [get, set]
 
Vector4 Col1 [get, set]
 
Vector4 Col2 [get, set]
 
Vector4 Col3 [get, set]
 
float M11 [get, set]
 Row 1, Column 1 More...
 
float M12 [get, set]
 Row 1, Column 2 More...
 
float M13 [get, set]
 Row 1, Column 3 More...
 
float M14 [get, set]
 Row 1, Column 4 More...
 
float M21 [get, set]
 Row 2, Column 1 More...
 
float M22 [get, set]
 Row 2, Column 2 More...
 
float M23 [get, set]
 Row 2, Column 3 More...
 
float M24 [get, set]
 Row 2, Column 4 More...
 
float M31 [get, set]
 Row 3, Column 1 More...
 
float M32 [get, set]
 Row 3, Column 2 More...
 
float M33 [get, set]
 Row 3, Column 3 More...
 
float M34 [get, set]
 Row 3, Column 4 More...
 
float M41 [get, set]
 Row 4, Column 1 More...
 
float M42 [get, set]
 Row 4, Column 2 More...
 
float M43 [get, set]
 Row 4, Column 3 More...
 
float M44 [get, set]
 Row 4, Column 4 More...
 
float * Data [get]
 
float this[int x, int y] [get, set]
 
float this[int index] [get, set]
 

Constructor & Destructor Documentation

◆ Matrix() [1/3]

BrawlLib.Internal.Matrix.Matrix ( SerializationInfo  info,
StreamingContext  ctxt 
)
inline
20 {
21 for (int i = 0; i < 16; i++)
22 {
23 Data[i] = info.GetSingle($"_values[{i}]");
24 }
25 }
float * Data
Definition: Matrix.cs:254

◆ Matrix() [2/3]

BrawlLib.Internal.Matrix.Matrix ( float *  values)
inline
284 {
285 Matrix m = this;
286 float* p = (float*) &m;
287 for (int i = 0; i < 16; i++)
288 {
289 p[i] = values[i];
290 }
291 }
Matrix(SerializationInfo info, StreamingContext ctxt)
Definition: Matrix.cs:19

◆ Matrix() [3/3]

BrawlLib.Internal.Matrix.Matrix ( params float[]  values)
inline
294 {
295 Matrix m = this;
296 float* p = (float*) &m;
297 for (int i = 0; i < 16; i++)
298 {
299 p[i] = values[i];
300 }
301 }

Member Function Documentation

◆ AxisAngleMatrix()

static Matrix BrawlLib.Internal.Matrix.AxisAngleMatrix ( Vector3  point1,
Vector3  point2 
)
inlinestatic
1372 {
1373 Matrix m = Identity;
1374 //Equal points will cause a corrupt matrix
1375 if (point1 != point2)
1376 {
1377 float* pOut = (float*) &m;
1378
1379 point1 = point1.Normalize();
1380 point2 = point2.Normalize();
1381
1382 Vector3 vSin = point1.Cross(point2);
1383 Vector3 axis = vSin.Normalize();
1384
1385 float cos = point1.Dot(point2);
1386 Vector3 vt = axis * (1.0f - cos);
1387
1388 pOut[0] = vt._x * axis._x + cos;
1389 pOut[5] = vt._y * axis._y + cos;
1390 pOut[10] = vt._z * axis._z + cos;
1391
1392 vt._x *= axis._y;
1393 vt._z *= axis._x;
1394 vt._y *= axis._z;
1395
1396 pOut[1] = vt._x + vSin._z;
1397 pOut[2] = vt._z - vSin._y;
1398 pOut[4] = vt._x - vSin._z;
1399 pOut[6] = vt._y + vSin._x;
1400 pOut[8] = vt._z + vSin._y;
1401 pOut[9] = vt._y - vSin._x;
1402 }
1403
1404 return m;
1405 }
static readonly Matrix Identity
Definition: Matrix.cs:15

◆ Copy()

Matrix BrawlLib.Internal.Matrix.Copy ( )
inline
279 {
280 return new Matrix(Data);
281 }

◆ Derive()

FrameState BrawlLib.Internal.Matrix.Derive ( )
inline
1011 {
1012 FrameState state = new FrameState();
1013
1014 fixed (float* p = _values)
1015 {
1016 //Translation is easy!
1017 state._translate = *(Vector3*) &p[12];
1018
1019 //Scale, use sqrt of rotation columns
1020 state._scale._x = (float) Math.Round(Math.Sqrt(p[0] * p[0] + p[1] * p[1] + p[2] * p[2]), 4);
1021 state._scale._y = (float) Math.Round(Math.Sqrt(p[4] * p[4] + p[5] * p[5] + p[6] * p[6]), 4);
1022 state._scale._z = (float) Math.Round(Math.Sqrt(p[8] * p[8] + p[9] * p[9] + p[10] * p[10]), 4);
1023
1024 state._rotate = GetAngles();
1025 }
1026
1027 state.CalcTransforms();
1028 return state;
1029 }
Vector3 GetAngles()
Definition: Matrix.cs:971
Definition: FrameState.cs:10
void CalcTransforms()
Definition: FrameState.cs:84

◆ Equals()

override bool BrawlLib.Internal.Matrix.Equals ( object  obj)
inline
1592 {
1593 if (obj is Matrix matrix)
1594 {
1595 return matrix == this;
1596 }
1597
1598 return false;
1599 }

◆ GetAngles()

Vector3 BrawlLib.Internal.Matrix.GetAngles ( )
inline
972 {
973 float x, y, z, c;
974 fixed (float* p = _values)
975 {
976 y = (float) Math.Asin(-p[2]);
977 if (Maths._halfPif - Math.Abs(y) < 0.0001f)
978 {
979 //Gimbal lock, occurs when the y rotation falls on pi/2 or -pi/2
980 z = 0.0f;
981 if (y > 0)
982 {
983 x = (float) Math.Atan2(p[4], p[8]);
984 }
985 else
986 {
987 x = (float) Math.Atan2(p[4], -p[8]);
988 }
989 }
990 else
991 {
992 c = (float) Math.Cos(y);
993 x = (float) Math.Atan2(p[6] / c, p[10] / c);
994 z = (float) Math.Atan2(p[1] / c, p[0] / c);
995
996 //180 z/x inverts y, use second option
997 if (Maths._pif - Math.Abs(z) < 0.05f)
998 {
999 y = Maths._pif - y;
1000 c = (float) Math.Cos(y);
1001 x = (float) Math.Atan2(p[6] / c, p[10] / c);
1002 z = (float) Math.Atan2(p[1] / c, p[0] / c);
1003 }
1004 }
1005 }
1006
1007 return new Vector3(x, y, z) * Maths._rad2degf;
1008 }

◆ GetHashCode()

override int BrawlLib.Internal.Matrix.GetHashCode ( )
inline
1602 {
1603 return base.GetHashCode();
1604 }

◆ GetObjectData()

void BrawlLib.Internal.Matrix.GetObjectData ( SerializationInfo  info,
StreamingContext  context 
)
inline
28 {
29 for (int i = 0; i < 16; i++)
30 {
31 info.AddValue($"_values[{i}]", Data[i]);
32 }
33 }

◆ GetPoint()

Vector3 BrawlLib.Internal.Matrix.GetPoint ( )
inline
322 {
323 fixed (float* p = _values)
324 {
325 return new Vector3(p[12], p[13], p[14]);
326 }
327 }

◆ GetQuaternion1()

Vector4 BrawlLib.Internal.Matrix.GetQuaternion1 ( )
inline
848 {
849 Matrix m = this;
850 float* p = (float*) &m;
851
852 Vector4 result = new Vector4();
853
854 float scale = p[0] + p[5] + p[10] + 1;
855 float sqrt;
856
857 if (scale > 0.0f)
858 {
859 sqrt = 0.5f / (float) Math.Sqrt(scale);
860
861 result._x = (p[9] - p[6]) * sqrt;
862 result._y = (p[2] - p[8]) * sqrt;
863 result._z = (p[4] - p[1]) * sqrt;
864 result._w = 0.25f / sqrt;
865
866 return result;
867 }
868
869 if (p[0] >= p[5] && p[0] >= p[10])
870 {
871 sqrt = (float) Math.Sqrt(1.0 + p[0] - p[5] - p[10]) * 2;
872
873 result._x = 0.5f / sqrt;
874 result._y = (p[1] + p[4]) / sqrt;
875 result._z = (p[2] + p[8]) / sqrt;
876 result._w = (p[6] + p[9]) / sqrt;
877
878 return result;
879 }
880
881 if (p[5] > p[10])
882 {
883 sqrt = (float) Math.Sqrt(1.0 + p[5] - p[0] - p[10]) * 2;
884
885 result._x = (p[1] + p[4]) / sqrt;
886 result._y = 0.5f / sqrt;
887 result._z = (p[6] + p[9]) / sqrt;
888 result._w = (p[2] + p[8]) / sqrt;
889
890 return result;
891 }
892
893 sqrt = (float) Math.Sqrt(1.0 + p[10] - p[0] - p[5]) * 2;
894
895 result._x = (p[2] + p[8]) / sqrt;
896 result._y = (p[6] + p[9]) / sqrt;
897 result._z = 0.5f / sqrt;
898 result._w = (p[1] + p[4]) / sqrt;
899
900 return result;
901 }

◆ GetQuaternion2()

Vector4 BrawlLib.Internal.Matrix.GetQuaternion2 ( )
inline
904 {
905 Vector4 q = new Vector4();
906
907 Matrix m = this;
908 float* p = (float*) &m;
909
910 double trace = p[0] + p[5] + p[10] + 1.0;
911
912 if (trace > 1e-7)
913 {
914 double s = 0.5 / Math.Sqrt(trace);
915 q[0] = (float) ((p[9] - p[6]) * s);
916 q[1] = (float) ((p[2] - p[8]) * s);
917 q[2] = (float) ((p[4] - p[1]) * s);
918 q[3] = (float) (0.25 / s);
919 }
920 else
921 {
922 if (p[0] > p[5] && p[0] > p[10])
923 {
924 double s = 2.0 * Math.Sqrt(1.0 + p[0] - p[5] - p[10]);
925 q[0] = (float) (0.25 * s);
926 q[1] = (float) ((p[1] + p[4]) / s);
927 q[2] = (float) ((p[2] + p[8]) / s);
928 q[3] = (float) ((p[6] - p[9]) / s);
929 }
930 else if (p[5] > p[10])
931 {
932 double s = 2.0 * Math.Sqrt(1.0 + p[5] - p[0] - p[10]);
933 q[0] = (float) ((p[1] + p[4]) / s);
934 q[1] = (float) (0.25 * s);
935 q[2] = (float) ((p[6] + p[9]) / s);
936 q[3] = (float) ((p[2] - p[8]) / s);
937 }
938 else
939 {
940 double s = 2.0 * Math.Sqrt(1.0 + p[10] - p[0] - p[5]);
941 q[0] = (float) ((p[2] + p[8]) / s);
942 q[1] = (float) ((p[6] + p[9]) / s);
943 q[2] = (float) (0.25 * s);
944 q[3] = (float) ((p[1] - p[4]) / s);
945 }
946 }
947
948 q.Normalize();
949
950 return q * Maths._rad2degf;
951 }

◆ GetQuaternion3()

Vector4 BrawlLib.Internal.Matrix.GetQuaternion3 ( )
inline
954 {
955 Matrix m = this;
956 Vector4 q = new Vector4
957 {
958 _w = (float) Math.Sqrt(Math.Max(0, 1 + m[0, 0] + m[1, 1] + m[2, 2])) / 2,
959 _x = (float) Math.Sqrt(Math.Max(0, 1 + m[0, 0] - m[1, 1] - m[2, 2])) / 2,
960 _y = (float) Math.Sqrt(Math.Max(0, 1 - m[0, 0] + m[1, 1] - m[2, 2])) / 2,
961 _z = (float) Math.Sqrt(Math.Max(0, 1 - m[0, 0] - m[1, 1] + m[2, 2])) / 2
962 };
963 q._x *= Math.Sign(q._x * (m[2, 1] - m[1, 2]));
964 q._y *= Math.Sign(q._y * (m[0, 2] - m[2, 0]));
965 q._z *= Math.Sign(q._z * (m[1, 0] - m[0, 1]));
966 return q;
967 }

◆ GetRotationMatrix()

Matrix BrawlLib.Internal.Matrix.GetRotationMatrix ( )
inline
826 {
827 Matrix m = Identity;
828 float* p = (float*) &m;
829 fixed (float* src = _values)
830 {
831 p[0] = src[0];
832 p[1] = src[1];
833 p[2] = src[2];
834
835 p[4] = src[4];
836 p[5] = src[5];
837 p[6] = src[6];
838
839 p[8] = src[8];
840 p[9] = src[9];
841 p[10] = src[10];
842 }
843
844 return m;
845 }

◆ GetScale()

Vector3 BrawlLib.Internal.Matrix.GetScale ( )
inline
330 {
331 fixed (float* p = _values)
332 {
333 return new Vector3(p[0], p[5], p[10]);
334 }
335 }

◆ InfluenceMatrix()

static Matrix BrawlLib.Internal.Matrix.InfluenceMatrix ( List< BoneWeight weights)
inlinestatic
384 {
385 Matrix m = new Matrix();
386 foreach (BoneWeight w in weights)
387 {
388 if (w.Bone != null)
389 {
390 m += w.Bone.Matrix * w.Bone.InverseBindMatrix * w.Weight;
391 }
392 }
393
394 return m;
395 }
Definition: InfluenceManager.cs:381
IBoneNode Bone
Definition: InfluenceManager.cs:387
float Weight
Definition: InfluenceManager.cs:388

◆ Invert() [1/2]

Matrix BrawlLib.Internal.Matrix.Invert ( )
inline
1475 {
1476 return Invert(this);
1477 }
Matrix Invert()
Definition: Matrix.cs:1474

◆ Invert() [2/2]

static Matrix BrawlLib.Internal.Matrix.Invert ( Matrix  mat)
inlinestatic
1480 {
1481 int[] colIdx = {0, 0, 0, 0};
1482 int[] rowIdx = {0, 0, 0, 0};
1483 int[] pivotIdx = {-1, -1, -1, -1};
1484
1485 // convert the matrix to an array for easy looping
1486 float[,] inverse =
1487 {
1488 {mat.Row0._x, mat.Row0._y, mat.Row0._z, mat.Row0._w},
1489 {mat.Row1._x, mat.Row1._y, mat.Row1._z, mat.Row1._w},
1490 {mat.Row2._x, mat.Row2._y, mat.Row2._z, mat.Row2._w},
1491 {mat.Row3._x, mat.Row3._y, mat.Row3._z, mat.Row3._w}
1492 };
1493 int icol = 0;
1494 int irow = 0;
1495 for (int i = 0; i < 4; i++)
1496 {
1497 // Find the largest pivot value
1498 float maxPivot = 0.0f;
1499 for (int j = 0; j < 4; j++)
1500 {
1501 if (pivotIdx[j] != 0)
1502 {
1503 for (int k = 0; k < 4; ++k)
1504 {
1505 if (pivotIdx[k] == -1)
1506 {
1507 float absVal = Math.Abs(inverse[j, k]);
1508 if (absVal > maxPivot)
1509 {
1510 maxPivot = absVal;
1511 irow = j;
1512 icol = k;
1513 }
1514 }
1515 else if (pivotIdx[k] > 0)
1516 {
1517 return mat;
1518 }
1519 }
1520 }
1521 }
1522
1523 ++pivotIdx[icol];
1524
1525 // Swap rows over so pivot is on diagonal
1526 if (irow != icol)
1527 {
1528 for (int k = 0; k < 4; ++k)
1529 {
1530 float f = inverse[irow, k];
1531 inverse[irow, k] = inverse[icol, k];
1532 inverse[icol, k] = f;
1533 }
1534 }
1535
1536 rowIdx[i] = irow;
1537 colIdx[i] = icol;
1538
1539 float pivot = inverse[icol, icol];
1540 // check for singular matrix
1541 if (pivot == 0.0f)
1542 {
1543 throw new InvalidOperationException("Matrix is singular and cannot be inverted.");
1544 //return mat;
1545 }
1546
1547 // Scale row so it has a unit diagonal
1548 float oneOverPivot = 1.0f / pivot;
1549 inverse[icol, icol] = 1.0f;
1550 for (int k = 0; k < 4; ++k)
1551 {
1552 inverse[icol, k] *= oneOverPivot;
1553 }
1554
1555 // Do elimination of non-diagonal elements
1556 for (int j = 0; j < 4; ++j)
1557 {
1558 // check this isn't on the diagonal
1559 if (icol != j)
1560 {
1561 float f = inverse[j, icol];
1562 inverse[j, icol] = 0.0f;
1563 for (int k = 0; k < 4; ++k)
1564 {
1565 inverse[j, k] -= inverse[icol, k] * f;
1566 }
1567 }
1568 }
1569 }
1570
1571 for (int j = 3; j >= 0; --j)
1572 {
1573 int ir = rowIdx[j];
1574 int ic = colIdx[j];
1575 for (int k = 0; k < 4; ++k)
1576 {
1577 float f = inverse[k, ir];
1578 inverse[k, ir] = inverse[k, ic];
1579 inverse[k, ic] = f;
1580 }
1581 }
1582
1583 mat.Row0 = new Vector4(inverse[0, 0], inverse[0, 1], inverse[0, 2], inverse[0, 3]);
1584 mat.Row1 = new Vector4(inverse[1, 0], inverse[1, 1], inverse[1, 2], inverse[1, 3]);
1585 mat.Row2 = new Vector4(inverse[2, 0], inverse[2, 1], inverse[2, 2], inverse[2, 3]);
1586 mat.Row3 = new Vector4(inverse[3, 0], inverse[3, 1], inverse[3, 2], inverse[3, 3]);
1587
1588 return mat;
1589 }

◆ Lookat()

static Matrix BrawlLib.Internal.Matrix.Lookat ( Vector3  eye,
Vector3  target,
float  roll 
)
inlinestatic
1408 {
1409 Vector3 up = new Vector3(-(float) Math.Sin(roll * Maths._deg2radf),
1410 (float) Math.Cos(roll * Maths._deg2radf), 0);
1411
1412 Vector3 zaxis = (eye - target).Normalize();
1413 Vector3 xaxis = up.Cross(zaxis).Normalize();
1414 Vector3 yaxis = zaxis.Cross(xaxis).Normalize();
1415
1416 Matrix m = Identity;
1417 float* pOut = (float*) &m;
1418
1419 pOut[0] = xaxis._x;
1420 pOut[4] = yaxis._x;
1421 pOut[8] = zaxis._x;
1422
1423 pOut[1] = xaxis._y;
1424 pOut[5] = yaxis._y;
1425 pOut[9] = zaxis._y;
1426
1427 pOut[2] = xaxis._z;
1428 pOut[6] = yaxis._z;
1429 pOut[10] = zaxis._z;
1430
1431 pOut[12] = eye._x;
1432 pOut[13] = eye._y;
1433 pOut[14] = eye._z;
1434
1435 return m;
1436 }

◆ Multiply()

Vector3 BrawlLib.Internal.Matrix.Multiply ( Vector3  v)
inline
542 {
543 Vector3 nv = new Vector3();
544 fixed (float* p = _values)
545 {
546 nv._x = p[0] * v._x + p[4] * v._y + p[8] * v._z + p[12];
547 nv._y = p[1] * v._x + p[5] * v._y + p[9] * v._z + p[13];
548 nv._z = p[2] * v._x + p[6] * v._y + p[10] * v._z + p[14];
549 }
550
551 return nv;
552 }

◆ MultiplyInverse()

Vector3 BrawlLib.Internal.Matrix.MultiplyInverse ( Vector3  v)
inline
555 {
556 Vector3 nv = new Vector3();
557 fixed (float* p = _values)
558 {
559 nv._x = p[0] * v._x + p[1] * v._y + p[2] * v._z;
560 nv._y = p[4] * v._x + p[5] * v._y + p[6] * v._z;
561 nv._z = p[8] * v._x + p[9] * v._y + p[10] * v._z;
562 }
563
564 return nv;
565 }

◆ operator Matrix()

static BrawlLib.Internal.Matrix.operator Matrix ( Matrix34  m)
inlineexplicitstatic
1054 {
1055 Matrix m1;
1056 float* sPtr = (float*) &m;
1057 float* dPtr = (float*) &m1;
1058
1059 dPtr[0] = sPtr[0];
1060 dPtr[1] = sPtr[4];
1061 dPtr[2] = sPtr[8];
1062 dPtr[3] = 0.0f;
1063 dPtr[4] = sPtr[1];
1064 dPtr[5] = sPtr[5];
1065 dPtr[6] = sPtr[9];
1066 dPtr[7] = 0.0f;
1067 dPtr[8] = sPtr[2];
1068 dPtr[9] = sPtr[6];
1069 dPtr[10] = sPtr[10];
1070 dPtr[11] = 0.0f;
1071 dPtr[12] = sPtr[3];
1072 dPtr[13] = sPtr[7];
1073 dPtr[14] = sPtr[11];
1074 dPtr[15] = 1.0f;
1075
1076 return m1;
1077 }

◆ operator Matrix34()

static BrawlLib.Internal.Matrix.operator Matrix34 ( Matrix  m)
inlineexplicitstatic
1080 {
1081 Matrix34 m1;
1082 float* sPtr = (float*) &m;
1083 float* dPtr = (float*) &m1;
1084
1085 dPtr[0] = sPtr[0];
1086 dPtr[1] = sPtr[4];
1087 dPtr[2] = sPtr[8];
1088 dPtr[3] = sPtr[12];
1089 dPtr[4] = sPtr[1];
1090 dPtr[5] = sPtr[5];
1091 dPtr[6] = sPtr[9];
1092 dPtr[7] = sPtr[13];
1093 dPtr[8] = sPtr[2];
1094 dPtr[9] = sPtr[6];
1095 dPtr[10] = sPtr[10];
1096 dPtr[11] = sPtr[14];
1097
1098 return m1;
1099 }

◆ operator!=()

static bool BrawlLib.Internal.Matrix.operator!= ( Matrix  m1,
Matrix  m2 
)
inlinestatic
723 {
724 float* p1 = (float*) &m1;
725 float* p2 = (float*) &m2;
726
727 for (int i = 0; i < 16; i++)
728 {
729 if (*p1++ != *p2++)
730 {
731 return true;
732 }
733 }
734
735 return false;
736 }

◆ operator*() [1/6]

static Matrix BrawlLib.Internal.Matrix.operator* ( Matrix  m,
float  f 
)
inlinestatic
685 {
686 float* p = (float*) &m;
687 for (int i = 0; i < 16; i++)
688 {
689 *p++ *= f;
690 }
691
692 return m;
693 }

◆ operator*() [2/6]

static Vector2 BrawlLib.Internal.Matrix.operator* ( Matrix  m,
Vector2  v 
)
inlinestatic
568 {
569 Vector2 nv;
570 float* p = (float*) &m;
571 nv._x = p[0] * v._x + p[4] * v._y + p[8] + p[12];
572 nv._y = p[1] * v._x + p[5] * v._y + p[9] + p[13];
573 //nv._x = (p[0] * v._x) + (p[4] * v._y) + (p[8] * v._z) + p[12];
574 //nv._y = (p[1] * v._x) + (p[5] * v._y) + (p[9] * v._z) + p[13];
575 //nv._z = (p[2] * v._x) + (p[6] * v._y) + (p[10] * v._z) + p[14];
576 return nv;
577 }

◆ operator*() [3/6]

static Vector3 BrawlLib.Internal.Matrix.operator* ( Matrix  m,
Vector3  v 
)
inlinestatic
595 {
596 return Transform(v, m);
597 }

◆ operator*() [4/6]

static Vector4 BrawlLib.Internal.Matrix.operator* ( Matrix  m,
Vector4  v 
)
inlinestatic
600 {
601 Vector4 nv;
602 float* dPtr = (float*) &nv;
603 float* p0 = (float*) &m, p1 = p0 + 4, p2 = p0 + 8, p3 = p0 + 12;
604 for (int i = 0; i < 4; i++)
605 {
606 dPtr[i] = p0[i] * v._x + p1[i] * v._y + p2[i] * v._z + p3[i] * v._w;
607 }
608
609 return nv;
610 }

◆ operator*() [5/6]

static Matrix BrawlLib.Internal.Matrix.operator* ( Matrix  m1,
Matrix  m2 
)
inlinestatic
629 {
630 Matrix dm;
631 float* s1 = (float*) &m2, s2 = (float*) &m1, d = (float*) &dm;
632
633 int index = 0;
634 float val;
635 for (int b = 0; b < 16; b += 4)
636 {
637 for (int a = 0; a < 4; a++)
638 {
639 val = 0.0f;
640 for (int x = b, y = a; y < 16; y += 4)
641 {
642 val += s1[x++] * s2[y];
643 }
644
645 d[index++] = val;
646 }
647 }
648
649 return dm;
650 }

◆ operator*() [6/6]

static Vector3 BrawlLib.Internal.Matrix.operator* ( Vector3  v,
Matrix  m 
)
inlinestatic
590 {
591 return Transform(v, m);
592 }

◆ operator+()

static Matrix BrawlLib.Internal.Matrix.operator+ ( Matrix  m1,
Matrix  m2 
)
inlinestatic
653 {
654 float* dPtr = (float*) &m1;
655 float* sPtr = (float*) &m2;
656 for (int i = 0; i < 16; i++)
657 {
658 *dPtr++ += *sPtr++;
659 }
660
661 return m1;
662 }

◆ operator-() [1/2]

static Matrix BrawlLib.Internal.Matrix.operator- ( Matrix  m)
inlinestatic
739 {
740 float* p = (float*) &m;
741 int i = 0;
742 while (i++ < 16)
743 {
744 *p = -*p++;
745 }
746
747 return m;
748 }

◆ operator-() [2/2]

static Matrix BrawlLib.Internal.Matrix.operator- ( Matrix  m1,
Matrix  m2 
)
inlinestatic
665 {
666 float* dPtr = (float*) &m1;
667 float* sPtr = (float*) &m2;
668 for (int i = 0; i < 16; i++)
669 {
670 *dPtr++ -= *sPtr++;
671 }
672
673 return m1;
674 }

◆ operator/()

static Matrix BrawlLib.Internal.Matrix.operator/ ( Matrix  m,
float  f 
)
inlinestatic
696 {
697 float* p = (float*) &m;
698 for (int i = 0; i < 16; i++)
699 {
700 *p++ /= f;
701 }
702
703 return m;
704 }

◆ operator==()

static bool BrawlLib.Internal.Matrix.operator== ( Matrix  m1,
Matrix  m2 
)
inlinestatic
707 {
708 float* p1 = (float*) &m1;
709 float* p2 = (float*) &m2;
710
711 for (int i = 0; i < 16; i++)
712 {
713 if (*p1++ != *p2++)
714 {
715 return false;
716 }
717 }
718
719 return true;
720 }

◆ OrthographicMatrix() [1/4]

static Matrix BrawlLib.Internal.Matrix.OrthographicMatrix ( float  left,
float  right,
float  top,
float  bottom,
float  nearZ,
float  farZ 
)
inlinestatic
1118 {
1119 Matrix m = Identity;
1120
1121 float* p = (float*) &m;
1122
1123 float rl = right - left;
1124 float tb = top - bottom;
1125 float fn = farZ - nearZ;
1126
1127 p[0] = 2.0f / rl;
1128 p[5] = 2.0f / tb;
1129 p[10] = -2.0f / fn;
1130
1131 p[12] = -(right + left) / rl;
1132 p[13] = -(top + bottom) / tb;
1133 p[14] = -(farZ + nearZ) / fn;
1134
1135 return m;
1136 }

◆ OrthographicMatrix() [2/4]

static Matrix BrawlLib.Internal.Matrix.OrthographicMatrix ( float  w,
float  h,
float  nearZ,
float  farZ 
)
inlinestatic
1112 {
1113 return OrthographicMatrix(-w / 2, w / 2, h / 2, -h / 2, nearZ, farZ);
1114 }
static Matrix OrthographicMatrix(Vector4 dimensions, Vector2 depth)
Definition: Matrix.cs:1101

◆ OrthographicMatrix() [3/4]

static Matrix BrawlLib.Internal.Matrix.OrthographicMatrix ( Vector4  dimensions,
float  nearZ,
float  farZ 
)
inlinestatic
1107 {
1108 return OrthographicMatrix(dimensions._x, dimensions._y, dimensions._z, dimensions._w, nearZ, farZ);
1109 }

◆ OrthographicMatrix() [4/4]

static Matrix BrawlLib.Internal.Matrix.OrthographicMatrix ( Vector4  dimensions,
Vector2  depth 
)
inlinestatic
1102 {
1103 return OrthographicMatrix(dimensions, depth._x, depth._y);
1104 }

◆ PerspectiveMatrix()

static Matrix BrawlLib.Internal.Matrix.PerspectiveMatrix ( float  fovY,
float  aspect,
float  nearZ,
float  farZ 
)
inlinestatic
1176 {
1177 Matrix m;
1178
1179 float* p = (float*) &m;
1180
1181 float cotan = (float) (1.0 / Math.Tan(fovY / 2 * Math.PI / 180.0));
1182
1183 p[0] = cotan / aspect;
1184 p[5] = cotan;
1185 p[10] = (farZ + nearZ) / (nearZ - farZ);
1186 p[11] = -1.0f;
1187 p[14] = 2.0f * farZ * nearZ / (nearZ - farZ);
1188
1189 p[1] = p[2] = p[3] = p[4] = p[6] = p[7] = p[8] = p[9] = p[12] = p[13] = p[15] = 0.0f;
1190
1191 return m;
1192 }

◆ QuaternionTransformMatrix()

static Matrix BrawlLib.Internal.Matrix.QuaternionTransformMatrix ( Vector3  scale,
Vector4  rotate,
Vector3  translate 
)
inlinestatic
1289 {
1290 Matrix m;
1291 float* p = (float*) &m;
1292
1293 float xx = rotate._x * rotate._x;
1294 float yy = rotate._y * rotate._y;
1295 float zz = rotate._z * rotate._z;
1296 float xy = rotate._x * rotate._y;
1297 float zw = rotate._z * rotate._w;
1298 float zx = rotate._z * rotate._x;
1299 float yw = rotate._y * rotate._w;
1300 float yz = rotate._y * rotate._z;
1301 float xw = rotate._x * rotate._w;
1302
1303 p[0] = scale._x * (1.0f - 2.0f * (yy + zz));
1304 p[1] = scale._x * (2.0f * (xy + zw));
1305 p[2] = scale._x * (2.0f * (zx - yw));
1306 p[3] = 0.0f;
1307
1308 p[4] = scale._y * (2.0f * (xy - zw));
1309 p[5] = scale._y * (1.0f - 2.0f * (zz + xx));
1310 p[6] = scale._y * (2.0f * (yz + xw));
1311 p[7] = 0.0f;
1312
1313 p[8] = scale._z * (2.0f * (zx + yw));
1314 p[9] = scale._z * (2.0f * (yz - xw));
1315 p[10] = scale._z * (1.0f - 2.0f * (yy + xx));
1316 p[11] = 0.0f;
1317
1318 p[12] = translate._x;
1319 p[13] = translate._y;
1320 p[14] = translate._z;
1321 p[15] = 1.0f;
1322
1323 return m;
1324 }

◆ Reverse()

Matrix BrawlLib.Internal.Matrix.Reverse ( )
inline
304 {
305 Matrix m;
306 float* pOut = (float*) &m;
307 fixed (float* p = _values)
308 {
309 for (int y = 0; y < 4; y++)
310 {
311 for (int x = 0; x < 4; x++)
312 {
313 *pOut++ = p[(x << 2) + y];
314 }
315 }
316 }
317
318 return m;
319 }

◆ ReverseInfluenceMatrix()

static Matrix BrawlLib.Internal.Matrix.ReverseInfluenceMatrix ( List< BoneWeight weights)
inlinestatic
398 {
399 Matrix m = new Matrix();
400 foreach (BoneWeight w in weights)
401 {
402 if (w.Bone != null)
403 {
404 m += w.Bone.InverseMatrix * w.Bone.BindMatrix * w.Weight;
405 }
406 }
407
408 return m;
409 }

◆ ReverseLookat()

static Matrix BrawlLib.Internal.Matrix.ReverseLookat ( Vector3  eye,
Vector3  target,
float  roll 
)
inlinestatic
1439 {
1440 Vector3 up = new Vector3(-(float) Math.Sin(roll * Maths._deg2radf),
1441 (float) Math.Cos(roll * Maths._deg2radf), 0);
1442
1443 Vector3 zaxis = (target - eye).Normalize();
1444 Vector3 xaxis = up.Cross(zaxis).Normalize();
1445 Vector3 yaxis = xaxis.Cross(zaxis).Normalize();
1446
1447 Matrix m = Identity;
1448 float* pOut = (float*) &m;
1449
1450 pOut[0] = xaxis._x;
1451 pOut[1] = yaxis._x;
1452 pOut[2] = zaxis._x;
1453
1454 pOut[4] = xaxis._y;
1455 pOut[5] = yaxis._y;
1456 pOut[6] = zaxis._y;
1457
1458 pOut[8] = xaxis._z;
1459 pOut[9] = yaxis._z;
1460 pOut[10] = zaxis._z;
1461
1462 eye._x = -eye._x;
1463 eye._y = -eye._y;
1464 eye._z = -eye._z;
1465
1466 pOut[12] = eye._x * pOut[0] + eye._y * pOut[4] + eye._z * pOut[8];
1467 pOut[13] = eye._x * pOut[1] + eye._y * pOut[5] + eye._z * pOut[9];
1468 pOut[14] = eye._x * pOut[2] + eye._y * pOut[6] + eye._z * pOut[10];
1469
1470 return m;
1471 }

◆ ReverseOrthographicMatrix() [1/4]

static Matrix BrawlLib.Internal.Matrix.ReverseOrthographicMatrix ( float  left,
float  right,
float  top,
float  bottom,
float  nearZ,
float  farZ 
)
inlinestatic
1155 {
1156 Matrix m = Identity;
1157
1158 float* p = (float*) &m;
1159
1160 float rl = right - left;
1161 float tb = top - bottom;
1162 float fn = farZ - nearZ;
1163
1164 p[0] = rl / 2.0f;
1165 p[5] = tb / 2.0f;
1166 p[10] = fn / -2.0f;
1167
1168 p[12] = (right + left) / 2.0f;
1169 p[13] = (top + bottom) / 2.0f;
1170 p[14] = (farZ + nearZ) / 2.0f;
1171
1172 return m;
1173 }

◆ ReverseOrthographicMatrix() [2/4]

static Matrix BrawlLib.Internal.Matrix.ReverseOrthographicMatrix ( float  w,
float  h,
float  nearZ,
float  farZ 
)
inlinestatic
1149 {
1150 return ReverseOrthographicMatrix(-w / 2, w / 2, h / 2, -h / 2, nearZ, farZ);
1151 }
static Matrix ReverseOrthographicMatrix(Vector4 dimensions, Vector2 depth)
Definition: Matrix.cs:1138

◆ ReverseOrthographicMatrix() [3/4]

static Matrix BrawlLib.Internal.Matrix.ReverseOrthographicMatrix ( Vector4  dimensions,
float  nearZ,
float  farZ 
)
inlinestatic
1144 {
1145 return ReverseOrthographicMatrix(dimensions._x, dimensions._y, dimensions._z, dimensions._w, nearZ, farZ);
1146 }

◆ ReverseOrthographicMatrix() [4/4]

static Matrix BrawlLib.Internal.Matrix.ReverseOrthographicMatrix ( Vector4  dimensions,
Vector2  depth 
)
inlinestatic
1139 {
1140 return ReverseOrthographicMatrix(dimensions, depth._x, depth._y);
1141 }

◆ ReversePerspectiveMatrix()

static Matrix BrawlLib.Internal.Matrix.ReversePerspectiveMatrix ( float  fovY,
float  aspect,
float  nearZ,
float  farZ 
)
inlinestatic
1195 {
1196 Matrix m;
1197
1198 float* p = (float*) &m;
1199
1200 float cotan = (float) (1.0 / Math.Tan(fovY / 2 * Math.PI / 180.0));
1201 float val = 2.0f * farZ * nearZ / (nearZ - farZ);
1202
1203 p[0] = aspect / cotan;
1204 p[5] = 1.0f / cotan;
1205 p[11] = 1.0f / val;
1206 p[14] = -1.0f;
1207 p[15] = (farZ + nearZ) / (nearZ - farZ) / val;
1208
1209 p[1] = p[2] = p[3] = p[4] = p[6] = p[7] = p[8] = p[9] = p[10] = p[12] = p[13] = 0.0f;
1210
1211 return m;
1212 }

◆ ReverseQuaternionTransformMatrix()

static Matrix BrawlLib.Internal.Matrix.ReverseQuaternionTransformMatrix ( Vector3  scale,
Vector4  rotate,
Vector3  translate 
)
inlinestatic
1327 {
1328 Matrix m;
1329 float* p = (float*) &m;
1330
1331 float xx = rotate._x * rotate._x;
1332 float yy = rotate._y * rotate._y;
1333 float zz = rotate._z * rotate._z;
1334 float xy = rotate._x * rotate._y;
1335 float zw = rotate._z * rotate._w;
1336 float zx = rotate._z * rotate._x;
1337 float yw = rotate._y * rotate._w;
1338 float yz = rotate._y * rotate._z;
1339 float xw = rotate._x * rotate._w;
1340
1341 scale._x = 1 / scale._x;
1342 scale._y = 1 / scale._y;
1343 scale._z = 1 / scale._z;
1344 translate._x = -translate._x;
1345 translate._y = -translate._y;
1346 translate._z = -translate._z;
1347
1348 p[0] = scale._x * (1.0f - 2.0f * (yy + zz));
1349 p[1] = scale._x * (2.0f * (xy + zw));
1350 p[2] = scale._x * (2.0f * (zx - yw));
1351 p[3] = 0.0f;
1352
1353 p[4] = scale._y * (2.0f * (xy - zw));
1354 p[5] = scale._y * (1.0f - 2.0f * (zz + xx));
1355 p[6] = scale._y * (2.0f * (yz + xw));
1356 p[7] = 0.0f;
1357
1358 p[8] = scale._z * (2.0f * (zx + yw));
1359 p[9] = scale._z * (2.0f * (yz - xw));
1360 p[10] = scale._z * (1.0f - 2.0f * (yy + xx));
1361 p[11] = 0.0f;
1362
1363 p[12] = translate._x * p[0] + translate._y * p[4] + translate._z * p[8];
1364 p[13] = translate._x * p[1] + translate._y * p[5] + translate._z * p[9];
1365 p[14] = translate._x * p[2] + translate._y * p[6] + translate._z * p[10];
1366 p[15] = 1.0f;
1367
1368 return m;
1369 }

◆ ReverseRotationMatrix() [1/2]

static Matrix BrawlLib.Internal.Matrix.ReverseRotationMatrix ( float  x,
float  y,
float  z 
)
inlinestatic
501 {
502 float cosx = (float) Math.Cos(x * Maths._deg2radf);
503 float sinx = (float) Math.Sin(x * Maths._deg2radf);
504 float cosy = (float) Math.Cos(y * Maths._deg2radf);
505 float siny = (float) Math.Sin(y * Maths._deg2radf);
506 float cosz = (float) Math.Cos(z * Maths._deg2radf);
507 float sinz = (float) Math.Sin(z * Maths._deg2radf);
508
509 Matrix m = Identity;
510 float* p = (float*) &m;
511
512 p[0] = cosy * cosz;
513 p[1] = sinx * siny * cosz - cosx * sinz;
514 p[2] = cosx * siny * cosz + sinx * sinz;
515 p[4] = cosy * sinz;
516 p[5] = sinx * siny * sinz + cosx * cosz;
517 p[6] = cosx * siny * sinz - sinx * cosz;
518 p[8] = -siny;
519 p[9] = sinx * cosy;
520 p[10] = cosx * cosy;
521
522 return m;
523 }

◆ ReverseRotationMatrix() [2/2]

static Matrix BrawlLib.Internal.Matrix.ReverseRotationMatrix ( Vector3  angles)
inlinestatic
496 {
497 return ReverseRotationMatrix(angles._x, angles._y, angles._z);
498 }
static Matrix ReverseRotationMatrix(Vector3 angles)
Definition: Matrix.cs:495

◆ ReverseTransformMatrix()

static Matrix BrawlLib.Internal.Matrix.ReverseTransformMatrix ( Vector3  scale,
Vector3  rotation,
Vector3  translation 
)
inlinestatic
1247 {
1248 float cosx = (float) Math.Cos(rotation._x * Maths._deg2radf);
1249 float sinx = (float) Math.Sin(rotation._x * Maths._deg2radf);
1250 float cosy = (float) Math.Cos(rotation._y * Maths._deg2radf);
1251 float siny = (float) Math.Sin(rotation._y * Maths._deg2radf);
1252 float cosz = (float) Math.Cos(rotation._z * Maths._deg2radf);
1253 float sinz = (float) Math.Sin(rotation._z * Maths._deg2radf);
1254
1255 scale._x = 1 / scale._x;
1256 scale._y = 1 / scale._y;
1257 scale._z = 1 / scale._z;
1258 translation._x = -translation._x;
1259 translation._y = -translation._y;
1260 translation._z = -translation._z;
1261
1262 Matrix m;
1263 float* p = (float*) &m;
1264
1265 p[0] = scale._x * cosy * cosz;
1266 p[1] = scale._y * (sinx * siny * cosz - cosx * sinz);
1267 p[2] = scale._z * (cosx * siny * cosz + sinx * sinz);
1268 p[3] = 0.0f;
1269
1270 p[4] = scale._x * cosy * sinz;
1271 p[5] = scale._y * (sinx * siny * sinz + cosx * cosz);
1272 p[6] = scale._z * (cosx * siny * sinz - sinx * cosz);
1273 p[7] = 0.0f;
1274
1275 p[8] = -scale._x * siny;
1276 p[9] = scale._y * sinx * cosy;
1277 p[10] = scale._z * cosx * cosy;
1278 p[11] = 0.0f;
1279
1280 p[12] = translation._x * p[0] + translation._y * p[4] + translation._z * p[8];
1281 p[13] = translation._x * p[1] + translation._y * p[5] + translation._z * p[9];
1282 p[14] = translation._x * p[2] + translation._y * p[6] + translation._z * p[10];
1283 p[15] = 1.0f;
1284
1285 return m;
1286 }

◆ ReverseTranslationMatrix() [1/2]

static Matrix BrawlLib.Internal.Matrix.ReverseTranslationMatrix ( float  x,
float  y,
float  z 
)
inlinestatic
374 {
375 Matrix m = Identity;
376 float* p = (float*) &m;
377 p[12] = -x - y - z;
378 p[13] = -x - y - z;
379 p[14] = -x - y - z;
380 return m;
381 }

◆ ReverseTranslationMatrix() [2/2]

static Matrix BrawlLib.Internal.Matrix.ReverseTranslationMatrix ( Vector3  v)
inlinestatic
369 {
370 return ReverseTranslationMatrix(v._x, v._y, v._z);
371 }
static Matrix ReverseTranslationMatrix(Vector3 v)
Definition: Matrix.cs:368

◆ RotateX()

void BrawlLib.Internal.Matrix.RotateX ( float  x)
inline
751 {
752 float var1, var2;
753 float cosx = (float) Math.Cos(x / 180.0f * Math.PI);
754 float sinx = (float) Math.Sin(x / 180.0f * Math.PI);
755
756 fixed (float* p = _values)
757 {
758 var1 = p[4];
759 var2 = p[8];
760 p[4] = var1 * cosx + var2 * sinx;
761 p[8] = var1 * -sinx + var2 * cosx;
762
763 var1 = p[5];
764 var2 = p[9];
765 p[5] = var1 * cosx + var2 * sinx;
766 p[9] = var1 * -sinx + var2 * cosx;
767
768 var1 = p[6];
769 var2 = p[10];
770 p[6] = var1 * cosx + var2 * sinx;
771 p[10] = var1 * -sinx + var2 * cosx;
772 }
773 }

◆ RotateY()

void BrawlLib.Internal.Matrix.RotateY ( float  y)
inline
776 {
777 float var1, var2;
778 float cosy = (float) Math.Cos(y / 180.0f * Math.PI);
779 float siny = (float) Math.Sin(y / 180.0f * Math.PI);
780
781 fixed (float* p = _values)
782 {
783 var1 = p[0];
784 var2 = p[8];
785 p[0] = var1 * cosy + var2 * -siny;
786 p[8] = var1 * siny + var2 * cosy;
787
788 var1 = p[1];
789 var2 = p[9];
790 p[1] = var1 * cosy + var2 * -siny;
791 p[9] = var1 * siny + var2 * cosy;
792
793 var1 = p[2];
794 var2 = p[10];
795 p[2] = var1 * cosy + var2 * -siny;
796 p[10] = var1 * siny + var2 * cosy;
797 }
798 }

◆ RotateZ()

void BrawlLib.Internal.Matrix.RotateZ ( float  z)
inline
801 {
802 float var1, var2;
803 float cosz = (float) Math.Cos(z / 180.0f * Math.PI);
804 float sinz = (float) Math.Sin(z / 180.0f * Math.PI);
805
806 fixed (float* p = _values)
807 {
808 var1 = p[0];
809 var2 = p[4];
810 p[0] = var1 * cosz + var2 * sinz;
811 p[4] = var1 * -sinz + var2 * cosz;
812
813 var1 = p[1];
814 var2 = p[5];
815 p[1] = var1 * cosz + var2 * sinz;
816 p[5] = var1 * -sinz + var2 * cosz;
817
818 var1 = p[2];
819 var2 = p[6];
820 p[2] = var1 * cosz + var2 * sinz;
821 p[6] = var1 * -sinz + var2 * cosz;
822 }
823 }

◆ RotationAboutX()

static Matrix BrawlLib.Internal.Matrix.RotationAboutX ( float  angle)
inlinestatic
412 {
413 angle *= Maths._deg2radf;
414
415 Matrix m = Identity;
416 float* p = (float*) &m;
417
418 float cos = (float) Math.Cos(angle);
419 float sin = (float) Math.Sin(angle);
420
421 m[5] = cos;
422 m[6] = -sin;
423 m[9] = sin;
424 m[10] = cos;
425
426 return m;
427 }

◆ RotationAboutY()

static Matrix BrawlLib.Internal.Matrix.RotationAboutY ( float  angle)
inlinestatic
430 {
431 angle *= Maths._deg2radf;
432
433 Matrix m = Identity;
434 float* p = (float*) &m;
435
436 float cos = (float) Math.Cos(angle);
437 float sin = (float) Math.Sin(angle);
438
439 m[0] = cos;
440 m[2] = sin;
441 m[8] = -sin;
442 m[10] = cos;
443
444 return m;
445 }

◆ RotationAboutZ()

static Matrix BrawlLib.Internal.Matrix.RotationAboutZ ( float  angle)
inlinestatic
448 {
449 angle *= Maths._deg2radf;
450
451 Matrix m = Identity;
452 float* p = (float*) &m;
453
454 float cos = (float) Math.Cos(angle);
455 float sin = (float) Math.Sin(angle);
456
457 m[0] = cos;
458 m[1] = -sin;
459 m[4] = sin;
460 m[5] = cos;
461
462 return m;
463 }

◆ RotationMatrix() [1/2]

static Matrix BrawlLib.Internal.Matrix.RotationMatrix ( float  x,
float  y,
float  z 
)
inlinestatic
471 {
472 float cosx = (float) Math.Cos(x * Maths._deg2radf);
473 float sinx = (float) Math.Sin(x * Maths._deg2radf);
474 float cosy = (float) Math.Cos(y * Maths._deg2radf);
475 float siny = (float) Math.Sin(y * Maths._deg2radf);
476 float cosz = (float) Math.Cos(z * Maths._deg2radf);
477 float sinz = (float) Math.Sin(z * Maths._deg2radf);
478
479 Matrix m = Identity;
480 float* p = (float*) &m;
481
482 m[0] = cosy * cosz;
483 m[1] = sinz * cosy;
484 m[2] = -siny;
485 m[4] = sinx * cosz * siny - cosx * sinz;
486 m[5] = sinx * sinz * siny + cosz * cosx;
487 m[6] = sinx * cosy;
488 m[8] = sinx * sinz + cosx * cosz * siny;
489 m[9] = cosx * sinz * siny - sinx * cosz;
490 m[10] = cosx * cosy;
491
492 return m;
493 }

◆ RotationMatrix() [2/2]

static Matrix BrawlLib.Internal.Matrix.RotationMatrix ( Vector3  angles)
inlinestatic
466 {
467 return RotationMatrix(angles._x, angles._y, angles._z);
468 }
static Matrix RotationMatrix(Vector3 angles)
Definition: Matrix.cs:465

◆ ScaleMatrix() [1/2]

static Matrix BrawlLib.Internal.Matrix.ScaleMatrix ( float  x,
float  y,
float  z 
)
inlinestatic
343 {
344 Matrix m = new Matrix();
345 float* p = (float*) &m;
346 p[0] = x;
347 p[5] = y;
348 p[10] = z;
349 p[15] = 1.0f;
350 return m;
351 }

◆ ScaleMatrix() [2/2]

static Matrix BrawlLib.Internal.Matrix.ScaleMatrix ( Vector3  scale)
inlinestatic
338 {
339 return ScaleMatrix(scale._x, scale._y, scale._z);
340 }
static Matrix ScaleMatrix(Vector3 scale)
Definition: Matrix.cs:337

◆ ToString()

override string BrawlLib.Internal.Matrix.ToString ( )
inline
1607 {
1608 return CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator.Contains(",")
1609 ? $"({this[0]} {this[1]} {this[2]} {this[3]})({this[4]} {this[5]} {this[6]} {this[7]})({this[8]} {this[9]} {this[10]} {this[11]})({this[12]} {this[13]} {this[14]} {this[15]})"
1610 : $"({this[0]},{this[1]},{this[2]},{this[3]})({this[4]},{this[5]},{this[6]},{this[7]})({this[8]},{this[9]},{this[10]},{this[11]})({this[12]},{this[13]},{this[14]},{this[15]})";
1611 }

◆ TransformMatrix()

static Matrix BrawlLib.Internal.Matrix.TransformMatrix ( Vector3  scale,
Vector3  rotate,
Vector3  translate 
)
inlinestatic
1215 {
1216 Matrix m;
1217 float* d = (float*) &m;
1218
1219 float cosx = (float) Math.Cos(rotate._x * Maths._deg2radf);
1220 float sinx = (float) Math.Sin(rotate._x * Maths._deg2radf);
1221 float cosy = (float) Math.Cos(rotate._y * Maths._deg2radf);
1222 float siny = (float) Math.Sin(rotate._y * Maths._deg2radf);
1223 float cosz = (float) Math.Cos(rotate._z * Maths._deg2radf);
1224 float sinz = (float) Math.Sin(rotate._z * Maths._deg2radf);
1225
1226 d[0] = scale._x * cosy * cosz;
1227 d[1] = scale._x * sinz * cosy;
1228 d[2] = -scale._x * siny;
1229 d[3] = 0.0f;
1230 d[4] = scale._y * (sinx * cosz * siny - cosx * sinz);
1231 d[5] = scale._y * (sinx * sinz * siny + cosz * cosx);
1232 d[6] = scale._y * sinx * cosy;
1233 d[7] = 0.0f;
1234 d[8] = scale._z * (sinx * sinz + cosx * cosz * siny);
1235 d[9] = scale._z * (cosx * sinz * siny - sinx * cosz);
1236 d[10] = scale._z * cosx * cosy;
1237 d[11] = 0.0f;
1238 d[12] = translate._x;
1239 d[13] = translate._y;
1240 d[14] = translate._z;
1241 d[15] = 1.0f;
1242
1243 return m;
1244 }

◆ Translate() [1/2]

void BrawlLib.Internal.Matrix.Translate ( float  x,
float  y,
float  z 
)
inline
531 {
532 fixed (float* p = _values)
533 {
534 p[12] += p[0] * x + p[4] * y + p[8] * z;
535 p[13] += p[1] * x + p[5] * y + p[9] * z;
536 p[14] += p[2] * x + p[6] * y + p[10] * z;
537 p[15] += p[3] * x + p[7] * y + p[11] * z;
538 }
539 }

◆ Translate() [2/2]

void BrawlLib.Internal.Matrix.Translate ( Vector3  v)
inline
526 {
527 Translate(v._x, v._y, v._z);
528 }
void Translate(Vector3 v)
Definition: Matrix.cs:525

◆ TranslationMatrix() [1/2]

static Matrix BrawlLib.Internal.Matrix.TranslationMatrix ( float  x,
float  y,
float  z 
)
inlinestatic
359 {
360 Matrix m = Identity;
361 float* p = (float*) &m;
362 p[12] = x;
363 p[13] = y;
364 p[14] = z;
365 return m;
366 }

◆ TranslationMatrix() [2/2]

static Matrix BrawlLib.Internal.Matrix.TranslationMatrix ( Vector3  v)
inlinestatic
354 {
355 return TranslationMatrix(v._x, v._y, v._z);
356 }
static Matrix TranslationMatrix(Vector3 v)
Definition: Matrix.cs:353

Member Data Documentation

◆ Identity

readonly Matrix BrawlLib.Internal.Matrix.Identity = ScaleMatrix(1.0f, 1.0f, 1.0f)
static

Property Documentation

◆ Col0

Vector4 BrawlLib.Internal.Matrix.Col0
getset
62 {
63 get => new Vector4(Data[0], Data[4], Data[8], Data[12]);
64 set
65 {
66 Data[0] = value._x;
67 Data[4] = value._y;
68 Data[8] = value._z;
69 Data[12] = value._w;
70 }
71 }

◆ Col1

Vector4 BrawlLib.Internal.Matrix.Col1
getset
74 {
75 get => new Vector4(Data[1], Data[5], Data[9], Data[13]);
76 set
77 {
78 Data[1] = value._x;
79 Data[5] = value._y;
80 Data[9] = value._z;
81 Data[13] = value._w;
82 }
83 }

◆ Col2

Vector4 BrawlLib.Internal.Matrix.Col2
getset
86 {
87 get => new Vector4(Data[2], Data[6], Data[10], Data[14]);
88 set
89 {
90 Data[2] = value._x;
91 Data[6] = value._y;
92 Data[10] = value._z;
93 Data[14] = value._w;
94 }
95 }

◆ Col3

Vector4 BrawlLib.Internal.Matrix.Col3
getset
98 {
99 get => new Vector4(Data[3], Data[7], Data[11], Data[15]);
100 set
101 {
102 Data[3] = value._x;
103 Data[7] = value._y;
104 Data[11] = value._z;
105 Data[15] = value._w;
106 }
107 }

◆ Data

float* BrawlLib.Internal.Matrix.Data
get
254 {
255 get
256 {
257 fixed (float* ptr = _values)
258 {
259 return ptr;
260 }
261 }
262 }

◆ M11

float BrawlLib.Internal.Matrix.M11
getset

Row 1, Column 1

113 {
114 get => Data[0];
115 set => Data[0] = value;
116 }

◆ M12

float BrawlLib.Internal.Matrix.M12
getset

Row 1, Column 2

122 {
123 get => Data[1];
124 set => Data[1] = value;
125 }

◆ M13

float BrawlLib.Internal.Matrix.M13
getset

Row 1, Column 3

131 {
132 get => Data[2];
133 set => Data[2] = value;
134 }

◆ M14

float BrawlLib.Internal.Matrix.M14
getset

Row 1, Column 4

140 {
141 get => Data[3];
142 set => Data[3] = value;
143 }

◆ M21

float BrawlLib.Internal.Matrix.M21
getset

Row 2, Column 1

149 {
150 get => Data[4];
151 set => Data[4] = value;
152 }

◆ M22

float BrawlLib.Internal.Matrix.M22
getset

Row 2, Column 2

158 {
159 get => Data[5];
160 set => Data[5] = value;
161 }

◆ M23

float BrawlLib.Internal.Matrix.M23
getset

Row 2, Column 3

167 {
168 get => Data[6];
169 set => Data[6] = value;
170 }

◆ M24

float BrawlLib.Internal.Matrix.M24
getset

Row 2, Column 4

176 {
177 get => Data[7];
178 set => Data[7] = value;
179 }

◆ M31

float BrawlLib.Internal.Matrix.M31
getset

Row 3, Column 1

185 {
186 get => Data[8];
187 set => Data[8] = value;
188 }

◆ M32

float BrawlLib.Internal.Matrix.M32
getset

Row 3, Column 2

194 {
195 get => Data[9];
196 set => Data[9] = value;
197 }

◆ M33

float BrawlLib.Internal.Matrix.M33
getset

Row 3, Column 3

203 {
204 get => Data[10];
205 set => Data[10] = value;
206 }

◆ M34

float BrawlLib.Internal.Matrix.M34
getset

Row 3, Column 4

212 {
213 get => Data[11];
214 set => Data[11] = value;
215 }

◆ M41

float BrawlLib.Internal.Matrix.M41
getset

Row 4, Column 1

221 {
222 get => Data[12];
223 set => Data[12] = value;
224 }

◆ M42

float BrawlLib.Internal.Matrix.M42
getset

Row 4, Column 2

230 {
231 get => Data[13];
232 set => Data[13] = value;
233 }

◆ M43

float BrawlLib.Internal.Matrix.M43
getset

Row 4, Column 3

239 {
240 get => Data[14];
241 set => Data[14] = value;
242 }

◆ M44

float BrawlLib.Internal.Matrix.M44
getset

Row 4, Column 4

248 {
249 get => Data[15];
250 set => Data[15] = value;
251 }

◆ Row0

Vector4 BrawlLib.Internal.Matrix.Row0
getset
38 {
39 get => *(Vector4*) &Data[0];
40 set => *(Vector4*) &Data[0] = value;
41 }

◆ Row1

Vector4 BrawlLib.Internal.Matrix.Row1
getset
44 {
45 get => *(Vector4*) &Data[4];
46 set => *(Vector4*) &Data[4] = value;
47 }

◆ Row2

Vector4 BrawlLib.Internal.Matrix.Row2
getset
50 {
51 get => *(Vector4*) &Data[8];
52 set => *(Vector4*) &Data[8] = value;
53 }

◆ Row3

Vector4 BrawlLib.Internal.Matrix.Row3
getset
56 {
57 get => *(Vector4*) &Data[12];
58 set => *(Vector4*) &Data[12] = value;
59 }

◆ this[int index]

float BrawlLib.Internal.Matrix.this[int index]
getset
271 {
272 get => Data[index];
273 set => Data[index] = value;
274 }

◆ this[int x, int y]

float BrawlLib.Internal.Matrix.this[int x, int y]
getset
265 {
266 get => Data[(y << 2) + x];
267 set => Data[(y << 2) + x] = value;
268 }

The documentation for this struct was generated from the following file: