Loading resources w/o a ResourceGroupLocation
- Moohasha
- Gnoll
- Posts: 672
- Joined: Fri Dec 07, 2007 7:37 pm
- x 8
Loading resources w/o a ResourceGroupLocation
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
- xavier
- 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
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.
I honestly don't know how to make it any plainer than I have, beyond writing your code for you.
- jacmoe
- 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
ManualResourceLoader is the magic word here.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
- Moohasha
- Gnoll
- Posts: 672
- Joined: Fri Dec 07, 2007 7:37 pm
- x 8
Re: Loading resources w/o a ResourceGroupLocation
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.
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:
(Desired) adding a resource w/o ResourceGroupLocation:
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
Code: Select all
Ogre::TextureManager::getSingleton().load(location + "/" + name, "none"); // Loads it from location provided
Black holes are where God divided by 0
- Praetor
- 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
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
http://www.darkwindmedia.com
- Moohasha
- Gnoll
- Posts: 672
- Joined: Fri Dec 07, 2007 7:37 pm
- x 8
Re: Loading resources w/o a ResourceGroupLocation
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.
Black holes are where God divided by 0
-
- Kobold
- Posts: 29
- Joined: Wed Nov 05, 2008 8:26 am
- Location: Israel
Re: Loading resources w/o a ResourceGroupLocation
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
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