Hi All,

 

I have an issue with loading .osg files.  I would like to be able to
specify the directories from which the internally referenced files of a
.osg file are loaded.   This can largely be achieved by using
osgDB::setDataFilePathList or setting the database path on an instance
of ReaderWriter::Options when calling osgDB::readNodeFile.  However I
have a problem.  Internally referenced files in the same directory as
the .osg file (current directory) will always be preferred to those in
other directories specified on the data path list even if the current
directory is on the data path list.  This is causing me problems when
trying to do resource localisation in the following way:

 

The directory Test (see below) contains a default version of bar.png,
directories fr-FR and en-GB containing localised versions of bar.png and
foo.osg that references bar.png.

 

Test

                foo.osg

                bar.png

                fr-FR

                                bar.png

                en-GB

                                bar.png

 

What I would like to happen is that bar.png in fr-FR is loaded instead
of the default when the data path is setup as (Test/fr-FR/,Test/).  If
bar.png doesn't exist in the localised directory then the default is
loaded.  What is stopping this happening is the following line in
.../src/osgPlugins/ReadWriterOSG.cpp

                

local_opt->getDatabasePathList().push_front(osgDB::getFilePath(fileName)
);

 

This always adds the directory of the .osg file to the front of the data
path list so internally referenced files will always be loaded from that
directory irrespective of how the data path has initially been
constructed.

 

There are a number of ways ReadWriterOSG.cpp could be changed to resolve
this issue:

1.       Only add the  directory of the .osg file if it isn't already on
the data path.

2.       Add a flag to ReaderWriter::Options to indicate that the
directory should not be added to the path.

3.       Some combination of 1 and 2.

This logic could be put into ReaderWriter::Options to make it available
to other plugins.

 

Any ideas?

 

Thanks,

 

Morgan.

 

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to