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 00040 struct Matrix44POD 00041 { 00042 //============================================================ 00044 00045 enum 00046 { 00047 Index00 = 0, 00048 Index10 = 1, 00049 Index20 = 2, 00050 Index30 = 3, 00051 Index01 = 4, 00052 Index11 = 5, 00053 Index21 = 6, 00054 Index31 = 7, 00055 Index02 = 8, 00056 Index12 = 9, 00057 Index22 = 10, 00058 Index32 = 11, 00059 Index03 = 12, 00060 Index13 = 13, 00061 Index23 = 14, 00062 Index33 = 15, 00063 IndexXX = Index00, 00064 IndexXY = Index10, 00065 IndexXZ = Index20, 00066 IndexXW = Index30, 00067 IndexYX = Index01, 00068 IndexYY = Index11, 00069 IndexYZ = Index21, 00070 IndexYW = Index31, 00071 IndexZX = Index02, 00072 IndexZY = Index12, 00073 IndexZZ = Index22, 00074 IndexZW = Index32, 00075 IndexWX = Index03, 00076 IndexWY = Index13, 00077 IndexWZ = Index23, 00078 IndexWW = Index33, 00079 }; 00081 00082 //============================================================ 00084 00085 static const Matrix44POD Identity(); 00086 static const Matrix44POD Translate( f32 aX , f32 aY , f32 aZ ); 00087 static const Matrix44POD Translate( const Vector3POD& aVec ); 00088 static const Matrix44POD Scale( f32 aX , f32 aY , f32 aZ ); 00089 static const Matrix44POD Scale( const Vector3POD& aVec ); 00090 static const Matrix44POD Rotate( const Angle& , f32 aAxisX , f32 aAxisY , f32 aAxisZ ); 00091 static const Matrix44POD Rotate( const Angle& , const Vector3POD& aAxis ); 00092 00094 static const Matrix44POD Ortho( f32 aLeft , f32 aTop , f32 aRight , f32 aBottom , f32 aNear , f32 aFar ); 00095 00097 static const Matrix44POD Frustum( f32 aLeft ,f32 aRight ,f32 aBottom , f32 aTop , f32 aNear , f32 aFar ); 00098 00106 static const Matrix44POD Perspective( const Angle& aFOVY , f32 aAspect , f32 aNear , f32 aFar ); 00107 00115 static const Matrix44POD LookAt( const Vector3POD& aEyePos , const Vector3POD& aTargetPos , const Vector3POD& aUpVec ); 00117 00118 //============================================================ 00120 00121 union 00122 { 00123 f32 v[16]; 00124 f32 m[4][4]; 00125 }; 00127 00128 //============================================================ 00130 00131 const Vector4POD x()const; 00132 const Vector4POD y()const; 00133 const Vector4POD z()const; 00134 const Vector4POD w()const; 00135 void setX( const Vector4POD& ); 00136 void setY( const Vector4POD& ); 00137 void setZ( const Vector4POD& ); 00138 void setW( const Vector4POD& ); 00140 00141 //============================================================ 00143 00144 const Matrix44POD mul( const Matrix44POD& )const; 00145 Matrix44POD& mulAssign( const Matrix44POD& ); 00146 00147 00148 //============================================================ 00150 00151 const Matrix44POD operator*( const Matrix44POD& )const; 00152 Matrix44POD& operator*=( const Matrix44POD& ); 00153 00154 00155 //============================================================ 00157 00158 const Matrix44POD invert()const; 00159 const Matrix44POD transpose()const; 00160 00161 00162 //============================================================ 00164 00165 void dump()const; 00167 }; 00168 00170 class Matrix44 : public Matrix44POD 00171 { 00172 public: 00173 //============================================================ 00175 00176 Matrix44(); 00177 00178 Matrix44( f32 r0c0 , f32 r0c1 , f32 r0c2 , f32 r0c3 00179 , f32 r1c0 , f32 r1c1 , f32 r1c2 , f32 r1c3 00180 , f32 r2c0 , f32 r2c1 , f32 r2c2 , f32 r2c3 00181 , f32 r3c0 , f32 r3c1 , f32 r3c2 , f32 r3c3 00182 ); 00183 Matrix44( const Vector4POD& aX , const Vector4POD& aY , const Vector4POD& aZ , const Vector4POD& aW ); 00184 Matrix44( const Matrix44POD& ); 00185 00186 }; 00187 00189 typedef Matrix44POD Mtx44; 00191 } 00192 //------------------------------------------------------------ 00193 #endif 00194 // EOF