Excellent ZipFS plugin Jason.  Thank you for the help.  I think that
was the hardest part of the problem.  I finally got around to working
on this more and I have the other half of the problem mostly solved.

It looks like OSG uses zlib for all its compression/decompression.
Just out of curiosity, how did you pick libzip instead?  Or did you
not write ZipFS?

To recap, I'm trying to set an OSG_FILE_PATH such as
mydirectory/data.zip and load files out of the specified archive.  At
first I discovered the Registry class's FindFileCallback.  I thought I
could just make one of those and have it search inside of zip files.
However, the work that I really needed to replace happened when the
default Registry::findDataFileImplementation would call
osgDB::findFileInPath in FileUtils.  So I decided to override
findFileInPath so that would look for paths containing ".zip" and try
to locate the desired file inside the zip file.

That almost worked.  I also had to modify ReaderWriterZipFS::readFile
so that it uses OSG's directory searching.  At the beginning of the
function I added

std::string filenameWithPath =
osgDB::Registry::instance()->findDataFile(fullFileName, options,
CASE_SENSITIVE);

and then I use filenameWithPath instead of fullFileName where appropriate.

So now I can load almost all my game resources from one .zip file
instead of a directory full of files.  I haven't tested performance
yet, but there's no noticeable change.  .osg files load with all their
textures.

Here's the catch: .osg files don't get loaded with their shaders.  I
believe this is because shaders don't use the standard OSG plugin
loading paradigm.  Instead they simply use
Shader::loadShaderSourceFromFile().  I haven't put any thought into
this last detail yet (I hope it's not too messy), but I need a
programming break....
--
Terry Welsh
mogumbo 'at' gmail.com
www.reallyslick.com

>
> Message: 9
> Date: Fri, 5 Aug 2011 08:50:10 -0400
> From: Jason Beverage <[email protected]>
> To: OpenSceneGraph Users <[email protected]>
> Subject: Re: [osg-users] tight integration of virtual file system
> Message-ID:
>        <camcxsmsly2m20aoa5z7tubjob1xyrqqkmnz9z9lslzmmkqu...@mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hi Terry,
>
> osgEarth has a generic zip based plugin called ZipFS that is
> implemented as an osgDB plugin and isn't dependent on osgEarth.  We
> originally developed it to support using a zip file of imagery tiles
> for a cache.
>
> It allows you to load files like:
> osgDB::readNodeFile("c:/data/models.zip/cow.osg");
>
> I haven't used it for quite awhile but last I checked it was working
> just fine.  You can get the osgearth source code from github at
> https://github.com/gwaldron/osgearth
>
> If anything it could be a start to what you're looking for.
>
> Thanks,
>
> Jason
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to