SIBCMatrix.h

Go to the documentation of this file.
00001 //***************************************************************************************
00002 // File supervisor: Crosswalk team
00012 //***************************************************************************************
00013 
00014 //***************************************************************************************
00015 // Defines
00016 //***************************************************************************************
00017 #ifndef __CSIBCMatrix_H__
00018 #define __CSIBCMatrix_H__
00019 
00020 //***************************************************************************************
00021 // Includes
00022 //***************************************************************************************
00023 #include <SIBCVector.h>
00024 
00025 #ifdef _PSX2
00026 #include <libvu0.h>
00027 #endif
00028 
00029 //***************************************************************************************
00030 // Typedefs
00031 //***************************************************************************************
00032 
00033 //***************************************************************************************
00034 // CSIBCMatrix4x4 | Matrices are stored in column major order, e.g., m_Matrix[ROW][COLUMN]
00035 //***************************************************************************************
00036 
00050 class XSICOREEXPORT CSIBCMatrix4x4
00051 {
00052     public:
00053 
00057         CSIBCMatrix4x4();
00058 
00063         CSIBCMatrix4x4( const CSIBCMatrix4x4 & i_Matrix);
00064 
00072         CSIBCMatrix4x4( SI_Float * i_pMatrix);
00073 
00074         ~CSIBCMatrix4x4();                                              // Default Destructor
00075 
00076         // Components
00077 
00082         SI_Error Set( const CSIBCMatrix4x4 & i_Matrix);
00083 
00110         SI_Error Set( const SI_Float * i_pMatrix);
00111 
00119         SI_Error Set( const SI_Byte i_bIndex, SI_Float i_fValue);
00120 
00129         SI_Error Set(   const SI_Byte i_Column,
00130                         const SI_Byte i_Row,
00131                         const SI_Float i_fValue);
00132 
00142         void SetToScale( const CSIBCVector3D & i_vScale);
00143 
00153         void SetToRotation( const CSIBCVector3D & i_vEuler);
00154 
00160         void SetToRotation( const SI_Float angl, const CSIBCVector3D &axis );
00161 
00166         void SetToTranslation( const CSIBCVector3D & i_vTrans);
00167 
00204         void SetTransforms( const CSIBCVector3D &scale,
00205                             const CSIBCVector3D &rot,
00206                             const CSIBCVector3D &trans );
00207 
00208 
00234         void SetScaling( const CSIBCVector3D & i_vScaling);
00235 
00270         void SetRotation( const CSIBCVector3D & i_vRot);
00271 
00283         void SetRotation( const CSIBCMatrix4x4 & i_mMatrix);
00284 
00299         void SetOrientation(    const CSIBCVector3D &x_axis,
00300                                 const CSIBCVector3D &y_axis,
00301                                 const CSIBCVector3D &z_axis );
00302 
00311         void SetTranslation( const CSIBCVector3D & i_vTrans);
00312 
00313         // Retrieve Information.
00314 
00320         SI_Error Get( SI_Float * o_pMatrix) const;
00321 
00328         SI_Error Get( CSIBCMatrix4x4 & o_mMatrix) const;
00329 
00335         SI_Float Get( const SI_Byte i_bIndex) const;
00336 
00337 
00344         SI_Float Get( const SI_Byte i_Column, const SI_Byte i_Row) const;   // Retrieves the value at an index 2d
00345 
00350         void GetScaling( CSIBCVector3D & o_vScale) const;
00351 
00356         void GetRotation( CSIBCVector3D & o_vRot) const ;                       // Gets the rotation values for euler xyz
00357 
00365         void GetOrientation(    CSIBCVector3D &x_axis,
00366                                 CSIBCVector3D &y_axis,
00367                                 CSIBCVector3D &z_axis ) const ;
00368 
00374         void GetTranslation( CSIBCVector3D & o_vTrans) const;
00375 
00388         void GetTransforms( CSIBCVector3D &scale,
00389                             CSIBCVector3D &rot,
00390                             CSIBCVector3D &trans );
00391 
00396         SI_Bool IsIdentity();
00397 
00398         // Operations
00399 
00407         SI_Bool GetInverse( CSIBCMatrix4x4 & o_mMatrix);
00408 
00410         CSIBCMatrix4x4& Normalize();
00411 
00416         CSIBCMatrix4x4& SetNull();
00417 
00423         CSIBCMatrix4x4& SetIdentity();
00424 
00428         CSIBCMatrix4x4& Transpose();
00429 
00438         void ColumnMajor( SI_Float * o_pMatrix);
00439 
00443         void RowMajor( SI_Float * );        // Copies the matrix in row major format
00444 
00454         SI_Float *Raw();
00455 
00461         SI_Matrix *GetSIMatrix() { return &m_Matrix; }
00462 
00473         void LookAt( const CSIBCVector3D &pos,
00474                      const CSIBCVector3D &target,
00475                      const CSIBCVector3D &up,
00476                      const SI_Float roll );
00477 
00478 
00492         void Ortho( const SI_Float left,
00493                     const SI_Float right,
00494                     const SI_Float top,
00495                     const SI_Float bottom,
00496                     const SI_Float nearPlane,
00497                     const SI_Float farPlane);
00498 
00511         void Perspective(   const SI_Float nearPlane,
00512                             const SI_Float farPlane,
00513                             const SI_Float fov,
00514                             const SI_Float aspect );
00515 
00528         void PerspectiveAlt(    const SI_Float nearPlane,
00529                                 const SI_Float farPlane,
00530                                 const SI_Float fov,
00531                                 const SI_Float aspect );
00532 
00545         SI_Bool AlignAxes(  CSIBCVector3D *x_vec,
00546                             CSIBCVector3D *xy_vec );
00547 
00556         SI_Bool AlignRoll(  SI_Float        in_Roll,
00557                             CSIBCVector3D   *in_pVector);
00558 
00568         CSIBCMatrix4x4 &Multiply( CSIBCMatrix4x4 & i_mMatrix);
00569 
00580         SI_Error Multiply(  CSIBCMatrix4x4 & i_mMatrix,
00581                             CSIBCMatrix4x4 &result);
00582 
00593         CSIBCMatrix4x4 &Multiply4x3( const CSIBCMatrix4x4 & i_mMatrix);
00594 
00605         SI_Error Multiply4x3(   const CSIBCMatrix4x4 & i_mMatrix,
00606                                 CSIBCMatrix4x4 &result) const;
00607 
00620         CSIBCVector4D Multiply( const CSIBCVector2D & i_vVector) const;
00621 
00635         CSIBCVector4D Multiply( const CSIBCVector3D & i_vVector);
00636 
00647         CSIBCVector4D Multiply( const CSIBCVector4D & i_vVector);
00648 
00663         void Multiply( CSIBCVector3D &i_vResult, const CSIBCVector3D &i_vVector );
00664 
00679         void MultiplyLeft( CSIBCVector3D & i_vResult, const CSIBCVector3D &i_vVector ) const;
00680 
00681 #ifdef _PSX2
00682 
00693         void CacheMatrix();
00694 
00708         void CacheMultiply( CSIBCVector3D & i_vResult, CSIBCVector3D & i_vVector);
00709 
00722         void CacheMultiply( CSIBCVector4D & i_vResult, const CSIBCVector4D & i_vVector);
00723 
00737         void CacheMultiplyScale( CSIBCVector3D & i_vResult, CSIBCVector3D & i_vVector, float i_fScale );
00738 
00754         void CacheMultiplyScaleAdd( CSIBCVector3D & io_vResult, CSIBCVector3D & i_vVector, float i_fScale );
00755 #endif
00756 
00757         // Operators
00758 
00769         CSIBCMatrix4x4      operator*(CSIBCMatrix4x4 & i_mMatrix);
00770 
00771 
00784         CSIBCVector4D       operator*(CSIBCVector2D & i_vVector);
00785 
00799         CSIBCVector4D       operator*(CSIBCVector3D & i_vVector);
00800 
00812         CSIBCVector4D       operator*(CSIBCVector4D & i_vVector);
00813 
00820         CSIBCMatrix4x4&     operator = (const CSIBCMatrix4x4 & i_mMatrix);
00821 
00829         CSIBCMatrix4x4&     operator +=( const CSIBCMatrix4x4 & i_mMatrix);
00830 
00832         SI_Error Dump();
00833 
00835         SI_Error SelfTest();
00836 
00837     private:
00838 
00839 #ifdef _PSX2
00840         sceVu0FMATRIX   m_Matrix;
00841         float           *row1;
00842         float           *row2;
00843         float           *row3;
00844         float           *row4;
00845 #else
00846         SI_Matrix       m_Matrix;
00847 #endif
00848 
00849 };
00850 
00851 #endif
00852 // CSIBCMatrix