CrossFramework Library
|
00001 00006 #if defined(XBASE_INCLUDED_MATRIX44_HPP) 00007 #else 00008 #define XBASE_INCLUDED_MATRIX44_HPP 00009 00010 //------------------------------------------------------------ 00011 #include <XBase/BuiltInTypes.hpp> 00012 00013 //------------------------------------------------------------ 00014 namespace XBase { 00015 class Angle; 00016 struct Vector3POD; 00017 struct Vector4POD; 00018 } 00019 00020 //------------------------------------------------------------ 00021 namespace XBase { 00023 00024 00039 struct Matrix44POD 00040 { 00041 //============================================================ 00043 00044 enum 00045 { 00046 Index00 = 0, 00047 Index10 = 1, 00048 Index20 = 2, 00049 Index30 = 3, 00050 Index01 = 4, 00051 Index11 = 5, 00052 Index21 = 6, 00053 Index31 = 7, 00054 Index02 = 8, 00055 Index12 = 9, 00056 Index22 = 10, 00057 Index32 = 11, 00058 Index03 = 12, 00059 Index13 = 13, 00060 Index23 = 14, 00061 Index33 = 15, 00062 IndexXX = Index00, 00063 IndexXY = Index10, 00064 IndexXZ = Index20, 00065 IndexXW = Index30, 00066 IndexYX = Index01, 00067 IndexYY = Index11, 00068 IndexYZ = Index21, 00069 IndexYW = Index31, 00070 IndexZX = Index02, 00071 IndexZY = Index12, 00072 IndexZZ = Index22, 00073 IndexZW = Index32, 00074 IndexWX = Index03, 00075 IndexWY = Index13, 00076 IndexWZ = Index23, 00077 IndexWW = Index33, 00078 }; 00080 00081 //============================================================ 00083 00084 static const Matrix44POD Identity(); 00085 static const Matrix44POD Translate( f32 aX , f32 aY , f32 aZ ); 00086 static const Matrix44POD Translate( const Vector3POD& aVec ); 00087 static const Matrix44POD Scale( f32 aX , f32 aY , f32 aZ ); 00088 static const Matrix44POD Scale( const Vector3POD& aVec ); 00089 static const Matrix44POD Rotate( const Angle& , f32 aAxisX , f32 aAxisY , f32 aAxisZ ); 00090 static const Matrix44POD Rotate( const Angle& , const Vector3POD& aAxis ); 00091 00093 static const Matrix44POD Ortho( f32 aLeft , f32 aTop , f32 aRight , f32 aBottom , f32 aNear , f32 aFar ); 00094 00096 static const Matrix44POD Frustum( f32 aLeft ,f32 aRight ,f32 aBottom , f32 aTop , f32 aNear , f32 aFar ); 00097 00105 static const Matrix44POD Perspective( const Angle& aFOVY , f32 aAspect , f32 aNear , f32 aFar ); 00106 00114 static const Matrix44POD LookAt( const Vector3POD& aEyePos , const Vector3POD& aTargetPos , const Vector3POD& aUpVec ); 00116 00117 //============================================================ 00119 00120 union 00121 { 00122 f32 v[16]; 00123 f32 m[4][4]; 00124 }; 00126 00127 //============================================================ 00129 00130 const Vector4POD x()const; 00131 const Vector4POD y()const; 00132 const Vector4POD z()const; 00133 const Vector4POD w()const; 00134 void setX( const Vector4POD& ); 00135 void setY( const Vector4POD& ); 00136 void setZ( const Vector4POD& ); 00137 void setW( const Vector4POD& ); 00139 00140 //============================================================ 00142 00143 const Matrix44POD mul( const Matrix44POD& )const; 00144 Matrix44POD& mulAssign( const Matrix44POD& ); 00145 00146 00147 //============================================================ 00149 00150 const Matrix44POD operator*( const Matrix44POD& )const; 00151 Matrix44POD& operator*=( const Matrix44POD& ); 00152 00153 00154 //============================================================ 00156 00157 const Matrix44POD transpose()const; 00158 00159 00160 //============================================================ 00162 00163 void dump()const; 00165 }; 00166 00168 class Matrix44 : public Matrix44POD 00169 { 00170 public: 00171 //============================================================ 00173 00174 Matrix44(); 00175 00176 Matrix44( f32 r0c0 , f32 r0c1 , f32 r0c2 , f32 r0c3 00177 , f32 r1c0 , f32 r1c1 , f32 r1c2 , f32 r1c3 00178 , f32 r2c0 , f32 r2c1 , f32 r2c2 , f32 r2c3 00179 , f32 r3c0 , f32 r3c1 , f32 r3c2 , f32 r3c3 00180 ); 00181 Matrix44( const Vector4POD& aX , const Vector4POD& aY , const Vector4POD& aZ , const Vector4POD& aW ); 00182 Matrix44( const Matrix44POD& ); 00183 00184 }; 00186 } 00187 //------------------------------------------------------------ 00188 #endif 00189 // EOF