How to add new resource pack?
-
- Gnoblar
- Posts: 9
- Joined: Mon Dec 06, 2004 11:13 pm
How to add new resource pack?
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
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
-
- OGRE Retired Team Member
- Posts: 3067
- Joined: Tue Feb 10, 2004 12:53 pm
- Location: The Netherlands
- x 1
-
- Gnoblar
- Posts: 9
- Joined: Mon Dec 06, 2004 11:13 pm
-
- Greenskin
- Posts: 128
- Joined: Sat Jul 24, 2004 9:07 am
- Location: Tulsa, Oklahoma
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?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.
-
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
-
- Greenskin
- Posts: 128
- Joined: Sat Jul 24, 2004 9:07 am
- Location: Tulsa, Oklahoma
-
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
-
- Gnoblar
- Posts: 16
- Joined: Thu Sep 30, 2004 6:21 am
- Location: Rome, Italy...
Thanks.. I've figured out by myself, it was quite easy (I really love this engine!!!), but I'm not sure about unloading:sinbad wrote:Look for 'parseScript' methods on '<Blah>Manager' classes, like MaterialManager.
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 () ;
btw, what about the new resource system at this purpose? we will have to parse scripts manually too?
thanks again.
-
- Greenskin
- Posts: 128
- Joined: Sat Jul 24, 2004 9:07 am
- Location: Tulsa, Oklahoma
-
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
No, complete shutdown of the manager objects, not clearing the scene. Unless you have to reinitialise Ogre, don't worry about it.johnnyfeego wrote: I'm using this function, but I don't understand what do you mean for reset. clearScene() is it correct?
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.btw, what about the new resource system at this purpose? we will have to parse scripts manually too?
Full details of the new features are available on the Wiki: http://ogrewiki.digitalsentience.com/in ... thothNotes
-
- Gnoblar
- Posts: 16
- Joined: Thu Sep 30, 2004 6:21 am
- Location: Rome, Italy...
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?sinbad wrote:No, complete shutdown of the manager objects, not clearing the scene. Unless you have to reinitialise Ogre, don't worry about it.
thanks a lot.
-
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
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.