Loading resources w/o a ResourceGroupLocation

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
Moohasha
Gnoll
Posts: 672
Joined: Fri Dec 07, 2007 7:37 pm
x 8

Loading resources w/o a ResourceGroupLocation

Post 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.
Black holes are where God divided by 0
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Re: Loading resources w/o a ResourceGroupLocation

Post 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.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Loading resources w/o a ResourceGroupLocation

Post by jacmoe »

ManualResourceLoader is the magic word here. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Moohasha
Gnoll
Posts: 672
Joined: Fri Dec 07, 2007 7:37 pm
x 8

Re: Loading resources w/o a ResourceGroupLocation

Post 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
Black holes are where God divided by 0
User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
x 3
Contact:

Re: Loading resources w/o a ResourceGroupLocation

Post 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.
Game Development, Engine Development, Porting
http://www.darkwindmedia.com
User avatar
Moohasha
Gnoll
Posts: 672
Joined: Fri Dec 07, 2007 7:37 pm
x 8

Re: Loading resources w/o a ResourceGroupLocation

Post 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
Black holes are where God divided by 0
yehiyaml
Kobold
Posts: 29
Joined: Wed Nov 05, 2008 8:26 am
Location: Israel

Re: Loading resources w/o a ResourceGroupLocation

Post 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
Yehiyam Livneh
Post Reply