00001 #ifndef MERCURYMATRIX_H 00002 #define MERCURYMATRIX_H 00003 00004 //This matrix will work identically to float[16] 00005 #include "global.h" 00006 #include "MercuryMath.h" 00007 00008 class MercuryMatrix; 00009 00010 //Matrix in1 will be copied, n2 will not. n2 better never be the same as out 00011 void TransposeMatrix( const MercuryMatrix& in, MercuryMatrix &out ); 00012 00014 class MercuryMatrix 00015 { 00016 private: 00018 float m_matrix[4][4]; 00019 public: 00020 MercuryMatrix(); 00021 inline MercuryMatrix(const MercuryMatrix& m) { *this = m; } 00022 inline float* operator[](unsigned int i) { return m_matrix[i]; } 00024 inline const float* operator[](unsigned int i) const { return m_matrix[i]; } 00025 const MercuryMatrix& operator=(const MercuryMatrix& m); 00026 const MercuryMatrix& operator=(const float* m); 00027 inline float* Ptr() { return (float*)&m_matrix; } 00028 inline const float* Ptr() const { return (float*)&m_matrix; } 00029 00030 MercuryMatrix operator*(const MercuryMatrix& m) const; 00031 MercuryMatrix& operator*=(const MercuryMatrix& m); 00032 00033 void Translate(float x, float y, float z); 00035 void RotateXYZ(float x, float y, float z); 00037 void RotateAngAxis( float fAngle, float x, float y, float z ); 00038 void Scale(float x, float y, float z); 00039 void Transotale( float tX, float tY, float tZ, float rX, float rY, float rZ, float sX, float sY, float sZ ); 00040 inline void Transpose() { TransposeMatrix(*this, *this); } 00041 00042 void Zero(); 00043 void Identity(); 00044 } M_ALIGN(64); 00045 00046 #endif 00047 00048 /* 00049 * Copyright (c) 2006 Joshua Allen 00050 * All rights reserved. 00051 * 00052 * Redistribution and use in source and binary forms, with or 00053 * without modification, are permitted provided that the following 00054 * conditions are met: 00055 * - Redistributions of source code must retain the above 00056 * copyright notice, this list of conditions and the following disclaimer. 00057 * - Redistributions in binary form must reproduce the above copyright 00058 * notice, this list of conditions and the following disclaimer in 00059 * the documentation and/or other materials provided with the distribution. 00060 * - Neither the name of the Mercury Engine nor the names of its 00061 * contributors may be used to endorse or promote products derived from 00062 * this software without specific prior written permission. 00063 * 00064 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00065 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00066 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00067 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 00068 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00069 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00070 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00071 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00072 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00073 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00074 */ 00075