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 » Wed Dec 08, 2004 2:31 pm

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

User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands

Post by :wumpus: » Wed Dec 08, 2004 3:46 pm

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

sim8
Gnoblar
Posts: 9
Joined: Mon Dec 06, 2004 11:13 pm
Contact:

Post by sim8 » Wed Dec 08, 2004 3:48 pm

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

User avatar
zarthrag
Greenskin
Posts: 128
Joined: Sat Jul 24, 2004 9:07 am
Location: Tulsa, Oklahoma

Post by zarthrag » Fri Dec 10, 2004 5:33 pm

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

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 2
Contact:

Post by sinbad » Fri Dec 10, 2004 5:52 pm

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

User avatar
zarthrag
Greenskin
Posts: 128
Joined: Sat Jul 24, 2004 9:07 am
Location: Tulsa, Oklahoma

Post by zarthrag » Fri Dec 10, 2004 5:58 pm

You'd have to parse any scripts in those locations manually though.
What function do I have to call to do that?
0 x

User avatar
johnnyfeego
Gnoblar
Posts: 16
Joined: Thu Sep 30, 2004 6:21 am
Location: Rome, Italy...
Contact:

Post by johnnyfeego » Fri Jan 07, 2005 11:16 pm

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.
0 x
Johnny Petrantoni.
Rome, Italy.
http://www.meskalina.it
OSX & WinXP user.

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 2
Contact:

Post by sinbad » Sat Jan 08, 2005 12:36 am

Look for 'parseScript' methods on '<Blah>Manager' classes, like MaterialManager.
0 x

User avatar
johnnyfeego
Gnoblar
Posts: 16
Joined: Thu Sep 30, 2004 6:21 am
Location: Rome, Italy...
Contact:

Post by johnnyfeego » Sat Jan 08, 2005 8:04 am

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.
0 x
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 » Sat Jan 08, 2005 1:44 pm

Bah...I'm just gonna move to 1.0
0 x

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 2
Contact:

Post by sinbad » Sat Jan 08, 2005 3:05 pm

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

User avatar
johnnyfeego
Gnoblar
Posts: 16
Joined: Thu Sep 30, 2004 6:21 am
Location: Rome, Italy...
Contact:

Post by johnnyfeego » Sat Jan 08, 2005 7:08 pm

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.
0 x
Johnny Petrantoni.
Rome, Italy.
http://www.meskalina.it
OSX & WinXP user.

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 2
Contact:

Post by sinbad » Sat Jan 08, 2005 7:58 pm

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

User avatar
johnnyfeego
Gnoblar
Posts: 16
Joined: Thu Sep 30, 2004 6:21 am
Location: Rome, Italy...
Contact:

Post by johnnyfeego » Sat Jan 08, 2005 8:39 pm

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

Post Reply