#include <TAPsTransformationSupport.hpp>
Public Member Functions | |
| void | ApplyRotationAxisAndAngle (T x, T y, T z, T angle) |
| void | ApplyRotationAxisAndAngle (Vector3< T > const &vAxis, T tAngle) |
| void | ApplyRotationFromVectorAtoVectorB (Vector3< T > const &A, Vector3< T > const &B) |
| void | ApplyScale (T x, T y, T z) |
| void | ApplyScale (Vector3< T > const &vScale) |
| void | ApplyTranslation (T x, T y, T z) |
| void | ApplyTranslation (Vector3< T > const &C) |
| void | ApplyUniformScale (T s) |
| void | DisableStatusApplyTransformation () |
| void | EnableStatusApplyTransformation () |
| Vector3< T > | GetCenterOfTransformation () const |
| Get the center of transformation. | |
| void | GetMatrixRotation (Matrix3x3< T > &MR) const |
| Matrix3x3< T > | GetMatrixRotation () const |
| void | GetMatrixTransform (Matrix4x4< T > &MT) const |
| Matrix4x4< T > | GetMatrixTransform () const |
| double & | GetMatrixTransformDouble () const |
| float & | GetMatrixTransformFloat () const |
| long double & | GetMatrixTransformLongDouble () const |
| bool | GetStatusApplyTransformation () const |
| void | GetTranslation (T &x, T &y, T &z) const |
| void | GetTranslation (Vector3< T > &C) const |
| Vector3< T > | GetTranslation () const |
| double & | GetTransposeMatrixTransformDouble () const |
| float & | GetTransposeMatrixTransformFloat () const |
| long double & | GetTransposeMatrixTransformLongDouble () const |
| void | MakeIdentity () |
| TransformationSupport< T > & | operator= (TransformationSupport< T > const &orig) |
| Assignment Operator. | |
| void | PreApplyRotationAxisAndAngle (T x, T y, T z, T angle) |
| void | PreApplyRotationAxisAndAngle (Vector3< T > const &vAxis, T tAngle) |
| void | PreApplyRotationFromVectorAtoVectorB (Vector3< T > const &A, Vector3< T > const &B) |
| void | PreApplyScale (T x, T y, T z) |
| void | PreApplyScale (Vector3< T > const &vScale) |
| void | PreApplyTranslation (T x, T y, T z) |
| void | PreApplyTranslation (Vector3< T > const &C) |
| void | PreApplyUniformScale (T s) |
| Matrix4x4< T > & | ReturnMatrixTransform () |
| Matrix4x4< T > const & | ReturnMatrixTransform () const |
| T & | ReturnTranslation (int i) |
| void | SetCenterOfTransformation (Vector3< T > const ¢erOfTransformation) |
| Set the center of transformation. | |
| void | SetMatrixRotation (Matrix3x3< T > const &MR) |
| void | SetMatrixTransform (Matrix4x4< T > const &MT) |
| void | SetStatusApplyTransformation (bool b) |
| void | SetTranslation (T x, T y, T z) |
| void | SetTranslation (Vector3< T > const &C) |
| virtual std::string | StrInfo () const |
| Return this object info as a string. | |
| void | ToggleStatusApplyTransformation () |
| TransformationSupport (const TransformationSupport< T > &orig) | |
| Copy Constructor. | |
| TransformationSupport () | |
| Default Constructor. | |
| virtual | ~TransformationSupport () |
| Destructor. | |
Protected Member Functions | |
| virtual void | TransformByTranslationRatationAndScale () |
Protected Attributes | |
| bool | m_bApplyTransform |
| flag for applying transformation | |
| Matrix4x4< T > | m_TransformationMatrix |
| transformation (translate, rotation, & scaling) | |
Friends | |
| std::ostream & | operator<< (std::ostream &output, TransformationSupport< T > const &obj) |
| Output Operator <<. | |
--------------------------------------------------------------------------- REMARK: --------------------------------------------------------------------------- A model that needs transformation should has an attribute of this class for transformation support. The model should has a fn called TransformByTranslationRatationAndScale for transformation support.
If a model is inherited from this class the model should overwrite TransformByTranslationRatationAndScale fn for transformation support.
The purpose of TransformByTranslationRatationAndScale fn is to apply the current translation, rotation, and scale to the model directly, i.e. change the position of model's vertices permamently. Then all of the translation, rotation, and scale must be reset to identity values. By applying transformation to model's vertices directly, the model's vertices can be used directly without transforming them first. This can be used for speeding up the simulation. ---------------------------------------------------------------------------
All Apply Fns are accumulate transform fns, i.e. the transform are added up. All Set Fns are set transform fns, i.e. set the values directly. All Get Fns return a copy of the get value(s). All Return Fns return a reference of the get value(s).
All Apply Fns are applied on the right-most (right in front of vertex) If want to apply on the left-most, use a PreApply Fn.
The transformation is followed the right-most transformation. Hence, the transformations applied are in opposite order. For example, say the transformation matrix is identity matrix, then apply transformation A, B, C, and D in the order will make the transformation matrix become A*B*C*D. So the vertex v will be transformed to A*B*C*D*v. Means v is transformed by D, followed by C, B, then A respectively. Therefore, the transformation is applied in opposite order to the vertex v. Where: The vertex is a column vector The transformation matrix is 4x4 matrix in row vectors. (Remark this is different from OpenGL where its matrices are column vectors.)
More about this transformation from the example above where we have A*B*C*D*v: If we think of it as transform A, followed by B, C, and D to the vertex v, then the transformation can be regarded as happened in the local coordinate system where the vertex v resides in, i.e. from a fixed point of view the coordinate is changed by each transformation. If we think of it as transform D applied to v first, then followed by C, B, and A, then the transformation can be regarded as happened in a fixed coordinate system, i.e. from a fixed point of view the coordinate is never changed by transformations. If TAPs_TRANSFORMATION_SUPPORT_WITH_HIERARCHY is defined, then the transformation support is built with a set of parent and child transformations.
Definition at line 80 of file TAPsTransformationSupport.hpp.
| BEGIN_NAMESPACE_TAPs TransformationSupport< T >::TransformationSupport | ( | ) | [inline] |
Default Constructor.
A Transformation support.
An model that needs transformation should has an attribute of this class for transformation support. The model should has a fn called TransformByTranslationRatationAndScale for transformation support.
If a model is inherited from this class the model should overwrite TransformByTranslationRatationAndScale fn for transformation support.
The purpose of TransformByTranslationRatationAndScale fn is to apply the current translation, rotation, and scale to the model, then all of the translation, rotation, and scale should be reset to default values.
Definition at line 33 of file TAPsTransformationSupport.cpp.
00034 : m_bApplyTransform( false )//, m_TransformationCenter( 0,0,0 ) 00035 { 00036 MakeIdentity(); 00037 00038 #ifdef TAPs_DEBUG_MODE 00039 std::cout << "TransformationSupport<" << typeid(T).name() << "> constructor\n"; 00040 #endif//TAPs_DEBUG_MODE 00041 }
| TransformationSupport< T >::TransformationSupport | ( | const TransformationSupport< T > & | orig | ) | [inline] |
Copy Constructor.
Definition at line 45 of file TAPsTransformationSupport.cpp.
00046 : m_bApplyTransform( orig.m_bApplyTransform ), 00047 m_TransformationMatrix( orig.m_TransformationMatrix ) 00048 //, m_TransformationCenter( orig.m_TransformationCenter ) 00049 #ifdef TAPs_TRANSFORMATION_SUPPORT_WITH_HIERARCHY 00050 , 00051 m_svParents( orig.m_svParents ); 00052 m_svChildren( orig.m_svChildren ); 00053 #endif//TAPs_TRANSFORMATION_SUPPORT_WITH_HIERARCHY 00054 { 00055 #ifdef TAPs_DEBUG_MODE 00056 std::cout << "TransformationSupport<" << typeid(T).name() << "> copy constructor\n"; 00057 #endif//TAPs_DEBUG_MODE 00058 }
| TransformationSupport< T >::~TransformationSupport | ( | ) | [inline, virtual] |
Destructor.
Definition at line 62 of file TAPsTransformationSupport.cpp.
00063 { 00064 #ifdef TAPs_DEBUG_MODE 00065 std::cout << "TransformationSupport<" << typeid(T).name() << "> destructor\n"; 00066 #endif//TAPs_DEBUG_MODE 00067 }
| void TransformationSupport< T >::ApplyRotationAxisAndAngle | ( | T | x, | |
| T | y, | |||
| T | z, | |||
| T | angle | |||
| ) | [inline] |
Definition at line 258 of file TAPsTransformationSupport.cpp.
00260 { 00261 ApplyRotationAxisAndAngle( Vector3<T>( x, y, z ), angle ); 00262 }
| void TransformationSupport< T >::ApplyRotationAxisAndAngle | ( | Vector3< T > const & | vAxis, | |
| T | tAngle | |||
| ) | [inline] |
Definition at line 249 of file TAPsTransformationSupport.cpp.
00251 { 00252 m_TransformationMatrix *= 00253 Matrix4x4<T>( CGMath<T>::CreateRotationMatrix3x3( vAxis, tAngle ) ); 00254 }
| void TransformationSupport< T >::ApplyRotationFromVectorAtoVectorB | ( | Vector3< T > const & | A, | |
| Vector3< T > const & | B | |||
| ) | [inline] |
Definition at line 266 of file TAPsTransformationSupport.cpp.
00268 { 00269 m_TransformationMatrix *= 00270 Matrix4x4<T>( CGMath<T>::CreateRotationMatrix3x3FromVectorAtoVectorB( A, B ) ); 00271 }
| void TransformationSupport< T >::ApplyScale | ( | T | x, | |
| T | y, | |||
| T | z | |||
| ) | [inline] |
Definition at line 305 of file TAPsTransformationSupport.cpp.
00306 { 00307 ApplyScale( Vector3<T>( x, y, z ) ); 00308 }
| void TransformationSupport< T >::ApplyScale | ( | Vector3< T > const & | vScale | ) | [inline] |
Definition at line 298 of file TAPsTransformationSupport.cpp.
00299 { 00300 m_TransformationMatrix *= Matrix4x4<T>( vScale ); 00301 }
| void TransformationSupport< T >::ApplyTranslation | ( | T | x, | |
| T | y, | |||
| T | z | |||
| ) | [inline] |
Definition at line 151 of file TAPsTransformationSupport.cpp.
00152 { 00153 m_TransformationMatrix *= 00154 Matrix4x4<T>( 00155 1, 0, 0, x, 00156 0, 1, 0, y, 00157 0, 0, 1, z, 00158 0, 0, 0, 1 00159 ); 00160 }
| void TransformationSupport< T >::ApplyTranslation | ( | Vector3< T > const & | C | ) | [inline] |
Definition at line 138 of file TAPsTransformationSupport.cpp.
00139 { 00140 m_TransformationMatrix *= 00141 Matrix4x4<T>( 00142 1, 0, 0, C[0], 00143 0, 1, 0, C[1], 00144 0, 0, 1, C[2], 00145 0, 0, 0, 1 00146 ); 00147 }
| void TransformationSupport< T >::ApplyUniformScale | ( | T | s | ) | [inline] |
Definition at line 312 of file TAPsTransformationSupport.cpp.
00313 { 00314 ApplyScale( Vector3<T>( s, s, s ) ); 00315 }
| void TransformationSupport< T >::DisableStatusApplyTransformation | ( | ) | [inline] |
| void TransformationSupport< T >::EnableStatusApplyTransformation | ( | ) | [inline] |
| Vector3<T> TransformationSupport< T >::GetCenterOfTransformation | ( | ) | const [inline] |
| void TransformationSupport< T >::GetMatrixRotation | ( | Matrix3x3< T > & | MR | ) | const [inline] |
Definition at line 180 of file TAPsTransformationSupport.hpp.
00181 { 00182 MR[0] = m_TransformationMatrix[ 0]; 00183 MR[1] = m_TransformationMatrix[ 1]; 00184 MR[2] = m_TransformationMatrix[ 2]; 00185 MR[3] = m_TransformationMatrix[ 4]; 00186 MR[4] = m_TransformationMatrix[ 5]; 00187 MR[5] = m_TransformationMatrix[ 6]; 00188 MR[6] = m_TransformationMatrix[ 8]; 00189 MR[7] = m_TransformationMatrix[ 9]; 00190 MR[8] = m_TransformationMatrix[10]; 00191 }
| Matrix3x3<T> TransformationSupport< T >::GetMatrixRotation | ( | ) | const [inline] |
Definition at line 172 of file TAPsTransformationSupport.hpp.
00173 { 00174 return Matrix3x3<T>( 00175 m_TransformationMatrix[ 0], m_TransformationMatrix[ 1], m_TransformationMatrix[ 2], 00176 m_TransformationMatrix[ 4], m_TransformationMatrix[ 5], m_TransformationMatrix[ 6], 00177 m_TransformationMatrix[ 8], m_TransformationMatrix[ 9], m_TransformationMatrix[10] 00178 ); 00179 }
| void TransformationSupport< T >::GetMatrixTransform | ( | Matrix4x4< T > & | MT | ) | const [inline] |
Definition at line 212 of file TAPsTransformationSupport.hpp.
00213 { MT = m_TransformationMatrix; }
| Matrix4x4<T> TransformationSupport< T >::GetMatrixTransform | ( | ) | const [inline] |
Definition at line 210 of file TAPsTransformationSupport.hpp.
00211 { return m_TransformationMatrix; }
| double & TransformationSupport< T >::GetMatrixTransformDouble | ( | ) | const [inline] |
Definition at line 325 of file TAPsTransformationSupport.cpp.
00326 { return GetMatrixTransform().GetDataDouble(); }
| float & TransformationSupport< T >::GetMatrixTransformFloat | ( | ) | const [inline] |
Definition at line 321 of file TAPsTransformationSupport.cpp.
00322 { return GetMatrixTransform().GetDataFloat(); }
| long double & TransformationSupport< T >::GetMatrixTransformLongDouble | ( | ) | const [inline] |
Definition at line 329 of file TAPsTransformationSupport.cpp.
00330 { return GetMatrixTransform().GetDataLongDouble(); }
| bool TransformationSupport< T >::GetStatusApplyTransformation | ( | ) | const [inline] |
| void TransformationSupport< T >::GetTranslation | ( | T & | x, | |
| T & | y, | |||
| T & | z | |||
| ) | const [inline] |
Definition at line 184 of file TAPsTransformationSupport.cpp.
00185 { 00186 x = m_TransformationMatrix[ 3]; 00187 y = m_TransformationMatrix[ 7]; 00188 z = m_TransformationMatrix[11]; 00189 }
| void TransformationSupport< T >::GetTranslation | ( | Vector3< T > & | C | ) | const [inline] |
Definition at line 175 of file TAPsTransformationSupport.cpp.
00176 { 00177 C[0] = m_TransformationMatrix[ 3]; 00178 C[1] = m_TransformationMatrix[ 7]; 00179 C[2] = m_TransformationMatrix[11]; 00180 }
| Vector3< T > TransformationSupport< T >::GetTranslation | ( | ) | const [inline] |
Definition at line 164 of file TAPsTransformationSupport.cpp.
00165 { 00166 return Vector3<T>( 00167 m_TransformationMatrix[ 3], 00168 m_TransformationMatrix[ 7], 00169 m_TransformationMatrix[11] 00170 ); 00171 }
| double & TransformationSupport< T >::GetTransposeMatrixTransformDouble | ( | ) | const [inline] |
Definition at line 337 of file TAPsTransformationSupport.cpp.
00338 { return GetMatrixTransform().GetTransposeDataDouble(); }
| float & TransformationSupport< T >::GetTransposeMatrixTransformFloat | ( | ) | const [inline] |
Definition at line 333 of file TAPsTransformationSupport.cpp.
00334 { return GetMatrixTransform().GetTransposeDataFloat(); }
| long double & TransformationSupport< T >::GetTransposeMatrixTransformLongDouble | ( | ) | const [inline] |
Definition at line 341 of file TAPsTransformationSupport.cpp.
00342 { return GetMatrixTransform().GetTransposeDataLongDouble(); }
| void TransformationSupport< T >::MakeIdentity | ( | ) | [inline] |
Definition at line 114 of file TAPsTransformationSupport.hpp.
00114 { m_TransformationMatrix.MakeIdentity(); }
| TransformationSupport<T>& TransformationSupport< T >::operator= | ( | TransformationSupport< T > const & | orig | ) | [inline] |
Assignment Operator.
| void TransformationSupport< T >::PreApplyRotationAxisAndAngle | ( | T | x, | |
| T | y, | |||
| T | z, | |||
| T | angle | |||
| ) | [inline] |
Definition at line 231 of file TAPsTransformationSupport.cpp.
00233 { 00234 PreApplyRotationAxisAndAngle( Vector3<T>( x, y, z ), angle ); 00235 }
| void TransformationSupport< T >::PreApplyRotationAxisAndAngle | ( | Vector3< T > const & | vAxis, | |
| T | tAngle | |||
| ) | [inline] |
Definition at line 221 of file TAPsTransformationSupport.cpp.
00223 { 00224 m_TransformationMatrix = 00225 Matrix4x4<T>( CGMath<T>::CreateRotationMatrix3x3( vAxis, tAngle ) ) 00226 * m_TransformationMatrix; 00227 }
| void TransformationSupport< T >::PreApplyRotationFromVectorAtoVectorB | ( | Vector3< T > const & | A, | |
| Vector3< T > const & | B | |||
| ) | [inline] |
Definition at line 239 of file TAPsTransformationSupport.cpp.
00241 { 00242 m_TransformationMatrix = 00243 Matrix4x4<T>( CGMath<T>::CreateRotationMatrix3x3FromVectorAtoVectorB( A, B ) ); 00244 * m_TransformationMatrix; 00245 }
| void TransformationSupport< T >::PreApplyScale | ( | T | x, | |
| T | y, | |||
| T | z | |||
| ) | [inline] |
Definition at line 284 of file TAPsTransformationSupport.cpp.
00285 { 00286 PreApplyScale( Vector3<T>( x, y, z ) ); 00287 }
| void TransformationSupport< T >::PreApplyScale | ( | Vector3< T > const & | vScale | ) | [inline] |
Definition at line 277 of file TAPsTransformationSupport.cpp.
00278 { 00279 m_TransformationMatrix = Matrix4x4<T>( vScale ) * m_TransformationMatrix; 00280 }
| void TransformationSupport< T >::PreApplyTranslation | ( | T | x, | |
| T | y, | |||
| T | z | |||
| ) | [inline] |
Definition at line 125 of file TAPsTransformationSupport.cpp.
00126 { 00127 m_TransformationMatrix = 00128 Matrix4x4<T>( 00129 1, 0, 0, x, 00130 0, 1, 0, y, 00131 0, 0, 1, z, 00132 0, 0, 0, 1 00133 ) * m_TransformationMatrix; 00134 }
| void TransformationSupport< T >::PreApplyTranslation | ( | Vector3< T > const & | C | ) | [inline] |
Definition at line 112 of file TAPsTransformationSupport.cpp.
00113 { 00114 m_TransformationMatrix = 00115 Matrix4x4<T>( 00116 1, 0, 0, C[0], 00117 0, 1, 0, C[1], 00118 0, 0, 1, C[2], 00119 0, 0, 0, 1 00120 ) * m_TransformationMatrix; 00121 }
| void TransformationSupport< T >::PreApplyUniformScale | ( | T | s | ) | [inline] |
Definition at line 291 of file TAPsTransformationSupport.cpp.
00292 { 00293 PreApplyScale( Vector3<T>( s, s, s ) ); 00294 }
| Matrix4x4<T>& TransformationSupport< T >::ReturnMatrixTransform | ( | ) | [inline] |
Definition at line 208 of file TAPsTransformationSupport.hpp.
00209 { return m_TransformationMatrix; }
| Matrix4x4<T> const& TransformationSupport< T >::ReturnMatrixTransform | ( | ) | const [inline] |
Definition at line 206 of file TAPsTransformationSupport.hpp.
00207 { return m_TransformationMatrix; }
| T & TransformationSupport< T >::ReturnTranslation | ( | int | i | ) | [inline] |
Definition at line 211 of file TAPsTransformationSupport.cpp.
00212 { 00213 assert( 0 <= i && i <= 2 ); 00214 return m_TransformationMatrix[i*4 + 3]; 00215 }
| void TransformationSupport< T >::SetCenterOfTransformation | ( | Vector3< T > const & | centerOfTransformation | ) | [inline] |
| void TransformationSupport< T >::SetMatrixRotation | ( | Matrix3x3< T > const & | MR | ) | [inline] |
Definition at line 192 of file TAPsTransformationSupport.hpp.
00193 { 00194 m_TransformationMatrix[ 0] = MR[0]; 00195 m_TransformationMatrix[ 1] = MR[1]; 00196 m_TransformationMatrix[ 2] = MR[2]; 00197 m_TransformationMatrix[ 4] = MR[3]; 00198 m_TransformationMatrix[ 5] = MR[4]; 00199 m_TransformationMatrix[ 6] = MR[5]; 00200 m_TransformationMatrix[ 8] = MR[6]; 00201 m_TransformationMatrix[ 9] = MR[7]; 00202 m_TransformationMatrix[10] = MR[8]; 00203 }
| void TransformationSupport< T >::SetMatrixTransform | ( | Matrix4x4< T > const & | MT | ) | [inline] |
Definition at line 214 of file TAPsTransformationSupport.hpp.
00215 { m_TransformationMatrix = MT; }
| void TransformationSupport< T >::SetStatusApplyTransformation | ( | bool | b | ) | [inline] |
| void TransformationSupport< T >::SetTranslation | ( | T | x, | |
| T | y, | |||
| T | z | |||
| ) | [inline] |
Definition at line 202 of file TAPsTransformationSupport.cpp.
00203 { 00204 m_TransformationMatrix[ 3] = x; 00205 m_TransformationMatrix[ 7] = y; 00206 m_TransformationMatrix[11] = z; 00207 }
| void TransformationSupport< T >::SetTranslation | ( | Vector3< T > const & | C | ) | [inline] |
Definition at line 193 of file TAPsTransformationSupport.cpp.
00194 { 00195 m_TransformationMatrix[ 3] = C[0]; 00196 m_TransformationMatrix[ 7] = C[1]; 00197 m_TransformationMatrix[11] = C[2]; 00198 }
| std::string TransformationSupport< T >::StrInfo | ( | ) | const [inline, virtual] |
Return this object info as a string.
Definition at line 71 of file TAPsTransformationSupport.cpp.
00072 { 00073 std::ostringstream ss; 00074 ss << "TransformationSupport<" << typeid(T).name() << ">"; 00075 ss << "\n Apply Status: "; 00076 if ( m_bApplyTransform ) ss << "true"; 00077 else ss << "false"; 00078 ss << "\n Trx Matrix: "; 00079 ss << m_TransformationMatrix; 00080 return ss.str(); 00081 }
| void TransformationSupport< T >::ToggleStatusApplyTransformation | ( | ) | [inline] |
Definition at line 122 of file TAPsTransformationSupport.hpp.
00122 { m_bApplyTransform = !m_bApplyTransform; }
| virtual void TransformationSupport< T >::TransformByTranslationRatationAndScale | ( | ) | [inline, protected, virtual] |
| std::ostream& operator<< | ( | std::ostream & | output, | |
| TransformationSupport< T > const & | obj | |||
| ) | [friend] |
Output Operator <<.
Definition at line 86 of file TAPsTransformationSupport.hpp.
00087 { 00088 output << obj.StrInfo(); 00089 return output; 00090 }
bool TransformationSupport< T >::m_bApplyTransform [protected] |
Matrix4x4<T> TransformationSupport< T >::m_TransformationMatrix [protected] |
transformation (translate, rotation, & scaling)
Definition at line 306 of file TAPsTransformationSupport.hpp.
1.5.6