How to add new resource pack?

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
sim8
Gnoblar
Posts: 9
Joined: Mon Dec 06, 2004 11:13 pm
Contact:

How to add new resource pack?

Post 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
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post 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.
sim8
Gnoblar
Posts: 9
Joined: Mon Dec 06, 2004 11:13 pm
Contact:

Post 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.
User avatar
zarthrag
Greenskin
Posts: 128
Joined: Sat Jul 24, 2004 9:07 am
Location: Tulsa, Oklahoma

Post 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?
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post 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.
User avatar
zarthrag
Greenskin
Posts: 128
Joined: Sat Jul 24, 2004 9:07 am
Location: Tulsa, Oklahoma

Post by zarthrag »

You'd have to parse any scripts in those locations manually though.
What function do I have to call to do that?
User avatar
johnnyfeego
Gnoblar
Posts: 16
Joined: Thu Sep 30, 2004 6:21 am
Location: Rome, Italy...
Contact:

Post 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... :wink:)

thanks a lot.
Johnny Petrantoni.
Rome, Italy.
http://www.meskalina.it
OSX & WinXP user.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

Look for 'parseScript' methods on '<Blah>Manager' classes, like MaterialManager.
User avatar
johnnyfeego
Gnoblar
Posts: 16
Joined: Thu Sep 30, 2004 6:21 am
Location: Rome, Italy...
Contact:

Post 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.
Johnny Petrantoni.
Rome, Italy.
http://www.meskalina.it
OSX & WinXP user.
User avatar
zarthrag
Greenskin
Posts: 128
Joined: Sat Jul 24, 2004 9:07 am
Location: Tulsa, Oklahoma

Post by zarthrag »

Bah...I'm just gonna move to 1.0
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post 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
User avatar
johnnyfeego
Gnoblar
Posts: 16
Joined: Thu Sep 30, 2004 6:21 am
Location: Rome, Italy...
Contact:

Post 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.
Johnny Petrantoni.
Rome, Italy.
http://www.meskalina.it
OSX & WinXP user.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post 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.
User avatar
johnnyfeego
Gnoblar
Posts: 16
Joined: Thu Sep 30, 2004 6:21 am
Location: Rome, Italy...
Contact:

Post by johnnyfeego »

Ok, I got it..
Thanks a lot Sinbad!!
Johnny Petrantoni.
Rome, Italy.
http://www.meskalina.it
OSX & WinXP user.
Post Reply