#include #include #include #include #include #include #include #include #include #include #include #include // Customize the CopyOp so that we add our own verbose // output of what's being copied. class MyCopyOp : public osg::CopyOp { public: inline MyCopyOp(CopyFlags flags=SHALLOW_COPY): osg::CopyOp(flags), _indent(0), _step(4) {} inline void moveIn() const { _indent += _step; } inline void moveOut() const { _indent -= _step; } inline void writeIndent() const { for(int i=0;i<_indent;++i) std::cout << " "; } virtual osg::Referenced* operator() (const osg::Referenced* ref) const { writeIndent(); std::cout << "copying Referenced "<className(); std::cout<className()<<" '"<getName()<<"'"; std::cout<className(); std::cout<className(); std::cout<className(); std::cout<className(); std::cout<className(); std::cout<(rootnode->clone(osg::CopyOp::DEEP_COPY_ALL)); std::cout << "Doing a deep copy of scene graph"<(rootnode->clone(MyCopyOp(osg::CopyOp::DEEP_COPY_ALL))); std::cout << "----------------------------------------------------------------"<(rootnode->clone(MyCopyOp(osg::CopyOp::SHALLOW_COPY))); // write out the various scene graphs so that they can be browsed, either // in an editor or using a graphics diff tool gdiff/xdiff/xxdiff. std::cout << std::endl << "Writing out the original scene graph as 'original.osg'"<(rootnode->clone(osg::CopyOp::DEEP_COPY_NODES | DEEP_COPY_DRAWABLES)); // Which shares state but creates copies of all nodes and drawables (which contain the geometry). // // You may also want to subclass from CopyOp to provide finer grained control of what gets shared (shallow copy) vs // cloned (deep copy). // ------------- End of copy specific code ------------------------------------------------------- // set the scene to render viewer.setSceneData(rootnode); return viewer.run(); }