OMK::Vis::VisualObject Class Reference

Visual object used by the visualisation to visualise the simulated objects. More...

#include <OMKVisualObject.h>

Inheritance diagram for OMK::Vis::VisualObject:

Inheritance graph
[legend]
Collaboration diagram for OMK::Vis::VisualObject:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void update ()
 The update to compute the new picture.
const VisBasegetVis () const
 returns a const reference to the associated visualisation
VisBasetouchVis () const
 returns a reference to the associated visualisation
const NamegetId () const
 Returns the id (name) of the visual object.
const Type::TransformgetTransform () const
 Returns a reference to the visual object transform.
void addAnimator (OMK::Vis::Animator *animator)
 Add an animator to the visual object.
void deleteAnimator (const Name &id)
 Delete an animator of the visual object.
OMK::Vis::AnimatorgetAnimator (const Name &id) const
 Returns the animator of the visual object.

Protected Types

typedef std::map< Name, OMK::Vis::Animator * > AnimatorsMap
 Animators list.

Protected Member Functions

virtual void visualise ()=0
 The visualisation method.

Protected Attributes

AnimatorsMap _animators

Private Member Functions

void readConfigurationParameters (const ConfigurationParameterDescriptor *node)
 read the configuration parameters : geometryFileName

Private Attributes

VisBase_vis
 reference to the associated visualisation
Name _id
 The id (name).
Type::Transform _transform
 transformation to position/orient the visual object

Detailed Description

Visual object used by the visualisation to visualise the simulated objects.

Author:
Benoit Chanclou, Micha� Rouill� bunraku <bchanclo@irisa.fr>
See also:
The visual objects and their animators
Configuration parameters :
First try to find a Position field which is a Transform (see ParametersAccessor for details). If the Position is not found try to find the following 3D vectors: Translate, Rotate and Scale. For example:
 Position [[0 1 2]]
or
 Translate [0 1.5 2]
 Rotate [0 0.3 0.3]
 Scale [0.5 0.5 0.5]
This parameters are optional, if nothing is found, the default is the null transformation, position in 0, no rotation, scale 1.

Definition at line 58 of file OMKVisualObject.h.


Member Typedef Documentation

typedef std::map< Name, OMK::Vis::Animator* > OMK::Vis::VisualObject::AnimatorsMap [protected]

Animators list.

The vector which stores the animators of the visual object

Definition at line 113 of file OMKVisualObject.h.


Constructor & Destructor Documentation

VisualObject::VisualObject ( VisBase vis,
const Name id,
const ConfigurationParameterDescriptor node 
)

Constructor of OMK::Vis::VisualObject.

Definition at line 42 of file OMKVisualObject.cpp.

References OMK::Vis::debugMsg(), OMK_DEBUG_VIS_EXEC, OMTRACEID, and readConfigurationParameters().

00042                                                                                                        :
00043 _vis( vis ),
00044 _id( id )
00045 {
00046   OMTRACEID( OMK_DEBUG_VIS_EXEC, "Construction of " << debugMsg( this ) );  
00047         readConfigurationParameters( node ) ;
00048 }

VisualObject::~VisualObject (  )  [virtual]

Destructor of OMK::Vis::VisualObject.

Destroy the animators.

Definition at line 53 of file OMKVisualObject.cpp.

References _animators, OMK::Vis::debugMsg(), OMK_DEBUG_VIS_EXEC, and OMTRACEID.

00054 {
00055   OMTRACEID( OMK_DEBUG_VIS_EXEC, "Destruction of " << debugMsg( this ) );  
00056   for( AnimatorsMap::iterator a( _animators.begin() ) ;
00057        a != _animators.end() ;
00058        a++ )
00059   {
00060     delete a->second ;
00061   }
00062   _animators.clear();
00063 }

VisualObject::VisualObject ( VisBase vis,
const Name id,
const ConfigurationParameterDescriptor node 
)

Constructor of OMK::Vis::VisualObject.

Definition at line 42 of file OMKVisualObject.cpp.

References OMK::Vis::debugMsg(), OMK_DEBUG_VIS_EXEC, OMTRACEID, and readConfigurationParameters().

