OMK::Vis::MaterialAnimator< Type > Class Template Reference
[Animators]

Animator to change the material. More...

#include <OMKMaterialAnimator.h>

Inheritance diagram for OMK::Vis::MaterialAnimator< Type >:

Inheritance graph
[legend]
Collaboration diagram for OMK::Vis::MaterialAnimator< Type >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

template<>
void selfProcessVis (const OMK::Type::StringType &value)
template<>
void selfProcessVis (const OMK::Type::BoolType &value)

Protected Member Functions

virtual void update (NodeMaterial *node)
virtual Ogre::String getMaterialName (const Ogre::String &name) const
virtual void undo (NodeMaterial *node)

Protected Attributes

std::string _materialName
NodeMaterialOrig_node
 pointer to the node to animate
bool _modified

Private Member Functions

 DECLARE_TEMPLATE_ANIMATOR_FACTORY (MaterialAnimator, Type)
virtual void selfProcessVis (const Type &value)
 Called by the partner to process the visualisation.
void doIt (bool activate)

Detailed Description

template<typename Type>
class OMK::Vis::MaterialAnimator< Type >

Animator to change the material.

Author:
Xavier Larrodé, bunraku <xlarrode@irisa.fr>

Benoît Chanclou, bunraku <bchanclo@irisa.fr>

Configuration parameters :
The configuration parameters are those of any animator and :
Animator
{
  myMaterialAnimator
  {
    Class MaterialAnimator // or MaterialBoolAnimator
    NodeName Robot
    changeInitMaterial "initialMaterial" // Optional
    material "aMaterial"
  }
} 
There are two types for the value to change the material.

The first type, MaterialBoolAnimator class, is a boolean:

The second type, MaterialAnimator class, is a string: Example:
visuOgre
{
  Class OgreVis
  ...
  Extensions
  {
    ...
    materialWithString
    {
      Class KeyStringEmitterExtension
      Key E
      VisuName visuOgre 
      EventName "materialWithString"
      Values ["TOGGLE"]
      Signal on
    }
    materialWithBool
    {
      Class KeyBoolEmitterExtension
      Key A
      VisuName visuOgre 
      EventName "materialWithBool"
      Values [ON OFF]
      Signal on
    }        
    ...
  }
  UserParams
  {
    OgreHome "${OGRE_HOME}"
    ...
    VisualObject
    {
      ...
      scene
      {
        Class OgreObjectScene
        ...
        Animator
        {
          materialWithString
          {
            Class MaterialAnimator
            NodeName FirstNODE
            material "first_material"
            ListenedEvent "materialWithString"
          }
          materialWithBool
          {
            Class MaterialBoolAnimator
            NodeName SecondNODE
            material "second_material"
            ListenedEvent "materialWithBool"
          }
        }
      }
      ...
    }
  }
}

Definition at line 134 of file OMKMaterialAnimator.h.


Member Function Documentation

template<typename Type>
OMK::Vis::MaterialAnimator< Type >::DECLARE_TEMPLATE_ANIMATOR_FACTORY ( MaterialAnimator< Type >  ,
Type   
) [private]

template<typename Type>
virtual void OMK::Vis::MaterialAnimator< Type >::selfProcessVis ( const Type &  value  )  [private, virtual]

Called by the partner to process the visualisation.

Called by the public version if the value was changed. Must be overwrite by sons.

Implements OMK::Vis::AnimatorT< Type >.

template<typename Type>
void MaterialAnimator::doIt ( bool  activate  )  [private]

Definition at line 87 of file OMKMaterialAnimator.cpp.

References OMK::Vis::MaterialAnimator< Type >::_modified, OMK::Vis::MaterialAnimator< Type >::_node, OMK::Vis::NodeMaterialOrig::createCopyAndUpdateWith(), OMTRACEID, and OMK::Vis::NodeMaterialOrig::undoFor().

Referenced by OMK::Vis::MaterialAnimator< Type >::selfProcessVis().

