Hi Stuart,

Could you try to replace ReadExternalsVisitor in ReaderWriterFLT.cpp
with the code below and give it a try.  The magic word (reader option)
is "cloneExternalReferences".


class ReadExternalsVisitor : public osg::NodeVisitor
{
   bool _cloneExternalReferences;
   osg::ref_ptr<ReaderWriter::Options> _options;

public:

   ReadExternalsVisitor(ReaderWriter::Options* options) :
       osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
       _options(options),
       _cloneExternalReferences(false)
   {
       if (options)
           _cloneExternalReferences =
(options->getOptionString().find("cloneExternalReferences")!=std::string::npos);
   }

   virtual ~ReadExternalsVisitor() {}

   virtual void apply(ProxyNode& node)
   {
       // Transfer ownership of pools.
       _options->setUserData( node.getUserData() );
       node.setUserData(NULL);

       for (unsigned int pos=0; pos<node.getNumFileNames(); pos++)
       {
           std::string filename = node.getFileName(pos);

           // read external
           osg::Node* external = osgDB::readNodeFile(filename,_options.get());
           if (external)
           {
               if (_cloneExternalReferences)
                   external =
dynamic_cast<osg::Node*>(external->clone(osg::CopyOp(osg::CopyOp::DEEP_COPY_NODES)));

               node.addChild(external);
           }
       }
   }
};


Brede

On 11/29/06, Paul Martz <[EMAIL PROTECTED]> wrote:
> > > Does OSG have a similar function?
> >
> >   node->clone(osg::CopyOp(...))
>
> Great! Then I suggest that that is how users will expect flt
> external references to be implemented. Shared instancing
> using multiple parents was used for internal instances and
> replications, but not external instances.

If you implement this in the OpenFlight loader, could you do so as an
option? The current behavior of multiply parenting a single instance would
be preferable in situations where the ext ref is not to be dynamically
manipulated.
   -Paul

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to