10 #pragma warning(disable: 4996)
17 #include "RTFXDebug.h"
22 const AXISFRAME RTFX_NATIVE_FRAME = XFORWARD_YRIGHT_ZUP;
23 const double RTFXPI = 3.14159265358979;
25 const Matrix4x4 I(1, 0, 0, 0, 1, 0, 0, 0, 1);
27 const Matrix4x4 frameMatrices[] = {
29 Matrix4x4( 0, 0, 1, 1, 0, 0, 0, 1, 0 ),
30 Matrix4x4( 0, 0, -1, 1, 0, 0, 0, 1, 0 ),
31 Matrix4x4( 0, 0, -1, -1, 0, 0, 0, -1, 0 ),
32 Matrix4x4( 0, 0, -1, -1, 0, 0, 0, 1, 0 ),
33 Matrix4x4( 0, 0, -1, 0, 1, 0, -1, 0, 0 ),
34 Matrix4x4( 0, 0, -1, 0, 1, 0, 1, 0, 0 ),
35 Matrix4x4( 0, 0, -1, 0, -1, 0, -1, 0, 0 ),
36 Matrix4x4( 0, 0, -1, 0, -1, 0, 1, 0, 0 ),
38 Matrix4x4( 0, 0, 1, 1, 0, 0, 0, -1, 0 ),
39 Matrix4x4( 0, 0, 1, 1, 0, 0, 0, 1, 0 ),
40 Matrix4x4( 0, 0, 1, -1, 0, 0, 0, -1, 0 ),
41 Matrix4x4( 0, 0, 1, -1, 0, 0, 0, 1, 0 ),
42 Matrix4x4( 0, 0, 1, 0, 1, 0, -1, 0, 0 ),
43 Matrix4x4( 0, 0, 1, 0, 1, 0, 1, 0, 0 ),
44 Matrix4x4( 0, 0, 1, 0, -1, 0, -1, 0, 0 ),
45 Matrix4x4( 0, 0, 1, 0, -1, 0, 1, 0, 0 ),
47 Matrix4x4( 1, 0, 0, 0, 0, 1, 0, 1, 0 ),
48 Matrix4x4( 1, 0, 0, 0, 0, -1, 0, 1, 0 ),
49 Matrix4x4( 1, 0, 0, 0, 0, 1, 0, -1, 0 ),
50 Matrix4x4( 1, 0, 0, 0, 0, -1, 0, -1, 0 ),
51 Matrix4x4( 1, 0, 0, 0, 1, 0, 0, 0, 1 ),
52 Matrix4x4( 1, 0, 0, 0, 1, 0, 0, 0, -1 ),
53 Matrix4x4( 1, 0, 0, 0, -1, 0, 0, 0, 1 ),
54 Matrix4x4( 1, 0, 0, 0, -1, 0, 0, 0, -1 ),
56 Matrix4x4( -1, 0, 0, 0, 0, 1, 0, 1, 0 ),
57 Matrix4x4( -1, 0, 0, 0, 0, -1, 0, 1, 0 ),
58 Matrix4x4( -1, 0, 0, 0, 0, 1, 0, -1, 0 ),
59 Matrix4x4( -1, 0, 0, 0, 0, -1, 0, -1, 0 ),
60 Matrix4x4( -1, 0, 0, 0, 1, 0, 0, 0, 1 ),
61 Matrix4x4( -1, 0, 0, 0, 1, 0, 0, 0, -1 ),
62 Matrix4x4( -1, 0, 0, 0, -1, 0, 0, 0, 1 ),
63 Matrix4x4( -1, 0, 0, 0, -1, 0, 0, 0, -1 ),
65 Matrix4x4( 0, 1, 0, 0, 0, 1, 1, 0, 0 ),
66 Matrix4x4( 0, 1, 0, 0, 0, 1, -1, 0, 0 ),
67 Matrix4x4( 0, 1, 0, 0, 0, -1, 1, 0, 0 ),
68 Matrix4x4( 0, 1, 0, 0, 0, -1, -1, 0, 0 ),
69 Matrix4x4( 0, 1, 0, 1, 0, 0, 0, 0, 1 ),
70 Matrix4x4( 0, 1, 0, 1, 0, 0, 0, 0, -1 ),
71 Matrix4x4( 0, 1, 0, -1, 0, 0, 0, 0, 1 ),
72 Matrix4x4( 0, 1, 0, -1, 0, 0, 0, 0, -1 ),
74 Matrix4x4( 0, -1, 0, 0, 0, 1, 1, 0, 0 ),
75 Matrix4x4( 0, -1, 0, 0, 0, 1, -1, 0, 0 ),
76 Matrix4x4( 0, -1, 0, 0, 0, -1, 1, 0, 0 ),
77 Matrix4x4( 0, -1, 0, 0, 0, -1, -1, 0, 0 ),
78 Matrix4x4( 0, -1, 0, 1, 0, 0, 0, 0, 1 ),
79 Matrix4x4( 0, -1, 0, 1, 0, 0, 0, 0, -1 ),
80 Matrix4x4( 0, -1, 0, -1, 0, 0, 0, 0, 1 ),
81 Matrix4x4( 0, -1, 0, -1, 0, 0, 0, 0, -1 ),
90 static Matrix4x4 GetFrameTransformMatrix( AXISFRAME _frameA, AXISFRAME _frameB )
93 if ( _frameA == _frameB )
return I;
98 if ( _frameB == RTFX_NATIVE_FRAME )
99 t_ = frameMatrices[ _frameA ];
101 else if ( _frameA == RTFX_NATIVE_FRAME )
103 t_ = frameMatrices[ _frameB ];
122 static void ExtractEulerRotationsFromMatrix(
Matrix4x4 _m,
float &_x,
float &_y,
float &_z );
123 static Point3D ConvertPointToNative( AXISFRAME _orig,
Point3D _point );
124 static Point3D ConvertPointFromNativeToOther( AXISFRAME _other,
Point3D _point );
125 static float ToRadians(
float _angle );
126 static float ToDegrees(
float _angle );
127 static Matrix4x4 RotateX(
float _angle );
128 static Matrix4x4 RotateY(
float _angle );
129 static Matrix4x4 RotateZ(
float _angle );