00001 /************************************************************************/ 00002 /* This file is part of openMask(c) INRIA, CNRS, Universite de Rennes 1 */ 00003 /* 1993-2002, thereinafter the Software */ 00004 /* */ 00005 /* The Software has been developped within the Siames Project. */ 00006 /* INRIA, the University of Rennes 1 and CNRS jointly hold intellectual */ 00007 /* property rights */ 00008 /* */ 00009 /* The Software has been registered with the Agence pour la Protection */ 00010 /* des Programmes (APP) under registration number */ 00011 /* IDDN.FR.001.510008.00.S.P.2001.000.41200 */ 00012 /* */ 00013 /* This file may be distributed under the terms of the Q Public License */ 00014 /* version 1.0 as defined by Trolltech AS of Norway and appearing in */ 00015 /* the file LICENSE.QPL included in the packaging of this file. */ 00016 /* */ 00017 /* Licensees holding valid specific licenses issued by INRIA, CNRS or */ 00018 /* Universite Rennes 1 for the software may use this file in */ 00019 /* acordance with that specific license */ 00020 /************************************************************************/ 00021 #include "OMKOgreAnimatorT.h" 00022 00023 void OMK::Vis::OgreAnimatorCommon::findOgreNode( OMK::Vis::Animator* animator, void*& tNode ) 00024 { 00025 if ( !_nodeName.empty() ) 00026 { 00027 _node = OMK::Vis::getOgreNode( getOgreObject().getSceneNode(), _nodeName ) ; 00028 OMASSERTM( _node, 00029 "Error for " << debugMsg( animator ) << std::endl 00030 << ">>> :-( the node " << _nodeName << " was not found" ) ; 00031 tNode = _node ; 00032 } 00033 } 00034 00035 00036 00037 //------------------------------------------------------------------------- 00038 // getOgreNode 00039 //------------------------------------------------------------------------- 00040 Ogre::Node* 00041 OMK::Vis::getOgreNode( const Ogre::Node& rootNode, const std::string& nodeName ) 00042 { 00043 if (getNameWithoutDelimiterOMK(rootNode.getName()) == nodeName) 00044 return const_cast<Ogre::Node*>(&rootNode); 00045 00046 Ogre::Node* node( 0 ) ; 00047 // look for the node in rootNode children, Ogre throws an exception if 00048 // nodeName is not the name of a child of rootNode. The exception is 00049 // catched and node set to NULL 00050 /* try 00051 { 00052 node = rootNode.getChild( getNameWithoutDelimiterOMK(nodeName) ) ; 00053 } 00054 catch( Ogre::Exception& ) 00055 { 00056 node = NULL ; 00057 } 00058 */ 00059 node = getChildWithDelimiterOMK( rootNode, nodeName ) ; 00060 00061 // if nodeName was not one of rootNode children we look deeper in the subtree, 00062 // the children of rootNode becoming the new rootNodes 00063 if( node == 0 ) 00064 { 00065 Ogre::Node::ConstChildNodeIterator ite( rootNode.getChildIterator() ) ; 00066 for( unsigned short i( 0 ) ; ( node == 0 ) && ( i < rootNode.numChildren() ) ; ++i ) 00067 { 00068 node = getOgreNode( *ite.getNext(), getNameWithoutDelimiterOMK( nodeName ) ) ; 00069 } 00070 00071 } 00072 return node ; 00073 } 00074 00075 Ogre::Node* 00076 OMK::Vis::getChildWithDelimiterOMK( const Ogre::Node& node, const std::string& name ) 00077 { 00078 Ogre::Node::ConstChildNodeIterator iter( node.getChildIterator() ) ; 00079 while( iter.hasMoreElements() ) 00080 { 00081 Ogre::Node* pChild( static_cast< Ogre::Node* >( iter.getNext() ) ) ; 00082 if( getNameWithoutDelimiterOMK( pChild->getName().c_str() ) == name ) 00083 { 00084 return pChild; 00085 } 00086 } 00087 return 0; 00088 } 00089 00090 std::string 00091 OMK::Vis::getNameWithoutDelimiterOMK( const std::string& fileName ) 00092 { 00093 static const std::string s_delimiter( "_#_" ) ; 00094 size_t delimiterPlace( fileName.rfind( s_delimiter ) ) ; 00095 std::string s( fileName ) ; 00096 if( delimiterPlace != std::string::npos ) 00097 { 00098 s.erase( delimiterPlace, fileName.size() ) ; 00099 } 00100 return s ; 00101 }
Documentation generated on Mon Jun 9 11:45:57 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |