[osg-users] Loading from directory, not file

Aaron Andersen aaron at fosslib.net
Wed Jul 15 04:35:57 PDT 2015


Hi Robert,

Thank you for your answer. That certainly cleared up how to make my loader work with a native file system directory. My code now works as expected!

I do have some questions about osg and virtual file systems, though. I noticed in the osg source code some files relating to zip and archive support which sounds great. Given the ReaderWriter interface has a read method which accepts an fstream it seems pretty straight forward that any ReaderWriter implementation implementing fstream methods will just work even if the file is in a zip file. That's fantastic, but it does leave me wondering what is the standard way for me to implement my ReaderWriter which requires the ability to look at a directory and read multiple files from that directory such that my ReaderWriter will "just work" even if the directory is virtual, like in a zip file?

Again, thank you kindly for any help you or anyone else may be able to provide.

Aaron

On July 15, 2015 3:26:26 AM EDT, Robert Osfield <robert.osfield at gmail.com> wrote:
>Hi Aaron,
>
>The ReaderWriter mechanism is built around the Chain-Of-Responsibility
>pattern so it's actually up to the ReaderWriter implementation to
>decide
>what files it can handle, you don't even need an file extension, or for
>the
>filename to even be an actual file or path name - this allows one to
>implement various psuedo loaders that various different things such as
>pre-processing of loaded models or paging.
>
>The only place that the extensions are stricktly checked is when
>initially
>loading the plugins - if no plugin that has already been loaded can
>handle
>a particle read*File() request then osgDB::Registry checks the
>extension
>and loads the plugin associated with that plugin.  In the case of
>psuedo
>plugin the filename won't be mapping directly to a file system file so
>the
>one either pre-loads these plugins, or append a .myplugin to filename
>and
>then strip the ".myplugin" inside the the ReaderWriter.  The .rot,
>.trans,
>.scale, .curl, .gdal plugins are all examples of plugins that use this
>approach.
>
>In your case I'd recommend supporting both these approproaches -
>support
>the dummy extension that maps to your plugin name as well as support
>usage
>without the extension.
>
>Robert.
>
>
>
>On 15 July 2015 at 00:01, Aaron Andersen <aaron at fosslib.net> wrote:
>
>> I will preface this by saying I'm quite new to open scene graph, so
>if I'm
>> missing something obvious please forgive me.
>>
>> I have a node/scene format I would like to implement in open scene
>graph.
>> The data for the format is encapsulated in multiple files within a
>> directory, not within a single file.
>>
>> How can I make a reader writer for a directory as opposed to a file?
>The
>> ReaderWriter api is geared toward files (supportedExtension) and this
>is
>> leaving me a little confused.
>>
>> Any help or guidance would be greatly appreciated.
>>
>> Thank you,
>> Aaron
>> _______________________________________________
>> osg-users mailing list
>> osg-users at lists.openscenegraph.org
>>
>http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>osg-users mailing list
>osg-users at lists.openscenegraph.org
>http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150715/bc7968e7/attachment-0003.htm>


More information about the osg-users mailing list