Page 1 of 1
How to add new resource pack?
Posted: Wed Dec 08, 2004 2:31 pm
by sim8
Very new with this ogre thing, so bear with my learning curve...
How do you load a new resource pack after the engine has been initialised? I am starting the engine and letting the user choose a map. After they make a selection, I want to register the resource pack for that map. However, since the engine is already initialised, the material scripts never get compiled. Is there a way to "reset" the engine so it will reload all of the resources?
Also, possibly related, is there a way to "unload" the resources from the last map?
Thanks,
Jason
Posted: Wed Dec 08, 2004 3:46 pm
by :wumpus:
Currently this is hard (you need to keep track of the resource groups yourself). The upcoming major OGRE version will have resource groups so you can do exactly this; load and unload complete blocks of resources.
Posted: Wed Dec 08, 2004 3:48 pm
by sim8
Okay, thanks I'll just hardcode a map for now and wait for the next version. I've got plenty of learning to do in the meantime.
Posted: Fri Dec 10, 2004 5:33 pm
by zarthrag
Currently this is hard (you need to keep track of the resource groups yourself). The upcoming major OGRE version will have resource groups so you can do exactly this; load and unload complete blocks of resources.
I think this explains why my engine takes eons to startup. As it currently has access to the entire game via OgreSQL. Is there a suggested workaround or set of functions I could hack away at?
Posted: Fri Dec 10, 2004 5:52 pm
by sinbad
You could not add those resource locations before the Root::initialise call, and add them afterwards. You'd have to parse any scripts in those locations manually though.
Posted: Fri Dec 10, 2004 5:58 pm
by zarthrag
You'd have to parse any scripts in those locations manually though.
What function do I have to call to do that?
Posted: Fri Jan 07, 2005 11:16 pm
by johnnyfeego
zarthrag wrote:What function do I have to call to do that?
ehm... I got this problem too..
have you figured out what functions we have to call?
(anyway I'm going to look into ogre code...
)
thanks a lot.
Posted: Sat Jan 08, 2005 12:36 am
by sinbad
Look for 'parseScript' methods on '<Blah>Manager' classes, like MaterialManager.
Posted: Sat Jan 08, 2005 8:04 am
by johnnyfeego
sinbad wrote:Look for 'parseScript' methods on '<Blah>Manager' classes, like MaterialManager.
Thanks.. I've figured out by myself, it was quite easy (I really love this engine!!!), but I'm not sure about unloading:
Code: Select all
/** Cleans up the statics 'mCommonVFS' and 'mCommonArchiveFiles'. Required to reset Ogre,
otherwise the containers are left with invalid pointers, which will lead to a crash
as soon as one of the ResourceManager implementers (e.g. MaterialManager) initializes.*/
static void cleanupCommonArchive () ;
I'm using this function, but I don't understand what do you mean for reset. clearScene() is it correct?
btw, what about the new resource system at this purpose? we will have to parse scripts manually too?
thanks again.
Posted: Sat Jan 08, 2005 1:44 pm
by zarthrag
Bah...I'm just gonna move to 1.0
Posted: Sat Jan 08, 2005 3:05 pm
by sinbad
johnnyfeego wrote:
I'm using this function, but I don't understand what do you mean for reset. clearScene() is it correct?
No, complete shutdown of the manager objects, not clearing the scene. Unless you have to reinitialise Ogre, don't worry about it.
btw, what about the new resource system at this purpose? we will have to parse scripts manually too?
No. Script parsing is a lot more flexible, and you can initialise either specific resource groups (parsing all scripts in them), or even initialise all groups which haven't been initialised yet, so any groups you've added since the last set of script parsing get done automatically.
Full details of the new features are available on the Wiki:
http://ogrewiki.digitalsentience.com/in ... thothNotes
Posted: Sat Jan 08, 2005 7:08 pm
by johnnyfeego
sinbad wrote:No, complete shutdown of the manager objects, not clearing the scene. Unless you have to reinitialise Ogre, don't worry about it.
what do you mean? I need to load resources for a map and when the player changes map I need to free resources and load them again for the new map, I'm sure that resources group will help a lot, but since I'm on mac and I cannot build 1.0 (the xcode project won't work) I need to work with the old resource system. So can I destroy all resources without going into troubles?
thanks a lot.
Posted: Sat Jan 08, 2005 7:58 pm
by sinbad
You can use the 'unload' and 'unloadAndDestroyAll' methods of ResourceManager to unload resources in Hastur. Just be aware that unloadAndDestroyAll, while convenient, really does unload and destroy everything in that ResourceManager. If you want to keep some basic resources you'll have to reload them manually, or unload everything except that. This inconvenience is one of the things the new resource management addresses.
Posted: Sat Jan 08, 2005 8:39 pm
by johnnyfeego
Ok, I got it..
Thanks a lot Sinbad!!