OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

VFS (PhysFS) support for .ive plugin


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Plugins [osgPlugins]
View previous topic :: View next topic  
Author Message
HiredK
Newbie


Joined: 03 Jun 2011
Posts: 13

PostPosted: Sat Jun 11, 2011 11:33 pm    Post subject:
VFS (PhysFS) support for .ive plugin
Reply with quote

Hi,

I'm looking for a way to load both the Virtual Planet Builder main .ive file and the tiles .ive from a VFS (Virtual file system). I already have a VPB terrain running and a functional VFS system that works by adding ".physfs" at the end of a filepath like this osgDB::readNode(engine/file.ive.physfs"). I'm able to load the main .ive file from the VFS but unfortunately when the plugin load the tiles I can't find a way to add the ".physfs" extension since the call is on the plugin side. What would be the best way to do so?

Cheers,
Micael
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11275

PostPosted: Wed Jun 15, 2011 8:13 am    Post subject:
VFS (PhysFS) support for .ive plugin
Reply with quote

Hi Miceal,

There shouldn't be any need to add the the physfs extension if you use
the "Chain of Responsibility" Design Pattern built into the OSG's
plugin mechnanism. Wht osgDB::Registry does is to pass file requests
to the loaded plugins to see if any of them can load it, if one of
them succeeds it simply passes back the loaded Object, if non of the
plugins can load the data then a plugin is loaded that matches the
osgdb_fileextension name. This approach leaves the responsibility
whether a plugin can load a specific type of data entirely down to the
plugin, the Registry doesn't preselect which one can handle what, and
with this responsibility comes get flexibility - you can preload
plugins that can intercept all loads and handle them appropriately.

The other approach you could take is write a custom osgDB::Archive,
and in svn/trunk and OSG-2.9.16 there is greater flexibility built
into it to handle novel backends.

Robert.

On Sun, Jun 12, 2011 at 12:33 AM, Micael Levesque
<> wrote:
Quote:
Hi,

I'm looking for a way to load both the Virtual Planet Builder main .ive file and the tiles .ive from a VFS (Virtual file system). I already have a VPB terrain running and a functional VFS system that works by adding ".physfs" at the end of a filepath like this osgDB::readNode(engine/file.ive.physfs"). I'm able to load the main .ive file from the VFS but unfortunately when the plugin load the tiles I can't find a way to add the ".physfs" extension since the call is on the plugin side. What would be the best way to do so?

Cheers,
Micael

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=40383#40383









------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
amigoface
User


Joined: 01 Apr 2010
Posts: 88
Location: Algeria

PostPosted: Wed Jun 15, 2011 8:50 am    Post subject:
Reply with quote

hi

i am interested in this too

@robert : does the latest 2.9.9 svn contains the new osgDB::Archive ?
and can you talk more about it please
it's architecture, how to use it, is it backward compatible with osg 2.8.x ?
Back to top
View user's profile Send private message Send e-mail
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11275

PostPosted: Wed Jun 15, 2011 9:00 am    Post subject:
VFS (PhysFS) support for .ive plugin
Reply with quote

On Wed, Jun 15, 2011 at 9:50 AM, issam boughanmi <> wrote:
Quote:
hi

i am interested in this too

@robert : does the latest 2.9.9 svn contains the new osgDB::Archive ?
and can you talk more about it please

No I am busy working on a release - you need to go do your own
research. Please go have a look at the forum/mailing lists archives
on the past two months. Also just upgrade your OSG version.

Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
zonk
Appreciator


Joined: 23 May 2009
Posts: 621

PostPosted: Wed Jun 15, 2011 9:14 am    Post subject:
Reply with quote

Hi Robert,

I'm facing the same question in another context.

currently I modify the loaded file to ensure that all subfiles are also loaded via my plugin.

I read about the plugin preload, but what is that?
I only found this wiki site about plugin mechanism:
http://www.openscenegraph.org/projects/osg/wiki/Support/UserGuides/Plugins

Ho does this preloading work? Does my plugin have to registered for ALL extensions to be selected for subsequent loadings?


If interested in: This thread describes my issue in detail:
http://forum.openscenegraph.org/viewtopic.php?t=8544

Thank you!

Cheers,
Torben
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11275

PostPosted: Wed Jun 15, 2011 9:46 am    Post subject:
VFS (PhysFS) support for .ive plugin
Reply with quote

Hi Torben,

On Wed, Jun 15, 2011 at 10:14 AM, Torben Dannhauer
<> wrote:
Quote:
Ho does this preloading work?

I've explain already in this thread, and plenty of times before so go
have a look at what I've said now and before.

Quote:
Does my plugin have to configured for ALL extensions to be selected for subsequent loadings?

The answer has already been provide in this thread... just need to
think about what I've written.

Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
zonk
Appreciator


Joined: 23 May 2009
Posts: 621

PostPosted: Wed Jun 15, 2011 11:43 am    Post subject:
Reply with quote

Hi Robert,

Let's agree we disagree.


thanks for focusing on OSG 3.0 Smile


Cheers,
Torben
Back to top
View user's profile Send private message
HiredK
Newbie


Joined: 03 Jun 2011
Posts: 13

PostPosted: Wed Jun 15, 2011 8:13 pm    Post subject:
Fix
Reply with quote

Alright here's my fix:

Plugin Header:

Code:
#ifndef READERTERRAINLOD_H_
    #define READERTERRAINLOD_H_

#include "Common.h"
#include "StreamBuf.h"

#include "osgDB/Registry"
#include "osgDB/FileNameUtils"
#include "osgDB/FileUtils"
#include "osgDB/ImageOptions"

class ReaderTerrainLOD : public osgDB::ReaderWriter {
   public:
      ReaderTerrainLOD();

