TAPs 0.7.7.3
TAPsImplicitObject.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsImplicitObject.cpp
00003 ******************************************************************************/
00007 /******************************************************************************
00008 SUKITTI PUNAK   (10/14/2009)
00009 UPDATE          (09/03/2010)
00010 ******************************************************************************/
00011 #include "TAPsImplicitObject.hpp"
00012 // Using Inclusion Model (i.e. definitions are included in declarations)
00013 //                       (this name.cpp is included in name.hpp)
00014 // Each friend is defined directly inside its declaration.
00015 
00016 BEGIN_NAMESPACE_TAPs
00017 //=============================================================================
00018 template <typename T> unsigned int  ImplicitObject<T>::g_NumOfObjects   = 0;
00019 //=============================================================================
00020 
00021 // Default constructor
00022 template <typename T>
00023 ImplicitObject<T>::ImplicitObject ( Enum::Shape shape, std::string & name )
00024     : m_ID( g_NumOfObjects++ ), m_Name( name ), m_Shape( shape )
00025 {
00026     #ifdef  TAPs_USE_GLSL
00027     OpenGL::GlobalGLSLShaderPool::Init();
00028     ShaderName = OpenGL::GlobalGLSLShaderPool::DEFAULT;
00029     #endif//TAPs_USE_GLSL
00030 
00031     #ifdef  TAPs_SHOW_COLLISION_STATE
00032         IsCollided = false;
00033     #endif//TAPs_SHOW_COLLISION_STATE
00034 }
00035 
00036 
00037 // Copy constructor
00038 template <typename T>
00039 ImplicitObject<T>::ImplicitObject ( ImplicitObject<T> const & obj )
00040     : m_ID( g_NumOfObjects++ ), m_Name( obj.m_Name ), m_Trx( obj.m_Trx )
00041 {
00042     #ifdef  TAPs_USE_GLSL
00043     ShaderName = obj.ShaderName;
00044     #endif//TAPs_USE_GLSL
00045 }
00046 
00047 
00048 // Destructor
00049 template <typename T>
00050 ImplicitObject<T>::~ImplicitObject ()
00051 {}
00052 
00053 
00054 // Return this object info as a string
00055 template <typename T>
00056 std::string ImplicitObject<T>::StrInfo () const
00057 {
00058     std::ostringstream ss;
00059     ss << "ImplicitObject<" << typeid(T).name() << ">";
00060     ss << "ID:\t" << m_ID << "; Name:\t" << m_Name;
00061     ss << "Transformation Support: " << m_Trx;
00062 
00063     return ss.str();
00064 }
00065 
00066 
00067 // Assignment Operator
00068 template <typename T>
00069 ImplicitObject<T> & ImplicitObject<T>::operator= ( ImplicitObject<T> const &orig )
00070 {   
00071     m_Name  = orig.m_Name;
00072     m_Trx   = orig.m_Trx;
00073 
00074     #ifdef  TAPs_USE_GLSL
00075     ShaderName = orig.ShaderName;
00076     #endif//TAPs_USE_GLSL
00077 
00078     return *this;
00079 }
00080 
00081 
00082 // Set transformation support
00083 template <typename T>
00084 void ImplicitObject<T>::SetTransform ( TransformationSupport<T> & Trx )
00085 {
00086     m_Trx = Trx;
00087     m_pBVHTree->GetTransform() = m_Trx;
00088 }
00089 
00090 
00091 // Set transformation support
00092 template <typename T>
00093 Vector3<T> ImplicitObject<T>::GetTransformedCenter () const
00094 {
00095     return (m_Trx.RefToMatrixTransform() * Vector4<T>(0,0,0,1)).GetVector3();
00096 }
00097 
00098 //-----------------------------------------------------------------------------
00099 //=============================================================================
00100 END_NAMESPACE_TAPs
00101 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00102 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines