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.Matrix34 Struct Reference

Public Member Functions

 Matrix34 (params float[] values)
 
void Translate (float x, float y, float z)
 
Matrix34 GetTranslation ()
 
void RotateX (float x)
 
void RotateY (float y)
 
void RotateZ (float z)
 
void Multiply (Matrix34 *m)
 
Vector3 Multiply (Vector3 v)
 
void Add (Matrix34 *m)
 
void Subtract (Matrix34 *m)
 
override bool Equals (object obj)
 
override int GetHashCode ()
 
override string ToString ()
 

Static Public Member Functions

static Matrix34 ScaleMatrix (float x, float y, float z)
 
static Matrix34 TranslationMatrix (float x, float y, float z)
 
static Matrix34 RotationMatrixX (float x)
 
static Matrix34 RotationMatrixRX (float x)
 
static Matrix34 RotationMatrixY (float y)
 
static Matrix34 RotationMatrixRY (float y)
 
static Matrix34 RotationMatrix (float x, float y, float z)
 
static Matrix34 TransformationMatrix (Vector3 scale, Vector3 rotation, Vector3 translation)
 
static Matrix34 ReverseTransformMatrix (Vector3 scale, Vector3 rotation, Vector3 translation)
 
static Matrix34 TextureMatrix (TextureFrameState state)
 
static Matrix34 EnvironmentTexMtx ()
 
static Matrix EnvCamMap (int refCam, SCN0Node node, ModelPanelViewport v, float frame)
 
static Matrix EnvLightMap (int refLight, SCN0Node node, ModelPanelViewport v, float frame)
 
static Matrix ProjectionMapping (int ref_camera, SCN0Node node, ModelPanelViewport v, float frame)
 
static Matrix EnvSpecMap (int refCam, int refLight, SCN0Node node, ModelPanelViewport v, float frame)
 This function returns a texture matrix that will aim the texture to the midpoint between the active camera and the given reference camera or light. More...
 
static Matrix34 operator* (Matrix34 m1, Matrix34 m2)
 
static bool operator== (Matrix34 m1, Matrix34 m2)
 
static bool operator!= (Matrix34 m1, Matrix34 m2)
 

Static Public Attributes

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

Properties

float this[int index] [get, set]
 

Constructor & Destructor Documentation

◆ Matrix34()

BrawlLib.Internal.Matrix34.Matrix34 ( params float[]  values)
inline
21 {
22 fixed (float* b = _data)
23 {
24 for (int i = 0; i < Math.Min(12, values.Length); i++)
25 {
26 b[i] = values[i];
27 }
28 }
29 }

Member Function Documentation

◆ Add()

void BrawlLib.Internal.Matrix34.Add ( Matrix34 m)
inline
1081 {
1082 float* s = (float*) m;
1083 fixed (float* d = _data)
1084 {
1085 for (int i = 0; i < 12; i++)
1086 {
1087 d[i] += s[i];
1088 }
1089 }
1090 }

◆ EnvCamMap()