00042                                                                                                        :
00043 _vis( vis ),
00044 _id( id )
00045 {
00046   OMTRACEID( OMK_DEBUG_VIS_EXEC, "Construction of " << debugMsg( this ) );  
00047         readConfigurationParameters( node ) ;
00048 }

VisualObject::~VisualObject (  )  [virtual]

Destructor of OMK::Vis::VisualObject.

Destroy the animators.

Definition at line 53 of file OMKVisualObject.cpp.

References _animators, OMK::Vis::debugMsg(), OMK_DEBUG_VIS_EXEC, and OMTRACEID.

00054 {
00055   OMTRACEID( OMK_DEBUG_VIS_EXEC, "Destruction of " << debugMsg( this ) );  
00056   for( AnimatorsMap::iterator a( _animators.begin() ) ;
00057        a != _animators.end() ;
00058        a++ )
00059   {
00060     delete a->second ;
00061   }
00062   _animators.clear();
00063 }


Member Function Documentation

void VisualObject::update (  ) 

The update to compute the new picture.

Ask to the animator to update the visual object, then calls visualize method. The method

Definition at line 68 of file OMKVisualObject.cpp.

References _animators, and visualise().

00069 {
00070   // Call each animator
00071   for( AnimatorsMap::iterator a( _animators.begin() ) ;
00072        a != _animators.end() ;
00073        ++a )
00074   {    
00075     a->second->processVis() ;
00076   }
00077  
00078   visualise() ;
00079 }

const VisBase & OMK::Vis::VisualObject::getVis (  )  const [inline]

returns a const reference to the associated visualisation

Definition at line 205 of file OMKVisualObject.h.

References _vis.

