OMK::Vis::SwitchAnimator Class Reference
[Animators]

Handler which computes the visualisation with the associated information found by the plug. More...

#include <OMKSwitchAnimator.h>

Inheritance diagram for OMK::Vis::SwitchAnimator:

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

Collaboration graph
[legend]
List of all members.

Protected Attributes

Ogre::SceneNode * _defaultNode
Ogre::SceneNode * _oldNode
std::vector< Ogre::SceneNode * > _vecNode

Private Member Functions

 DECLARE_ANIMATOR_FACTORY (SwitchAnimator)
virtual void selfProcessVis (const OMK::Type::IntType &value)
 Called by the partner to process the visualisation.
virtual void init (const ConfigurationParameterDescriptor &node)
 init, load param

Detailed Description

Handler which computes the visualisation with the associated information found by the plug.

Author:
Xavier Larrodé, bunraku <xlarrode@irisa.fr>
Animator
{
  mySwitchAnimator
  {
    Class SwitchAnimator
    EventId SwitchStringEvent
    //Param 
    FileTab [ badTie.scene goodTie.scene ]
  }
} 

Definition at line 51 of file OMKSwitchAnimator.h.


Member Function Documentation

OMK::Vis::SwitchAnimator::DECLARE_ANIMATOR_FACTORY ( SwitchAnimator   )  [private]

void SwitchAnimator::selfProcessVis ( const OMK::Type::IntType 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.

Definition at line 120 of file OMKSwitchAnimator.cpp.

References _defaultNode, _oldNode, _vecNode, OMK::Vis::Animator::getId(), OMK::Type::SimpleTypeT< T >::getValue(), and OMERROR.

00121 {
00122   Ogre::SceneNode* newNode = _defaultNode ;
00123   if( 0 <= value.getValue() && value.getValue() < (int)_vecNode.size() ) 
00124   {
00125 
00126     newNode = _vecNode[ value.getValue() ];
00127   }
00128   else
00129   {
00130     OMERROR( "Warning for object \"" << getId() << "\", the value " 
00131            << value.getValue() << " is not in the range [ 0, " 
00132            << _vecNode.size() << " [ => use default scene" ) ;
00133   }
00134   if( newNode != _oldNode )
00135   {
00136     _oldNode->setVisible( false ) ;
00137     _oldNode = newNode ;
00138     _oldNode->setVisible( true );
00139   }
00140 }

void SwitchAnimator::init ( const ConfigurationParameterDescriptor node  )  [private, virtual]

init, load param

Definition at line 50 of file OMKSwitchAnimator.cpp.

References _defaultNode, _oldNode, _vecNode, OMK::ParametersAccessor::get(), OMK::Vis::Animator::getId(), OMK::Vis::OgreAnimatorCommon::getNode(), OMK::Vis::OgreAnimatorCommon::getNodeName(), OMK::Vis::OgreAnimatorCommon::getOgreObject(), OMASSERT, OMK_DEBUG_VIS, and OMTRACEID.

00051 {
00052   Ogre::SceneNode* animeNode = dynamic_cast< Ogre::SceneNode *>( &getNode() );
00053   OMASSERT( animeNode != NULL );
00054   _defaultNode = animeNode->createChildSceneNode( getNodeName() + "_Switch defaut" ) ;
00055 
00056   //Ajout un Node au niveau du NodeName et decalage du contenu dans defaut
00057   for( size_t i = 0 ; i < animeNode->numAttachedObjects() ; i++ )
00058   {
00059     Ogre::MovableObject * move = animeNode->getAttachedObject(i);
00060     animeNode->detachObject(move);
00061     _defaultNode->attachObject(move);
00062   }  
00063   for( Ogre::Node::ChildNodeIterator iter = animeNode->getChildIterator() ;
00064        iter.hasMoreElements() ; )
00065   {
00066     Ogre::SceneNode * nodeToMove = static_cast< Ogre::SceneNode* >( iter.getNext() ) ;
00067     if ( nodeToMove->getName() != _defaultNode->getName())
00068     {
00069       animeNode->removeChild( nodeToMove );
00070       _defaultNode->addChild( nodeToMove );
00071     }
00072   }
00073   // Add the default node
00074   _vecNode.push_back( _defaultNode ) ;
00075   _defaultNode->setVisible( true );
00076 
00077   std::vector < std::string > fileTab ;
00078   ParametersAccessor::get( &node, "FileTab", fileTab ) ;
00079 
00080   Ogre::Root& root( getOgreObject().getOgreVis().touchRoot() ) ;
00081   for( size_t i = 0 ; i< fileTab.size() ; i++ )
00082   {
00083     Ogre::SceneNode* nodeToAdd = animeNode->createChildSceneNode( fileTab[i] );
00084     OBT::Singleton< Ogre::dsi::dotSceneLoader >::getInstance().load( fileTab[i], 
00085                                                                      "General", 
00086                                                                      root.getSceneManager( "sceneManager" ), 
00087                                                                      root.getAutoCreatedWindow(), 
00088                                                                      nodeToAdd, 
00089                                                                      false, 
00090                                                                      false, 
00091                                                                      true ) ;
00092     std::string errs ;
00093     for( Ogre::dsi::dotSceneInfo::itLoadLog it( Ogre::dsi::dotSceneInfo::getSceneLoadingLog() ) ; 
00094          it.hasMoreElements() ; )
00095     {
00096       errs += it.getNext() + "\n" ;
00097     }
00098     if ( !errs.empty() )
00099     {
00100       OMTRACEID( OMK_DEBUG_VIS, "Warning for object \"" << getId() << "\"" << std::endl
00101                              << " errors occured during scene loading\n" << errs ) ;
00102     }
00103     _vecNode.push_back( nodeToAdd ) ;
00104     nodeToAdd->setVisible( false ) ;  
00105   }
00106 
00107   // select the default node
00108   _oldNode = _defaultNode ;
00109 }


Member Data Documentation

Ogre::SceneNode* OMK::Vis::SwitchAnimator::_defaultNode [protected]

Definition at line 65 of file OMKSwitchAnimator.h.

Referenced by init(), and selfProcessVis().

Ogre::SceneNode* OMK::Vis::SwitchAnimator::_oldNode [protected]

Definition at line 66 of file OMKSwitchAnimator.h.

Referenced by init(), and selfProcessVis().

std::vector< Ogre::SceneNode* > OMK::Vis::SwitchAnimator::_vecNode [protected]

Definition at line 67 of file OMKSwitchAnimator.h.

Referenced by init(), and selfProcessVis().


logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007