static Matrix BrawlLib.Internal.Matrix34.EnvCamMap ( int  refCam,
SCN0Node  node,
ModelPanelViewport  v,
float  frame 
)
inlinestatic
748 {
749 GLCamera cam = v.Camera;
750 if (refCam >= 0 && node?.CameraGroup != null && refCam < node.CameraGroup.Children.Count)
751 {
752 SCN0CameraNode camNode = (SCN0CameraNode) node.CameraGroup.Children[refCam];
753 camNode.GetModelViewMatrix(frame, out Matrix cm, out Matrix cmInv);
754 return (Matrix) EnvironmentTexMtx() * cm.GetRotationMatrix();
755 }
756
757 return (Matrix) EnvironmentTexMtx() * v.Camera._matrix.GetRotationMatrix();
758 }
Definition: GLCamera.cs:8
Matrix _matrix
Definition: GLCamera.cs:9
GLCamera Camera
Definition: GLViewport.cs:54
List< ResourceNode > Children
Definition: ResourceNode.cs:262
Definition: SCN0CameraNode.cs:12
void GetModelViewMatrix(float frame, out Matrix mtx, out Matrix inverse)
mtx is from camera to world space (a point in camera space) inverse is from world to camera space (a ...
Definition: SCN0CameraNode.cs:212
SCN0GroupNode CameraGroup
Definition: SCN0Node.cs:65
static Matrix34 EnvironmentTexMtx()
Definition: Matrix34.cs:679

◆ EnvironmentTexMtx()

static Matrix34 BrawlLib.Internal.Matrix34.EnvironmentTexMtx ( )
inlinestatic
680 {
681 Matrix34 m = Identity;
682 m[0] = 0.5f;
683 m[3] = 0.5f;
684 m[5] = -0.5f;
685 m[7] = 0.5f;
686 m[10] = 0.0f;
687 m[11] = 1.0f;
688 return m;
689 }
Matrix34(params float[] values)
Definition: Matrix34.cs:20
static readonly Matrix34 Identity
Definition: Matrix34.cs:16

◆ EnvLightMap()

static Matrix BrawlLib.Internal.Matrix34.EnvLightMap ( int  refLight,
SCN0Node  node,
ModelPanelViewport  v,
float  frame 
)
inlinestatic
761 {
762 Matrix m = Matrix.Identity;
763 GLCamera cam = v.Camera;
764 Matrix camMtx = cam._matrix;
765 Matrix invCamMtx = cam._matrixInverse;
766
767 Matrix34 envMtx = new Matrix34(
768 0.5f, 0.0f, 0.0f, 0.5f,
769 0.0f, -0.5f, 0.0f, 0.5f,
770 0.0f, 0.0f, 0.0f, 1.0f);
771
772 //If no light is referenced, use the BrawlCrate built-in light
773 if (refLight < 0 || node?.LightGroup != null && refLight >= node.LightGroup.Children.Count)
774 {
775 refLight = 0;
776 node = null;
777 }
778
779 // The light position and direction needs to be transformed with the camera's inverse matrix.
780 Vector3 vLook, camUp, vRight, vUp;
781
782 vLook = GetLightLook(node, refLight, invCamMtx, v, frame, out bool specEnabled).Normalize();
783
784 // Calculate without using a target because the margin of error for calculations must be taken into account when the light is far away.
785 // Take the absolute value as a measure against transformation margin.
786 if (Math.Abs(vLook._x) < 0.000001f &&
787 Math.Abs(vLook._z) < 0.000001f)
788 {
789 camUp._x = camUp._y = 0.0f;
790 if (vLook._y <= 0.0f)
791 {
792 // Look straight down
793 camUp._z = -1.0f;
794 }
795 else
796 {
797 // Look straight up
798 camUp._z = 1.0f;
799 }
800 }
801 else
802 {
803 camUp._x = camUp._z = 0.0f;
804 camUp._y = 1.0f;
805 }
806
807 vUp = (vRight = vLook.Cross(camUp).Normalize()).Cross(vLook);
808
809 Matrix34 m34 = new Matrix34(
810 vRight._x, vRight._y, vRight._z, 0.0f,
811 vUp._x, vUp._y, vUp._z, 0.0f,
812 -vLook._x, -vLook._y, -vLook._z, 0.0f);
813
814 m34 = (Matrix34) ((Matrix) m34 * invCamMtx);
815
816 m34[3] = 0.0f;
817 m34[7] = 0.0f;
818 m34[11] = 0.0f;
819
820 return (Matrix) (envMtx * m34);
821
822 //return (Matrix)envMtx * Matrix.RotationMatrix(new Vector3().LookatAngles((Vector3)v._posLight) * Maths._rad2degf);
823 }
Matrix _matrixInverse
Definition: GLCamera.cs:10
SCN0GroupNode LightGroup
Definition: SCN0Node.cs:51
Vector3 Normalize()
Definition: Vector3.cs:507

◆ EnvSpecMap()

static Matrix BrawlLib.Internal.Matrix34.EnvSpecMap ( int  refCam,
int  refLight,
SCN0Node  node,
ModelPanelViewport  v,
float  frame 
)
inlinestatic

This function returns a texture matrix that will aim the texture to the midpoint between the active camera and the given reference camera or light.

888 {
889 // Normal environmental map when neither the light nor the camera is specified.
890 Matrix34 finalMtx = EnvironmentTexMtx();
891
892 GLCamera cam = v.Camera;
893 Vector3 vLook, camUp, camLook;
894 Matrix camMtx = cam._matrixInverse;
895 Matrix invCamMtx = cam._matrix;
896
897 Matrix34 m34 = (Matrix34) camMtx;
898 camLook._x = -m34[8];
899 camLook._y = -m34[9];
900 camLook._z = -m34[10];
901
902 if (refLight >= 0)
903 {
904 Vector3 lgtLook = GetLightLook(node, refLight, invCamMtx, v, frame, out bool specEnabled);
905
906 // Specular light is already set as a vector taking the center position.
907 if (!specEnabled)
908 {
909 vLook = GetHalfAngle(camLook, lgtLook);
910 }
911 else
912 {
913 vLook = -lgtLook;
914 }
915
916 if (Math.Abs(vLook._x) < 0.000001f &&
917 Math.Abs(vLook._z) < 0.000001f)
918 {
919 camUp._x = camUp._y = 0.0f;
920 if (vLook._y <= 0.0f)
921 {
922 // Look straight down
923 camUp._z = -1.0f;
924 }
925 else
926 {
927 // Look straight up
928 camUp._z = 1.0f;
929 }
930 }
931 else
932 {
933 camUp._x = camUp._z = 0.0f;
934 camUp._y = 1.0f;
935 }
936 }
937 else if (refCam >= 0)
938 {
939 SCN0CameraNode camNode = null;
940
941 if (node?.CameraGroup != null && refCam < node.CameraGroup.Children.Count)
942 {
943 camNode = (SCN0CameraNode) node.CameraGroup.Children[refCam];
944 }
945 else
946 {
947 camNode = new SCN0CameraNode();
948 }
949
950 camNode.GetModelViewMatrix(frame, out Matrix cM, out Matrix cMInv);
951
952 // Map from the midpoint of the view camera and the specified camera.
953 Matrix34 lgtCam = (Matrix34) cM;
954 camUp._x = lgtCam[4];
955 camUp._y = lgtCam[5];
956 camUp._z = lgtCam[6];
957 Vector3 lgtLook = new Vector3(-lgtCam[8], -lgtCam[9], -lgtCam[10]);
958
959 vLook = GetHalfAngle(camLook, lgtLook);
960 }
961 else
962 {
963 return (Matrix) finalMtx;
964 }
965
966 vLook.Normalize();
967 Vector3 vRight, vUp;
968
969 vUp = (vRight = vLook.Cross(camUp).Normalize()).Cross(vLook);
970 m34 = new Matrix34(
971 vRight._x, vRight._y, vRight._z, 0.0f,
972 vUp._x, vUp._y, vUp._z, 0.0f,
973 vLook._x, vLook._y, vLook._z, 0.0f);
974
975 m34 = (Matrix34) ((Matrix) m34 * invCamMtx);
976 m34[3] = 0.0f;
977 m34[7] = 0.0f;
978 m34[11] = 0.0f;
979
980 return (Matrix) (finalMtx * m34);
981 }

◆ Equals()

override bool BrawlLib.Internal.Matrix34.Equals ( object  obj)
inline
1164 {
1165 if (obj is Matrix34 matrix34)
1166 {
1167 return matrix34 == this;
1168 }
1169
1170 return base.Equals(obj);
1171 }

◆ GetHashCode()

override int BrawlLib.Internal.Matrix34.GetHashCode ( )
inline
1174 {
1175 return base.GetHashCode();
1176 }

◆ GetTranslation()

Matrix34 BrawlLib.Internal.Matrix34.GetTranslation ( )
inline
68 {
70 float* p = (float*) &m;
71 fixed (float* s = _data)
72 {
73 p[3] = s[3];
74 p[7] = s[7];
75 p[11] = s[11];
76 }
77
78 return m;
79 }

◆ Multiply() [1/2]

void BrawlLib.Internal.Matrix34.Multiply ( Matrix34 m)
inline
1038 {
1039 Matrix34 m2 = this;
1040
1041 float* s1 = (float*) &m2, s2 = (float*) m;
1042
1043 fixed (float* p = _data)
1044 {
1045 int index = 0;
1046 float val;
1047 for (int b = 0; b < 12; b += 4)
1048 {
1049 for (int a = 0; a < 4; a++)
1050 {
1051 val = 0.0f;
1052 for (int x = b, y = a; y < 12; y += 4)
1053 {
1054 val += s1[x++] * s2[y];
1055 }
1056
1057 p[index++] = val;
1058 }
1059 }
1060
1061 p[3] += s1[3];
1062 p[7] += s1[7];
1063 p[11] += s1[11];
1064 }
1065 }

◆ Multiply() [2/2]

Vector3 BrawlLib.Internal.Matrix34.Multiply ( Vector3  v)
inline
1068 {
1069 Vector3 nv = new Vector3();
1070 fixed (float* p = _data)
1071 {
1072 nv._x = p[0] * v._x + p[1] * v._y + p[2] * v._z + p[3];
1073 nv._y = p[4] * v._x + p[5] * v._y + p[6] * v._z + p[7];
1074 nv._z = p[8] * v._x + p[9] * v._y + p[10] * v._z + p[11];
1075 }
1076
1077 return nv;
1078 }

◆ operator!=()

static bool BrawlLib.Internal.Matrix34.operator!= ( Matrix34  m1,
Matrix34  m2 
)
inlinestatic
1159 {
1160 return !(m1 == m2);
1161 }

◆ operator*()

static Matrix34 BrawlLib.Internal.Matrix34.operator* ( Matrix34  m1,
Matrix34  m2 
)
inlinestatic
1116 {
1117 Matrix34 m;
1118
1119 float* s1 = (float*) &m1, s2 = (float*) &m2, p = (float*) &m;
1120
1121 int index = 0;
1122 float val;
1123 for (int b = 0; b < 12; b += 4)
1124 {
1125 for (int a = 0; a < 4; a++)
1126 {
1127 val = 0.0f;
1128 for (int x = b, y = a; y < 12; y += 4)
1129 {
1130 val += s1[x++] * s2[y];
1131 }
1132
1133 p[index++] = val;
1134 }
1135 }
1136
1137 p[3] += s1[3];
1138 p[7] += s1[7];
1139 p[11] += s1[11];
1140
1141 return m;
1142 }

◆ operator==()

static bool BrawlLib.Internal.Matrix34.operator== ( Matrix34  m1,
Matrix34  m2 
)
inlinestatic
1145 {
1146 float* p1 = (float*) &m1, p2 = (float*) &m2;
1147 for (int i = 0; i < 12; i++)
1148 {
1149 if (*p1++ != *p2++)
1150 {
1151 return false;
1152 }
1153 }
1154
1155 return true;
1156 }

◆ ProjectionMapping()

static Matrix BrawlLib.Internal.Matrix34.ProjectionMapping ( int  ref_camera,
SCN0Node  node,
ModelPanelViewport  v,
float  frame 
)
inlinestatic
830 {
831 Matrix projMtx = Matrix.Identity;
832 Matrix camMtx = Matrix.Identity;
833 GLCamera cam = v.Camera;
834 if (ref_camera >= 0 && node?.CameraGroup != null && ref_camera < node.CameraGroup.Children.Count)
835 {
836 // Set so that the image is projected from the specified camera.
837 // Transform to the viewing coordinate system of the specified camera
838 SCN0CameraNode camNode = (SCN0CameraNode) node.CameraGroup.Children[ref_camera];
839 camNode.GetModelViewMatrix(frame, out Matrix cm, out Matrix cmInv);
840 camMtx = cm * cam._matrix;
841 projMtx = (Matrix) ProjectionTexMtx(camNode, frame);
842 }
843 else
844 {
845 camMtx = cam._matrix;
846 projMtx = (Matrix) ProjectionTexMtx(cam);
847 }
848
849 return projMtx * camMtx;
850 }

◆ ReverseTransformMatrix()

static Matrix34 BrawlLib.Internal.Matrix34.ReverseTransformMatrix ( Vector3  scale,
Vector3  rotation,
Vector3  translation 
)
inlinestatic
323 {
324 float cosx = (float) Math.Cos(rotation._x / 180.0 * Math.PI);
325 float sinx = (float) Math.Sin(rotation._x / 180.0 * Math.PI);
326 float cosy = (float) Math.Cos(rotation._y / 180.0 * Math.PI);
327 float siny = (float) Math.Sin(rotation._y / 180.0 * Math.PI);
328 float cosz = (float) Math.Cos(rotation._z / 180.0 * Math.PI);
329 float sinz = (float) Math.Sin(rotation._z / 180.0 * Math.PI);
330
331 scale._x = 1 / scale._x;
332 scale._y = 1 / scale._y;
333 scale._z = 1 / scale._z;
334 translation._x = -translation._x;
335 translation._y = -translation._y;
336 translation._z = -translation._z;
337
338 Matrix34 m;
339 float* p = (float*) &m;
340
341 p[0] = scale._x * cosy * cosz;
342 p[1] = scale._x * cosy * sinz;
343 p[2] = -scale._x * siny;
344 p[3] = translation._x * p[0] + translation._y * p[1] + translation._z * p[2];
345 p[4] = scale._y * (sinx * siny * cosz - cosx * sinz);
346 p[5] = scale._y * (sinx * siny * sinz + cosx * cosz);
347 p[6] = scale._y * sinx * cosy;
348 p[7] = translation._x * p[4] + translation._y * p[5] + translation._z * p[6];
349 p[8] = scale._z * (cosx * siny * cosz + sinx * sinz);
350 p[9] = scale._z * (cosx * siny * sinz - sinx * cosz);
351 p[10] = scale._z * cosx * cosy;
352 p[11] = translation._x * p[8] + translation._y * p[9] + translation._z * p[10];
353
354 return m;
355 }

◆ RotateX()

void BrawlLib.Internal.Matrix34.RotateX ( float  x)
inline
173 {
174 float var1, var2;
175 float cosx = (float) Math.Cos(x / 180.0f * Math.PI);
176 float sinx = (float) Math.Sin(x / 180.0f * Math.PI);
177
178 fixed (float* p = _data)
179 {
180 var1 = p[1];
181 var2 = p[2];
182 p[1] = var1 * cosx + var2 * sinx;
183 p[2] = var1 * -sinx + var2 * cosx;
184
185 var1 = p[5];
186 var2 = p[6];
187 p[5] = var1 * cosx + var2 * sinx;
188 p[6] = var1 * -sinx + var2 * cosx;
189
190 var1 = p[9];
191 var2 = p[10];
192 p[9] = var1 * cosx + var2 * sinx;
193 p[10] = var1 * -sinx + var2 * cosx;
194 }
195 }

◆ RotateY()

void BrawlLib.Internal.Matrix34.RotateY ( float  y)
inline
198 {
199 float var1, var2;
200 float cosy = (float) Math.Cos(y / 180.0f * Math.PI);
201 float siny = (float) Math.Sin(y / 180.0f * Math.PI);
202
203 fixed (float* p = _data)
204 {
205 var1 = p[0];
206 var2 = p[2];
207 p[0] = var1 * cosy + var2 * -siny;
208 p[2] = var1 * siny + var2 * cosy;
209
210 var1 = p[4];
211 var2 = p[6];
212 p[4] = var1 * cosy + var2 * -siny;
213 p[6] = var1 * siny + var2 * cosy;
214
215 var1 = p[8];
216 var2 = p[10];
217 p[8] = var1 * cosy + var2 * -siny;
218 p[10] = var1 * siny + var2 * cosy;
219 }
220 }

◆ RotateZ()

void BrawlLib.Internal.Matrix34.RotateZ ( float  z)
inline
223 {
224 float var1, var2;
225 float cosz = (float) Math.Cos(z / 180.0f * Math.PI);
226 float sinz = (float) Math.Sin(z / 180.0f * Math.PI);
227
228 fixed (float* p = _data)
229 {
230 var1 = p[0];
231 var2 = p[1];
232 p[0] = var1 * cosz + var2 * sinz;
233 p[1] = var1 * -sinz + var2 * cosz;
234
235 var1 = p[4];
236 var2 = p[5];
237 p[4] = var1 * cosz + var2 * sinz;
238 p[5] = var1 * -sinz + var2 * cosz;
239
240 var1 = p[8];
241 var2 = p[9];
242 p[8] = var1 * cosz + var2 * sinz;
243 p[9] = var1 * -sinz + var2 * cosz;
244 }
245 }

◆ RotationMatrix()

static Matrix34 BrawlLib.Internal.Matrix34.RotationMatrix ( float  x,
float  y,
float  z 
)
inlinestatic
248 {
249 float cosx = (float) Math.Cos(x / 180.0f * Math.PI);
250 float sinx = (float) Math.Sin(x / 180.0f * Math.PI);
251 float cosy = (float) Math.Cos(y / 180.0f * Math.PI);
252 float siny = (float) Math.Sin(y / 180.0f * Math.PI);
253 float cosz = (float) Math.Cos(z / 180.0f * Math.PI);
254 float sinz = (float) Math.Sin(z / 180.0f * Math.PI);
255
256 Matrix34 m = Identity;
257 float* p = (float*) &m;
258
259 p[5] = cosx;
260 p[6] = -sinx;
261 p[9] = sinx;
262 p[10] = cosx;
263
264 Matrix34 m2 = Identity;
265 float* p2 = (float*) &m2;
266 p2[0] = cosy;
267 p2[2] = siny;
268 p2[8] = -siny;
269 p2[10] = cosy;
270
271 Matrix34 m3 = Identity;
272 float* p3 = (float*) &m3;
273 p3[0] = cosz;
274 p3[1] = -sinz;
275 p3[4] = sinz;
276 p3[5] = cosz;
277
278 m.Multiply(&m2);
279 m.Multiply(&m3);
280
281 //p[0] = cosy * cosz;
282 //p[1] = cosy * sinz;
283 //p[2] = -siny;
284 //p[4] = (sinx * siny * cosz - cosx * sinz);
285 //p[5] = (sinx * siny * sinz + cosx * cosz);
286 //p[6] = sinx * cosy;
287 //p[8] = (cosx * siny * cosz + sinx * sinz);
288 //p[9] = (cosx * siny * sinz - sinx * cosz);
289 //p[10] = cosx * cosy;
290
291 return m;
292 }
void Multiply(Matrix34 *m)
Definition: Matrix34.cs:1037

◆ RotationMatrixRX()

static Matrix34 BrawlLib.Internal.Matrix34.RotationMatrixRX ( float  x)
inlinestatic
120 {
121 Matrix34 m = new Matrix34();
122 float* p = (float*) &m;
123
124 float cosx = (float) Math.Cos(x / 180.0f * Math.PI);
125 float sinx = (float) Math.Sin(x / 180.0f * Math.PI);
126
127 p[0] = 1.0f;
128 p[5] = cosx;
129 p[6] = sinx;
130 p[9] = -sinx;
131 p[10] = cosx;
132
133 return m;
134 }

◆ RotationMatrixRY()

static Matrix34 BrawlLib.Internal.Matrix34.RotationMatrixRY ( float  y)
inlinestatic
155 {
156 Matrix34 m = new Matrix34();
157 float* p = (float*) &m;
158
159 float cosy = (float) Math.Cos(y / 180.0f * Math.PI);
160 float siny = (float) Math.Sin(y / 180.0f * Math.PI);
161
162 p[5] = 1.0f;
163
164 p[0] = cosy;
165 p[2] = -siny;
166 p[8] = siny;
167 p[10] = cosy;
168
169 return m;
170 }

◆ RotationMatrixX()

static Matrix34 BrawlLib.Internal.Matrix34.RotationMatrixX ( float  x)
inlinestatic
103 {
104 Matrix34 m = new Matrix34();
105 float* p = (float*) &m;
106
107 float cosx = (float) Math.Cos(x / 180.0f * Math.PI);
108 float sinx = (float) Math.Sin(x / 180.0f * Math.PI);
109
110 p[0] = 1.0f;
111 p[5] = cosx;
112 p[6] = -sinx;
113 p[9] = sinx;
114 p[10] = cosx;
115
116 return m;
117 }

◆ RotationMatrixY()

static Matrix34 BrawlLib.Internal.Matrix34.RotationMatrixY ( float  y)
inlinestatic
137 {
138 Matrix34 m = new Matrix34();
139 float* p = (float*) &m;
140
141 float cosy = (float) Math.Cos(y / 180.0f * Math.PI);
142 float siny = (float) Math.Sin(y / 180.0f * Math.PI);
143
144 p[5] = 1.0f;
145
146 p[0] = cosy;
147 p[2] = siny;
148 p[8] = -siny;
149 p[10] = cosy;
150
151 return m;
152 }

◆ ScaleMatrix()

static Matrix34 BrawlLib.Internal.Matrix34.ScaleMatrix ( float  x,
float  y,
float  z 
)
inlinestatic
82 {
83 Matrix34 m = new Matrix34();
84 float* p = (float*) &m;
85 p[0] = x;
86 p[5] = y;
87 p[10] = z;
88 return m;
89 }

◆ Subtract()

void BrawlLib.Internal.Matrix34.Subtract ( Matrix34 m)
inline
1093 {
1094 float* s = (float*) m;
1095 fixed (float* d = _data)
1096 {
1097 for (int i = 0; i < 12; i++)
1098 {
1099 d[i] -= s[i];
1100 }
1101 }
1102 }

◆ TextureMatrix()

static Matrix34 BrawlLib.Internal.Matrix34.TextureMatrix ( TextureFrameState  state)
inlinestatic
386 {
387 Matrix34 m = Identity;
388 if (state.Flags != 7)
389 {
390 MtxArray[state.Indirect ? 0 : 1 + ((int) state.MatrixMode).Clamp(0, 2) * 7 + state.Flags]((float*) &m,
391 state);
392 }
393
394 return m;
395 }
TexMatrixMode MatrixMode
Definition: FrameState.cs:170
int Flags
Bit flags used for texture matrix calculation
Definition: FrameState.cs:167

◆ ToString()

override string BrawlLib.Internal.Matrix34.ToString ( )
inline
1179 {
1180 fixed (float* p = _data)
1181 {
1182 return CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator.Contains(",")
1183 ? $"({p[0]} {p[1]} {p[2]} {p[3]})({p[4]} {p[5]} {p[6]} {p[7]})({p[8]} {p[9]} {p[10]} {p[11]})"
1184 : $"({p[0]},{p[1]},{p[2]},{p[3]})({p[4]},{p[5]},{p[6]},{p[7]})({p[8]},{p[9]},{p[10]},{p[11]})";
1185 }
1186 }

◆ TransformationMatrix()

static Matrix34 BrawlLib.Internal.Matrix34.TransformationMatrix ( Vector3  scale,
Vector3  rotation,
Vector3  translation 
)
inlinestatic
295 {
296 float cosx = (float) Math.Cos(rotation._x / 180.0 * Math.PI);
297 float sinx = (float) Math.Sin(rotation._x / 180.0 * Math.PI);
298 float cosy = (float) Math.Cos(rotation._y / 180.0 * Math.PI);
299 float siny = (float) Math.Sin(rotation._y / 180.0 * Math.PI);
300 float cosz = (float) Math.Cos(rotation._z / 180.0 * Math.PI);
301 float sinz = (float) Math.Sin(rotation._z / 180.0 * Math.PI);
302
303 Matrix34 m;
304 float* p = (float*) &m;
305
306 p[0] = scale._x * cosy * cosz;
307 p[1] = scale._y * (sinx * siny * cosz - cosx * sinz);
308 p[2] = scale._z * (cosx * siny * cosz + sinx * sinz);
309 p[3] = translation._x;
310 p[4] = scale._x * cosy * sinz;
311 p[5] = scale._y * (sinx * siny * sinz + cosx * cosz);
312 p[6] = scale._z * (cosx * siny * sinz - sinx * cosz);
313 p[7] = translation._y;
314 p[8] = -scale._x * siny;
315 p[9] = scale._y * sinx * cosy;
316 p[10] = scale._z * cosx * cosy;
317 p[11] = translation._z;
318
319 return m;
320 }

◆ Translate()

void BrawlLib.Internal.Matrix34.Translate ( float  x,
float  y,
float  z 
)
inline
50 {
51 Matrix34 m = TranslationMatrix(x, y, z);
52 Multiply(&m);
53 }
static Matrix34 TranslationMatrix(float x, float y, float z)
Definition: Matrix34.cs:91

◆ TranslationMatrix()

static Matrix34 BrawlLib.Internal.Matrix34.TranslationMatrix ( float  x,
float  y,
float  z 
)
inlinestatic
92 {
93 Matrix34 m = new Matrix34();
94 float* p = (float*) &m;
95 p[3] = x;
96 p[7] = y;
97 p[11] = z;
98 p[0] = p[5] = p[10] = 1.0f;
99 return m;
100 }

Member Data Documentation

◆ Identity

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

Property Documentation

◆ this[int index]

float BrawlLib.Internal.Matrix34.this[int index]
getset
32 {
33 get
34 {
35 fixed (float* p = _data)
36 {
37 return p[index];
38 }
39 }
40 set
41 {
42 fixed (float* p = _data)
43 {
44 p[index] = value;
45 }
46 }
47 }

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