TAPs 0.7.7.3
TAPsTransformationSupport.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsTransformationSupport.hpp
00003 ******************************************************************************/
00058 /******************************************************************************
00059 SUKITTI PUNAK   (03/03/2006)
00060 UPDATE          (09/12/2010)
00061 ******************************************************************************/
00062 #ifndef TAPs_TRANSFORMATION_SUPPORT_HPP
00063 #define TAPs_TRANSFORMATION_SUPPORT_HPP
00064 
00065 #include "../Core/TAPsLib.hpp"
00066 
00067 BEGIN_NAMESPACE_TAPs
00068 //=============================================================================
00069 template <typename T>
00070 class TransformationSupport {
00071 //-----------------------------------------------------------------------------
00072 // Member Functions -----------------------------------------------------------
00073 public:
00074     // Member Functions -------------------------------------------------------
00076     friend std::ostream & operator<< ( std::ostream &output, TransformationSupport<T> const &obj )
00077     {
00078         output << obj.StrInfo();
00079         return output;
00080     }
00081     //-------------------------------------------------------------------------
00083     TransformationSupport ( TransformationSupport<T> * pParent = NULL );
00084     //-------------------------------------------------------------------------
00086     TransformationSupport ( const TransformationSupport<T> & orig );
00087     //-------------------------------------------------------------------------
00089     virtual ~TransformationSupport ();
00090     //-------------------------------------------------------------------------
00092     virtual std::string StrInfo () const;
00093     //-------------------------------------------------------------------------
00095     inline TransformationSupport<T> & operator= ( TransformationSupport<T> const & orig );
00096     //-------------------------------------------------------------------------
00097     // Operation Fn(s)
00098 protected:
00099     // For inheritance class
00100     virtual void TransformByTranslationRatationAndScale () {};
00101 public:
00102     //-------------------------------------------------------------------------
00103     //inline void   Reset ()    {   m_TransformationMatrix.MakeIdentity();  }
00104     inline void MakeIdentity () {   m_TransformationMatrix.MakeIdentity();  }
00105     //-------------------------------------------------------------------------
00106     //===============================================================
00107     //---------------------------------------------------------------
00109     inline void PreApplyTranslation ( Vector3<T> const & C );
00111     inline void PreApplyTranslation ( T x, T y, T z );
00112     //-----------------------
00114     inline void ApplyTranslation ( Vector3<T> const & C );
00116     inline void ApplyTranslation ( T x, T y, T z );
00117     //-----------------------
00119     inline Vector3<T>   GetTranslation () const;
00121     inline void GetTranslation ( Vector3<T> & C ) const;
00123     inline void GetTranslation ( T & x, T & y, T & z ) const;
00124     //-----------------------
00126     inline void SetTranslation ( Vector3<T> const & C );
00128     inline void SetTranslation ( T x, T y, T z );
00130     inline T &      ReturnTranslation ( int i );
00132     inline void SetRotation ( Matrix3x3<T> const & MR );
00133     //---------------------------------------------------------------
00134     // Pre apply rotation (defined by axis and angle in degrees) to the transformation matrix
00135     inline void PreApplyRotationAxisAndAngle ( Vector3<T> const & vAxis, T tAngle );
00136     // Pre apply rotation (defined by axis and angle in degrees) to the transformation matrix
00137     inline void PreApplyRotationAxisAndAngle ( T x, T y, T z, T angle );
00138     // Pre apply rotation (defined by two vectors) to the transformation matrix
00139     inline void PreApplyRotationFromVectorAtoVectorB ( Vector3<T> const & A, Vector3<T> const & B );
00140     //-----------------------
00141     // Post apply rotation (defined by axis and angle in degrees) to the transformation matrix
00142     inline void ApplyRotationAxisAndAngle ( Vector3<T> const & vAxis, T tAngle );
00143     // Post apply rotation (defined by axis and angle in degrees) to the transformation matrix
00144     inline void ApplyRotationAxisAndAngle ( T x, T y, T z, T angle );
00145     // Post apply rotation (defined by two vectors) to the transformation matrix
00146     inline void ApplyRotationFromVectorAtoVectorB ( Vector3<T> const & A, Vector3<T> const & B );
00147     //---------------------------------------------------------------
00148     // Pre apply scales for X-, Y-, and Z-Axes
00149     inline void PreApplyScale ( Vector3<T> const & vScale );
00150     // Pre apply scales for X-, Y-, and Z-Axes
00151     inline void PreApplyScale ( T x, T y, T z );
00152     // Pre apply scales uniformly for X-, Y-, and Z-Axes
00153     inline void PreApplyUniformScale ( T s );
00154     //-----------------------
00155     // Post apply scales for X-, Y-, and Z-Axes
00156     inline void ApplyScale ( Vector3<T> const & vScale );
00157     // Post apply scales for X-, Y-, and Z-Axes
00158     inline void ApplyScale ( T x, T y, T z );
00159     // Post apply scales uniformly for X-, Y-, and Z-Axes
00160     inline void ApplyUniformScale ( T s );
00161 
00163     //inline TransformationSupport const * GetParent () const   { return m_pParent; }
00165     //inline TransformationSupport * GetParent ()               { return m_pParent; };
00167     //inline void SetParent ( TransformationSupport * pParent ) { m_pParent = pParent; };
00168 
00169     //---------------------------------------------------------------
00170     //===============================================================
00171     //---------------------------------------------------------------
00172 
00174     //inline Vector3<T> GetCenterOfTransformation () const
00175     //{ return m_TranformationCenter; }
00176 
00178     //inline void SetCenterOfTransformation ( Vector3<T> const & centerOfTransformation )
00179     //{ m_TranformationCenter = centerOfTransformation; }
00180 
00181     //---------------------------------------------------------------
00182     // (3x3) Rotation Matrix
00183     inline Matrix3x3<T> GetMatrixRotation () const
00184         { 
00185             return Matrix3x3<T>( 
00186                 m_TransformationMatrix[ 0], m_TransformationMatrix[ 1], m_TransformationMatrix[ 2], 
00187                 m_TransformationMatrix[ 4], m_TransformationMatrix[ 5], m_TransformationMatrix[ 6], 
00188                 m_TransformationMatrix[ 8], m_TransformationMatrix[ 9], m_TransformationMatrix[10] 
00189             );
00190         }
00191     inline void GetMatrixRotation ( Matrix3x3<T> & MR ) const
00192         { 
00193             MR[0] = m_TransformationMatrix[ 0];
00194             MR[1] = m_TransformationMatrix[ 1];
00195             MR[2] = m_TransformationMatrix[ 2];
00196             MR[3] = m_TransformationMatrix[ 4];
00197             MR[4] = m_TransformationMatrix[ 5];
00198             MR[5] = m_TransformationMatrix[ 6];
00199             MR[6] = m_TransformationMatrix[ 8];
00200             MR[7] = m_TransformationMatrix[ 9];
00201             MR[8] = m_TransformationMatrix[10];
00202         }
00203     inline void SetMatrixRotation ( Matrix3x3<T> const & MR )
00204         {
00205             m_TransformationMatrix[ 0] = MR[0];
00206             m_TransformationMatrix[ 1] = MR[1];
00207             m_TransformationMatrix[ 2] = MR[2];
00208             m_TransformationMatrix[ 4] = MR[3];
00209             m_TransformationMatrix[ 5] = MR[4];
00210             m_TransformationMatrix[ 6] = MR[5];
00211             m_TransformationMatrix[ 8] = MR[6];
00212             m_TransformationMatrix[ 9] = MR[7];
00213             m_TransformationMatrix[10] = MR[8];
00214         }
00215 
00217     inline Quaternion<T> GetRotationAsQuaternion ()
00218         {
00219             Quaternion<T> q;
00220             q.SetFromRotationMatrix3x3( GetMatrixRotation() );
00221             return q;
00222         }
00223     //---------------------------------------------------------------
00224     // (4x4) Transformation Matrix
00225     inline Matrix4x4<T> const & RefToMatrixTransform () const
00226         { return m_TransformationMatrix; }
00227     inline Matrix4x4<T> &       RefToMatrixTransform ()
00228         { return m_TransformationMatrix; }
00229     inline Matrix4x4<T> const & GetMatrixTransform () const
00230         { return m_TransformationMatrix; }
00231     inline void GetMatrixTransform ( Matrix4x4<T> & MT ) const
00232         { MT = m_TransformationMatrix; }
00233     inline void SetMatrixTransform ( Matrix4x4<T> const & MT )
00234         { m_TransformationMatrix = MT; }
00235     inline Matrix4x4<T> GetInverseMatrixTransform () const
00236         { return m_TransformationMatrix.GetInverse(); }
00237     //-------------------------------------------------------------------------
00238     //=========================================================================
00239     //-------------------------------------------------------------------------
00240     // Static Member Functions for Data Conversions
00241     inline const float *        GetMatrixTransformFloat () const;
00242     inline const double *       GetMatrixTransformDouble () const;
00243     inline const long double *  GetMatrixTransformLongDouble () const;
00244     inline const float *        GetTransposeMatrixTransformFloat () const;
00245     inline const double *       GetTransposeMatrixTransformDouble () const;
00246     inline const long double *  GetTransposeMatrixTransformLongDouble () const;
00247     //-------------------------------------------------------------------------
00248 
00249 protected:
00250 //-----------------------------------------------------------------------------
00251 // Model Transformation (DATA MEMBERS)
00252 //------------------------------------------------------------------------
00253     Matrix4x4<T>    m_TransformationMatrix; 
00254     //TransformationSupport<T> * m_pParent; //!< transformation parent
00255 
00256     //-------------------------------------------------------------------------
00257     //=========================================================================
00258 #if defined(__gl_h_) || defined(__GL_H__)
00259 public:
00260     // Transfrom by OpenGL for Drawing by OpenGL
00261     inline void TransformByOpenGLForDrawing () const;
00262 #endif
00263     //-------------------------------------------------------------------------
00264 };  // End class TransformationSupport<T>
00265 //=============================================================================
00266 END_NAMESPACE_TAPs
00267 //-----------------------------------------------------------------------------
00268 // Include definition if TAPs_USE_EXPORT is not defined
00269 //#if !defined( TAPs_USE_EXPORT )
00270     #include "TAPsTransformationSupport.cpp"
00271 //#endif
00272 //-----------------------------------------------------------------------------
00273 #endif
00274 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00275 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines