OMK::Vis::NodeMaterialOrig Class Reference

#include <OMKMaterial.h>

Inheritance diagram for OMK::Vis::NodeMaterialOrig:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 NodeMaterialOrig (Ogre::SceneNode *node)
virtual ~NodeMaterialOrig ()
void undoFor (IUpdateMaterial *update, bool deleteNode)
void createCopyAndUpdateWith (IUpdateMaterial *update)
NodeMaterialOrigfind (Ogre::SceneNode *node)
virtual void doAction (const IMaterialAction &action)

Protected Member Functions

void updateCopyWith (IUpdateMaterial *update)

Protected Attributes

NodeMaterialOrigVector _childs
Ogre::SceneNode * _sceneNode

Detailed Description

Definition at line 160 of file OMKMaterial.h.


Constructor & Destructor Documentation

NodeMaterialOrig::NodeMaterialOrig ( Ogre::SceneNode *  node  ) 

Definition at line 166 of file OMKMaterial.cpp.

References _childs, OMK::Vis::NodeMaterial::_entities, and OMTRACEID.

00167 : NodeMaterial(),
00168   _sceneNode( sceneNode ) 
00169 {
00170   for( Ogre::SceneNode::ObjectIterator it = sceneNode->getAttachedObjectIterator() ;
00171        it.hasMoreElements() ;
00172        it.moveNext() )
00173   {
00174     Ogre::MovableObject * currentMO = it.peekNextValue() ;
00175     if ( currentMO->getMovableType() == Ogre::EntityFactory::FACTORY_TYPE_NAME ) 
00176     {
00177       OMTRACEID( "DEBUG", "Create entity " << currentMO->getName() ) ;
00178       _entities[ it.peekNextKey() ] = new EntityMaterialOrig( static_cast< Ogre::Entity *> ( currentMO ) ) ;
00179     }
00180   }
00181   for( Ogre::Node::ChildNodeIterator it = sceneNode->getChildIterator() ;
00182        it.hasMoreElements() ;
00183        it.moveNext() )
00184   {
00185     Ogre::SceneNode* childSceneNode = static_cast< Ogre::SceneNode* >( it.peekNextValue() ) ;
00186     OMTRACEID( "DEBUG", "Create ChildSceneNode " << childSceneNode->getName() ) ;
00187     NodeMaterialOrig* child = new NodeMaterialOrig( childSceneNode ) ;
00188     _childs.push_back( child ) ;
00189   }
00190 }

NodeMaterialOrig::~NodeMaterialOrig (  )  [virtual]

Definition at line 192 of file OMKMaterial.cpp.

References _childs, and OMK::Vis::NodeMaterial::_stack.

00193 {
00194   for( NodeMaterialOrigVector::iterator it = _childs.begin() ;
00195        it != _childs.end() ;
00196        it++ ) 
00197   {
00198     delete *it ;
00199   }
00200   for( ItemStack::iterator it = _stack.begin() ; 
00201        it != _stack.end() ;
00202        it++ )
00203   {
00204     delete it->nodeMaterial ;
00205   }
00206 }


Member Function Documentation

void NodeMaterialOrig::undoFor ( IUpdateMaterial update,
bool  deleteNode 
)

Definition at line 275 of file OMKMaterial.cpp.

References _childs, OMK::Vis::NodeMaterial::_stack, OMK::Vis::IUpdateMaterial::update(), and updateCopyWith().

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

00276 {
00277   // Undo the current node level
00278   UpdateMaterialStack updateStack ;
00279   for( ; _stack.back().update != update ; _stack.pop_back() )
00280   {
00281     updateStack.push( _stack.back().update ) ;
00282     _stack.back().update->undo( _stack.back().nodeMaterial ) ;
00283     delete _stack.back().nodeMaterial ;
00284   }
00285   // delete the node which is undoing
00286   if( deleteNode )
00287   {
00288     delete _stack.back().nodeMaterial ;
00289     _stack.pop_back() ;
00290   }
00291   // activate the new current material
00292   ( _stack.empty() ? (NodeMaterial*)this : (NodeMaterial*)( _stack.back().nodeMaterial ) )->activateMaterial() ;
00293   // Do the same for children
00294   for( NodeMaterialOrigVector::iterator it = _childs.begin() ;
00295        it != _childs.end() ;
00296        it++ ) 
00297   {
00298     (*it)->undoFor( update, deleteNode ) ;
00299   }
00300   // Redo the action
00301   if( !deleteNode )
00302   {
00303     update->update( _stack.back().nodeMaterial ) ;
00304   }
00305   for( ; !updateStack.empty(); updateStack.pop() )
00306   {
00307     updateCopyWith( updateStack.top() ) ;
00308   }
00309 }

