00001 /********************************************************************** 00002 *< 00003 FILE: IGameType.h 00004 00005 DESCRIPTION: General definition for IGame types 00006 00007 CREATED BY: Alex Zadorozhny 00008 00009 HISTORY: 05/12/2005 00010 00011 IGame Version: 1.122 00012 00013 *> Copyright (c) 2005, All Rights Reserved. 00014 **********************************************************************/ 00015 00020 #pragma once 00021 00022 #include "..\maxheap.h" 00023 #include "IGameExport.h" 00024 #include "..\point3.h" 00025 #include "..\matrix3.h" 00026 // forward declarations 00027 class Point4; 00028 00029 00031 typedef float GRow[4]; 00032 00033 00035 class GMatrix : public MaxHeapOperators 00036 { 00037 private: 00038 float m[4][4]; 00039 friend IGAMEEXPORT Point3 operator*(const Point3& V, const GMatrix& A); 00040 00041 public: 00043 00044 00045 Point4& operator[](int i) { return((Point4&)(*m[i]));} 00046 const Point4& operator[](int i) const { return((Point4&)(*m[i])); } 00048 00050 00053 GRow * GetAddr(){return (GRow *)(m);} 00054 00056 00059 const GRow* GetAddr() const { return (GRow *)(m); } 00060 00062 IGAMEEXPORT GMatrix(); 00063 00065 IGAMEEXPORT GMatrix(Matrix3); 00066 00068 void ResetMatrix(); 00069 00071 00075 IGAMEEXPORT BOOL IsIdentity(float epsilon = 1E-5f); 00076 00078 IGAMEEXPORT void SetIdentity(); 00079 00081 IGAMEEXPORT float Determinant() const; 00082 00084 IGAMEEXPORT GMatrix Inverse(); 00085 00087 IGAMEEXPORT Point3 Translation () const; 00088 00090 IGAMEEXPORT Quat Rotation () const; 00091 00093 IGAMEEXPORT Point3 Scaling () const; 00094 00096 00098 Quat ScaleRotation () const; 00099 00101 IGAMEEXPORT int Parity() const; 00102 00104 00107 IGAMEEXPORT Point4 GetColumn(int i) const; 00108 00110 /*\param i The number of the column to set 00111 \param col Point4 containing the column to set 00112 */ 00113 IGAMEEXPORT void SetColumn(int i, Point4 col); 00114 00116 /*\param i The number of the row to retrieve 00117 \returns A Point4 containing the row 00118 */ 00119 Point4 GetRow(int i) const { return (*this)[i]; } 00120 00122 /*\param i The number of the row to set 00123 \param row A Point4 containing the row 00124 */ 00125 IGAMEEXPORT void SetRow(int i, Point4 row); 00126 00128 00129 IGAMEEXPORT GMatrix operator-(const GMatrix&)const; 00130 IGAMEEXPORT GMatrix operator*(const GMatrix&)const; 00131 IGAMEEXPORT GMatrix operator+(const GMatrix&)const; 00133 00135 00136 IGAMEEXPORT GMatrix& operator-=( const GMatrix& M); 00137 IGAMEEXPORT GMatrix& operator+=( const GMatrix& M); 00138 IGAMEEXPORT GMatrix& operator*=( const GMatrix& M); // Matrix multiplication 00139 IGAMEEXPORT GMatrix& operator*=( const float a); 00140 IGAMEEXPORT GMatrix& operator=(const Matrix3&); 00142 00144 00145 IGAMEEXPORT BOOL operator==(const GMatrix& M) const; 00146 IGAMEEXPORT BOOL Equals(const GMatrix& M, float epsilon = 1E-5f) const; 00147 00148 00150 00154 IGAMEEXPORT Matrix3 ExtractMatrix3()const ; 00155 00156 }; 00157 00159 IGAMEEXPORT Point3 operator*(const Point3& V, const GMatrix& A); 00160 00161