00088 {
00089   OMTRACEID("OMK::MaterialAnimator"," modi " << _modified << " new " << activate );
00090   if( activate != _modified )
00091   {
00092     _modified = activate ;
00093     if( _modified )
00094     {
00095       OMTRACEID("OMK::MaterialAnimator"," copy" );
00096       _node->createCopyAndUpdateWith( this ) ;
00097     }
00098     else
00099     {
00100       OMTRACEID("OMK::MaterialAnimator"," UNDO " );
00101       _node->undoFor( this, true ) ;
00102     }
00103   }
00104 }

template<typename Type>
void MaterialAnimator::update ( NodeMaterial node  )  [protected, virtual]

Implements OMK::Vis::IUpdateMaterial.

Definition at line 110 of file OMKMaterialAnimator.cpp.

References OMK::Vis::MaterialAnimator< Type >::_materialName, and OMK::Vis::NodeMaterial::doAction().

00111 {
00112   node->doAction( MaterialSetMaterialName( _materialName ) ) ;
00113 }

template<typename Type>
Ogre::String MaterialAnimator::getMaterialName ( const Ogre::String &  name  )  const [protected, virtual]

Reimplemented from OMK::Vis::IUpdateMaterial.

Definition at line 119 of file OMKMaterialAnimator.cpp.

References OMK::Vis::MaterialAnimator< Type >::_materialName.

00120 { 
00121   return  _materialName ;
00122 }

template<typename Type>
void MaterialAnimator::undo ( NodeMaterial node  )  [protected, virtual]

Reimplemented from OMK::Vis::IUpdateMaterial.

Definition at line 128 of file OMKMaterialAnimator.cpp.

00129 {
00130   // must do nothing
00131   // the default destroy the material !!!
00132 }

template<>
void OMK::Vis::MaterialAnimator< OMK::Type::StringType >::selfProcessVis ( const OMK::Type::StringType value  ) 

Definition at line 143 of file OMKMaterialAnimator.cpp.

References OMK::Vis::MaterialAnimator< Type >::_modified, OMK::Vis::MaterialAnimator< Type >::doIt(), OMK::Type::SimpleTypeT< T >::getValue(), and OMTRACEID.

00144 {
00145   OMTRACEID("OMK::MaterialAnimator"," got " << value );
00146   std::string str( value.getValue() ) ;
00147   std::transform( str.begin(), str.end(), str.begin(), toupper ) ;
00148   bool newModified = !_modified ;
00149   if( str == "ON" )
00150   {
00151     newModified = true ;
00152   }
00153   else if( str == "OFF" )
00154   {
00155     newModified = false ;
00156   }
00157   doIt( newModified ) ;
00158 }

template<>
void OMK::Vis::MaterialAnimator< OMK::Type::BoolType >::selfProcessVis ( const OMK::Type::BoolType value  ) 

Definition at line 161 of file OMKMaterialAnimator.cpp.

References OMK::Vis::MaterialAnimator< Type >::doIt(), OMK::Type::SimpleTypeT< T >::getValue(), and OMTRACEID.

00162 {
00163   OMTRACEID("OMK::MaterialAnimator"," got " << value );
00164   doIt( value.getValue() ) ;
00165 }


Member Data Documentation

template<typename Type>
std::string OMK::Vis::MaterialAnimator< Type >::_materialName [protected]

Definition at line 147 of file OMKMaterialAnimator.h.

Referenced by OMK::Vis::MaterialAnimator< Type >::getMaterialName(), and OMK::Vis::MaterialAnimator< Type >::update().

template<typename Type>
NodeMaterialOrig* OMK::Vis::MaterialAnimator< Type >::_node [protected]

pointer to the node to animate

Reimplemented from OMK::Vis::OgreAnimatorCommon.

Definition at line 148 of file OMKMaterialAnimator.h.

Referenced by OMK::Vis::MaterialAnimator< Type >::doIt().

template<typename Type>
bool OMK::Vis::MaterialAnimator< Type >::_modified [protected]

Definition at line 149 of file OMKMaterialAnimator.h.

Referenced by OMK::Vis::MaterialAnimator< Type >::doIt(), and OMK::Vis::MaterialAnimator< Type >::selfProcessVis().


logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007