00207 {
00208   return _vis ;

VisBase & OMK::Vis::VisualObject::touchVis (  )  const [inline]

returns a reference to the associated visualisation

Definition at line 214 of file OMKVisualObject.h.

References _vis.

Referenced by OMK::Vis::Animator::Animator(), and OMK::Vis::AnimatorT< T >::AnimatorT().

00216 {
00217   return _vis ;

const Name & OMK::Vis::VisualObject::getId (  )  const [inline]

Returns the id (name) of the visual object.

Definition at line 223 of file OMKVisualObject.h.

References _id.

Referenced by OMK::Vis::VisBase::addNewVisualObject(), OMK::Vis::debugMsg(), and OMK::Vis::VisBase::processAddVisualObjectEvent().

00225 {
00226   return _id ;

const Type::Transform & OMK::Vis::VisualObject::getTransform (  )  const [inline]

Returns a reference to the visual object transform.

Definition at line 232 of file OMKVisualObject.h.

References _transform.

Referenced by OMK::Vis::OgreObject::OgreObject().

00234 {
00235   return _transform ;

void VisualObject::addAnimator ( OMK::Vis::Animator animator  ) 

Add an animator to the visual object.

Definition at line 147 of file OMKVisualObject.cpp.

References _animators, and OMK::Vis::Animator::getId().

00148 {
00149   _animators[ animator->getId() ] = animator ;
00150 }

void VisualObject::deleteAnimator ( const Name id  ) 

Delete an animator of the visual object.

Parameters:
[in] id,the id of tha animator to delete.

Definition at line 155 of file OMKVisualObject.cpp.

References _animators, OMASSERTM, OMK_DEBUG_VIS_EXEC, and OMTRACEID.

00156 {
00157   AnimatorsMap::iterator i = _animators.find( id ) ;
00158   OMASSERTM( i != _animators.end(), "The animator named \"" << id << "\" is not present !" ) ;
00159   // delete the animator
00160   delete i->second ;
00161   _animators.erase( i ) ;
00162   OMTRACEID( OMK_DEBUG_VIS_EXEC, ">>> :-) The animator named \"" << id << "\" is deleted" ) ;
00163 }

Animator * VisualObject::getAnimator ( const Name id  )  const

Returns the animator of the visual object.

Parameters:
[in] id,the id of tha animator to find.
Returns:
the pointer on the animator, or null if the animator is not present.

Definition at line 138 of file OMKVisualObject.cpp.

References _animators.

00139 {
00140   AnimatorsMap::const_iterator i = _animators.find( id ) ;
00141   return i != _animators.end() ? i->second : 0 ;
00142 }

virtual void OMK::Vis::VisualObject::visualise (  )  [protected, pure virtual]

The visualisation method.

This method is called by visualisation to compute the new picture. This method is overwritten by sons to create the visualisation.

Implemented in OMK::Vis::OgreObject, and OMK::Vis::AvatarVisualObject.

Referenced by update().

void VisualObject::readConfigurationParameters ( const ConfigurationParameterDescriptor node  )  [private]

read the configuration parameters : geometryFileName

Definition at line 84 of file OMKVisualObject.cpp.

References _transform, OMK::Vis::debugMsg(), OMK::ParametersAccessor::get(), OMK_DEBUG_VIS, OMTRACEID, OMK::Type::Transform::setRotate(), OMK::Type::Transform::setScale(), OMK::Type::Transform::setTranslate(), and OMK::Type::Transform::setUniformScale().

Referenced by VisualObject().

00085 {
00086         // Retrieve the transform parameters
00087   // First try to load a transform
00088         
00089   if( !ParametersAccessor::get( node, "Position", _transform ) )
00090   {
00091     std::vector< float > v ;
00092     if( ParametersAccessor::get( node, "Translate", v ) 
00093      && v.size() == 3 )
00094     {
00095                         _transform.setTranslate( Vector3f( v[0], v[1], v[2] ) ) ;
00096     }
00097     else
00098     {
00099                   OMTRACEID( OMK_DEBUG_VIS, "Warning for " << debugMsg( this ) << std::endl
00100                                   << ">>> :-| no translate provided, will use 0 0 0 by default" ) ; 
00101     }
00102           v.clear() ;
00103     if( ParametersAccessor::get( node, "Rotate", v ) 
00104      && v.size() == 3 )
00105     {
00106                         Matrix3f matrix ;
00107                         matrix.FromEulerAnglesXYZ( v[0], v[1], v[2] ) ;
00108                         _transform.setRotate( matrix ) ;
00109     }
00110     else
00111     {
00112                   OMTRACEID( OMK_DEBUG_VIS, "Warning for " << debugMsg( this ) << std::endl
00113                                   << ">>> :-| no rotate provided, will use 0 0 0 by default" ) ; 
00114     }
00115     v.clear() ;
00116     float scale = 1.0f ;
00117     if( ParametersAccessor::get( node, "Scale", v ) 
00118      && v.size() == 3 )
00119     {
00120                         _transform.setScale( Vector3f( v[0], v[1], v[2] ) ) ;
00121     }
00122     if( ParametersAccessor::get( node, "Scale", scale ) ) 
00123     {
00124                         _transform.setUniformScale( scale ) ;
00125     }
00126     else
00127     {
00128                   OMTRACEID( OMK_DEBUG_VIS, "Warning for " << debugMsg( this ) << std::endl
00129                                   << ">>> :-| no scale provided, will use 0 0 0 by default" ) ; 
00130     }
00131   }
00132 
00133 }


Member Data Documentation

AnimatorsMap OMK::Vis::VisualObject::_animators [protected]

Definition at line 114 of file OMKVisualObject.h.

Referenced by addAnimator(), deleteAnimator(), getAnimator(), update(), OMK::Vis::OgreObject::~OgreObject(), and ~VisualObject().

VisBase& OMK::Vis::VisualObject::_vis [private]

reference to the associated visualisation

Definition at line 123 of file OMKVisualObject.h.

Referenced by getVis(), and touchVis().

Name OMK::Vis::VisualObject::_id [private]

The id (name).

Definition at line 126 of file OMKVisualObject.h.

Referenced by getId().

Type::Transform OMK::Vis::VisualObject::_transform [private]

transformation to position/orient the visual object

Definition at line 129 of file OMKVisualObject.h.

Referenced by getTransform(), and readConfigurationParameters().


logo OpenMask

Documentation generated on Mon Jun 9 11:46:05 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007