OpenSceneGraph/include/osgUtil/AppVisitor
Don BURNS 81f553aaee o Updated Metrowerks files for MacOS. They aren't 100% there yet,
but getting there.

  o First cut of osgcluster demo.  Very simple beginings.  Alas
    I only one PC here so I can't test it in its current guise.

  o New support for NodeCallbacks, via AppCallback attached to
    osg::Node's, and a default osgUtil::AppVisitor which calls them on
    each frame.

  o Support for traversal masks in osg::NodeVisitor, osg::Node
    which allows nodes to be switched on or off via a bit mask.

  o Suppport for traversal number (frame number) and reference time
    into osg::NodeVisitor to handle syncronization of app and cull
    traversals.  This also assist clustering as traversal number
    master to slaves.
2001-09-19 23:41:39 +00:00

68 lines
1.9 KiB
Plaintext

#ifndef OSGUTIL_APPVISITOR
#define OSGUTIL_APPVISITOR 1
#include <osg/NodeVisitor>
#include <osg/Node>
#include <osg/Geode>
#include <osg/Billboard>
#include <osg/LOD>
#include <osg/Switch>
#include <osg/LightSource>
#include <osg/Transform>
#include <osg/Impostor>
#include <osgUtil/Export>
namespace osgUtil {
/**
* Basic AppVisitor implementation for animating a scene.
* This visitor traverses the scene graph, call each nodes appCallback if
* it exists.
*/
class OSGUTIL_EXPORT AppVisitor : public osg::NodeVisitor
{
public:
AppVisitor();
virtual ~AppVisitor();
virtual void reset();
virtual void apply(osg::Node& node) { handle_callbacks(node); }
virtual void apply(osg::Geode& node) { handle_callbacks(node); }
virtual void apply(osg::Billboard& node) { handle_callbacks(node); }
virtual void apply(osg::LightSource& node){ handle_callbacks(node); }
virtual void apply(osg::Group& node) { handle_callbacks(node); }
virtual void apply(osg::Transform& node) { handle_callbacks(node); }
virtual void apply(osg::Switch& node) { handle_callbacks(node); }
virtual void apply(osg::LOD& node) { handle_callbacks(node); }
virtual void apply(osg::Impostor& node) { handle_callbacks(node); }
protected:
/** prevent unwanted copy construction.*/
AppVisitor(const AppVisitor&):osg::NodeVisitor() {}
/** prevent unwanted copy operator.*/
AppVisitor& operator = (const AppVisitor&) { return *this; }
inline void handle_callbacks(osg::Node& node)
{
osg::NodeCallback* callback = node.getAppCallback();
if (callback) (*callback)(&node,this);
else if (node.getNumChildrenRequiringAppTraversal()>0) traverse(node);
}
};
};
#endif