void NodeMaterialOrig::createCopyAndUpdateWith ( IUpdateMaterial update  ) 

Definition at line 263 of file OMKMaterial.cpp.

References _childs, OMTRACEID, and updateCopyWith().

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

00264 {
00265   updateCopyWith( update ) ;
00266   for( NodeMaterialOrigVector::iterator it = _childs.begin() ;
00267        it != _childs.end() ;
00268        it++ ) 
00269   {
00270     OMTRACEID("DEBUG", "Child --------------- " );
00271       (*it)->createCopyAndUpdateWith( update ) ;
00272   }
00273 }

NodeMaterialOrig * NodeMaterialOrig::find ( Ogre::SceneNode *  node  ) 

Definition at line 227 of file OMKMaterial.cpp.

References _childs, _sceneNode, and find().

Referenced by find(), OMK::Vis::TransparencyValueAnimator::selfProcessVis(), and OMK::Vis::TransparencyAnimAnimator::selfProcessVis().

00228 {
00229   NodeMaterialOrig* result = node != _sceneNode ? 0 : this ;
00230   for( NodeMaterialOrigVector::iterator it = _childs.begin() ;
00231        it != _childs.end() && !result ;
00232        it++ ) 
00233   {
00234     result = (*it)->find( node ) ;
00235   }
00236   return result ;
00237 }

void NodeMaterialOrig::doAction ( const IMaterialAction action  )  [virtual]

Reimplemented from OMK::Vis::NodeMaterial.

Definition at line 208 of file OMKMaterial.cpp.

References _childs, OMK::Vis::NodeMaterial::getEntityMaterialIterator(), and OMK::Vis::IMaterialAction::nodeAction().

00209 {
00210   if( action.nodeAction( this ) )
00211   {
00212     for( EntityMaterialIterator it = getEntityMaterialIterator() ;
00213          it.hasMoreElements() ;
00214          it.moveNext() ) 
00215     {
00216       it.peekNextValue()->doAction( action ) ;
00217     }
00218   }
00219   for( NodeMaterialOrigVector::iterator it = _childs.begin() ;
00220        it != _childs.end() ;
00221        it++ ) 
00222   {
00223     (*it)->doAction( action ) ;
00224   }
00225 }

void NodeMaterialOrig::updateCopyWith ( IUpdateMaterial update  )  [protected]

Definition at line 239 of file OMKMaterial.cpp.

References OMK::Vis::NodeMaterial::_stack, OMK::Vis::NodeMaterial::getEntityMaterialIterator(), OMK::Vis::IUpdateMaterial::getMaterialName(), OMK::Vis::NodeMaterial::NodeMaterialCopy, OMTRACEID, and OMK::Vis::IUpdateMaterial::update().

Referenced by createCopyAndUpdateWith(), and undoFor().

00240 {
00241   NodeMaterialCopy* newNode = new NodeMaterialCopy( _stack.empty() ? (NodeMaterial*)this : (NodeMaterial*)_stack.back().nodeMaterial, update ) ;
00242   _stack.push_back( Item( newNode, update ) ) ;
00243   OMTRACEID("DEBUG", "" << update->getMaterialName(".") 
00244         << " Stack size " << _stack.size() );
00245     for( EntityMaterialIterator it = getEntityMaterialIterator() ;
00246        it.hasMoreElements() ;
00247        it.moveNext() )
00248   {
00249    OMTRACEID("DEBUG", "Entities "  <<   it.peekNextKey()  );
00250      for( SubEntityMaterialIterator it2 = it.peekNextValue()->getSubEntityMaterialIterator() ;
00251        it2.hasMoreElements() ;
00252        it2.moveNext() )
00253   {
00254     if ( !  it2.peekNext()->getMaterial().isNull())
00255       OMTRACEID("DEBUG", "SubEntitity Mat "<<   it2.peekNext()->getMaterial()->getName()) ;
00256   }
00257 
00258   }
00259 
00260   update->update( newNode ) ;
00261 }


Member Data Documentation

NodeMaterialOrigVector OMK::Vis::NodeMaterialOrig::_childs [protected]

Definition at line 171 of file OMKMaterial.h.

Referenced by createCopyAndUpdateWith(), doAction(), find(), NodeMaterialOrig(), undoFor(), and ~NodeMaterialOrig().

Ogre::SceneNode* OMK::Vis::NodeMaterialOrig::_sceneNode [protected]

Definition at line 172 of file OMKMaterial.h.

Referenced by find().


logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007