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

Loading resources w/o a ResourceGroupLocation

Post by Moohasha » Fri Dec 26, 2008 12:30 am

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.
0 x
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

Re: Loading resources w/o a ResourceGroupLocation

Post by xavier » Fri Dec 26, 2008 1:50 am

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.
0 x
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
Contact:

Re: Loading resources w/o a ResourceGroupLocation

Post by jacmoe » Fri Dec 26, 2008 2:07 am

ManualResourceLoader is the magic word here. :wink:
0 x
/* 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

Re: Loading resources w/o a ResourceGroupLocation

Post by Moohasha » Fri Dec 26, 2008 3:05 pm

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
0 x
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
Contact:

Re: Loading resources w/o a ResourceGroupLocation

Post by Praetor » Fri Dec 26, 2008 8:27 pm

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.
0 x
Game Development, Engine Development, Porting
http://www.darkwindmedia.com

User avatar
Moohasha
Gnoll
Posts: 672
Joined: Fri Dec 07, 2007 7:37 pm

Re: Loading resources w/o a ResourceGroupLocation

Post by Moohasha » Fri Dec 26, 2008 8:58 pm

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
0 x
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 » Thu Jan 01, 2009 12:38 pm

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
0 x
Yehiyam Livneh

Post Reply