      virtual ~ReaderTerrainLOD() {}
      virtual const char* className() const;
      virtual bool acceptsExtension(const std::string& extension) const;
      virtual osgDB::ReaderWriter::ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options ) const;
};

#endif


Plugin Source:

Code:
#include "ReaderTerrainLOD.h"

ReaderTerrainLOD::ReaderTerrainLOD()
{
   supportsExtension("pagedlod", "VFS PagedLOD terrain loader");
}

const char* ReaderTerrainLOD::className() const
{
    return "TerrainLOD Reader";
}

bool ReaderTerrainLOD::acceptsExtension(const std::string& extension) const
{
   if(osgDB::equalCaseInsensitive(extension, "pagedlod")) return true;
    return false;
}

osgDB::ReaderWriter::ReadResult ReaderTerrainLOD::readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
   std::string actualfilename(file);
   if(osgDB::getFileExtension(file) == "pagedlod")  actualfilename = osgDB::getNameLessExtension(file);
    osgDB::ReaderWriter* p_reader = osgDB::Registry::instance()->getReaderWriterForExtension("physfs");
    if(!p_reader) return osgDB::ReaderWriter::ReadResult::ERROR_IN_READING_FILE;
   return p_reader->readNode(actualfilename + std::string(".physfs"));
}

// Register Plugin
REGISTER_OSGPLUGIN(pagedlod, ReaderTerrainLOD)


You can setup the ".physfs" plugin using this link http://www.openscenegraph.org/projects/osg/wiki/Support/Tutorials/VFS[/url][/b]
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11275

PostPosted: Thu Jun 16, 2011 7:54 am    Post subject:
VFS (PhysFS) support for .ive plugin
Reply with quote

Hi Micael,

I would have thought you could just preload the physfs plugin so that
it catches all file load calls and loads them if approrpiate, I don't
it should be neccessary to put another plugin in just to add the
filename extension. If the physfs plugin is already getting the
fileload calls then it shouldn't need to have any file extension
added. To pre load your plugin simply explictly load the plugin prior
to running your rendering loop with:

osgDB::Registry::instance()->loadLibrary(osgDB::Registry::instance()->createLibraryNameForExtension("physfs"));

Robert.

On Wed, Jun 15, 2011 at 9:13 PM, Micael Levesque
<> wrote:
Quote:
Alright here's my fix:

Plugin Header:


Code:
#ifndef READERTERRAINLOD_H_
   #define READERTERRAINLOD_H_

#include "Common.h"
#include "StreamBuf.h"

#include "osgDB/Registry"
#include "osgDB/FileNameUtils"
#include "osgDB/FileUtils"
#include "osgDB/ImageOptions"

class ReaderTerrainLOD : public osgDB::ReaderWriter {
       public:
               ReaderTerrainLOD();

               virtual ~ReaderTerrainLOD() {}
               virtual const char* className() const;
               virtual bool acceptsExtension(const std::string& extension) const;
               virtual osgDB::ReaderWriter::ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options ) const;
};

#endif



Plugin Source:


Code:
#include "ReaderTerrainLOD.h"

ReaderTerrainLOD::ReaderTerrainLOD()
{
       supportsExtension("pagedlod", "VFS PagedLOD terrain loader");
}

const char* ReaderTerrainLOD::className() const
{
   return "TerrainLOD Reader";
}

bool ReaderTerrainLOD::acceptsExtension(const std::string& extension) const
{
       if(osgDB::equalCaseInsensitive(extension, "pagedlod")) return true;
   return false;
}

osgDB::ReaderWriter::ReadResult ReaderTerrainLOD::readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
       std::string actualfilename(file);
       if(osgDB::getFileExtension(file) == "pagedlod")  actualfilename = osgDB::getNameLessExtension(file);
   osgDB::ReaderWriter* p_reader = osgDB::Registry::instance()->getReaderWriterForExtension("physfs");
   if(!p_reader) return osgDB::ReaderWriter::ReadResult::ERROR_IN_READING_FILE;
       return p_reader->readNode(actualfilename + std::string(".physfs"));
}

// Register Plugin
REGISTER_OSGPLUGIN(pagedlod, ReaderTerrainLOD)



You can setup the ".physfs" plugin using this link http://www.openscenegraph.org/projects/osg/wiki/Support/Tutorials/VFS[/url][/b]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=40548#40548









------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
zonk
Appreciator


Joined: 23 May 2009
Posts: 621

PostPosted: Thu Jun 16, 2011 8:43 am    Post subject:
Reply with quote

Thanks Robert,

I will try that!

Cheers,
Torben
Back to top
View user's profile Send private message
Steal
User


Joined: 26 Jan 2017
Posts: 60

PostPosted: Sun Jul 09, 2017 8:10 pm    Post subject:
Reply with quote

Hi,

This threads explains the theory so well, but the Registry and osgDB is intimidating to meddle with.

Edit: here's my VFS / PHYSFS solution
http://forum.openscenegraph.org/viewtopic.php?t=16726

Thank you!

Cheers,
Johny
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Plugins [osgPlugins] All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Build OSG on iOS with support OpenGLE... xerxses Build system [build] 1 Tue Dec 12, 2017 1:09 pm View latest post
No new posts Building Nvidia Texture Tools plugin ... hbucher Build system [build] 2 Thu Dec 07, 2017 11:21 pm View latest post
No new posts logo plugin culling Mathieu Submission 1 Wed Nov 29, 2017 10:15 am View latest post
No new posts obj plugin does not support diffuse ... Ralf Habacker Submission 0 Tue Nov 14, 2017 4:18 pm View latest post
No new posts Fix for cmake modules for plugin exr robertosfield Submission 1 Tue Nov 14, 2017 10:17 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP