Page 1 of 1

Loading resources w/o a ResourceGroupLocation

Posted: Fri Dec 26, 2008 12:30 am
by Moohasha
I already started a thread in the Help section about this (http://www.ogre3d.org/forums/viewtopic. ... 28&start=0), but since it doesn't seem possible I'd like to make it a feature request. You really should be able to load media as long as you have the absolute or relative path without having to add a ResourceGroupLocation for it. ResourceGroupLocations should be the default because they make sense, but it shouldn't be the only option without having to work around it or install seperate plugins.

Re: Loading resources w/o a ResourceGroupLocation

Posted: Fri Dec 26, 2008 1:50 am
by xavier
Dude, if you'd quit being so dense about this you would see that in that thread, I have given you the code that works exactly as you describe.

I honestly don't know how to make it any plainer than I have, beyond writing your code for you.

Re: Loading resources w/o a ResourceGroupLocation

Posted: Fri Dec 26, 2008 2:07 am
by jacmoe
ManualResourceLoader is the magic word here. :wink:

Re: Loading resources w/o a ResourceGroupLocation

Posted: Fri Dec 26, 2008 3:05 pm
by Moohasha
Yes, once I ate a slice of humble pie I realized xavier was giving me a solution rather than suggesting a plugin. Even though I already did it in the other thread, I'll appologise here as well. My bad. :oops:
While I did find a solution (thanks xavier), I do still think that loading resources without a resource group location should be just as transparent as loading them with one, while a ManualResourceLoader should simply provide more flexibility over the process.

Adding a ResourceGroupLocation:

Code: Select all

Ogre::ResourceGroupManager::getSingleton().addResourceLocation(location, "FileSystem");
...
Ogre::TextureManager::getSingleton().load(name, group);  // Finds it in some resource group
(Desired) adding a resource w/o ResourceGroupLocation:

Code: Select all

Ogre::TextureManager::getSingleton().load(location + "/" + name, "none");  // Loads it from location provided

Re: Loading resources w/o a ResourceGroupLocation

Posted: Fri Dec 26, 2008 8:27 pm
by Praetor
There's no way to know that the name provided is an absolute location to load the resource from instead of just a name to use as a reference. The use of ManualResourceLoader, or the listener interface you can register with ResourceGroupManager is an example of the concept of explicit over implicit. Having Ogre automatically try to load resources without locations or resource loaders is implicit, which leads to confusion. By explicitly handling a resource's loading you avoid any ambiguity over where a resource's data comes from. You can build a nice system around automatically creating ManualResourceLoaders for resources as you need them if you'd like. My applications don't use a single resource location, which gives me huge control over how resources are loaded.

Re: Loading resources w/o a ResourceGroupLocation

Posted: Fri Dec 26, 2008 8:58 pm
by Moohasha
I guess what I'm asking for has already been looked at in the past and the result was the ManualResourceLoader. I still personally think that's a little too complex a solution for every situation (such as the one I first described), but I suppose I can suck it up if everyone else accepts it. I just like easy solutions. :P

Re: Loading resources w/o a ResourceGroupLocation

Posted: Thu Jan 01, 2009 12:38 pm
by yehiyaml
Another option, which is the one I've taken, is to create an Archive of your own, and register it.
When ogre tries to find a resource in the resourceGroupManager, it will also "ask" your archive if you have it. Inside the open method of the archive, open the file, and return a DataStreamPtr. After that, everything else in Ogre will work the same.

Yehiyam