Custom resources (ResourceManager plugin?)

Thomas233

26-09-2009 23:08:34

Hey guys,

i have a question concerning the basic concept of Ogre/Mogre. In my project I need a lot of custom ressources like XML-files, sound files (ogg), text files and of course Ogre specific resources like meshes, materials and so on too. At this point I have to decide wheter i want to use Ogre`s resource management classes for custom resource types (XML,Ogg,etc.) or develop my own mechanism.

My wish is to let Mogre/Ogre do resource management for all types of resources that are within the resource locations configured because i like the concept Ogre does this. So what about those custom resource types (xml, text files), is there a way to load/open them without implementing custom resource manager classes/plugins as described here: http://www.ogre3d.org/wiki/index.php/Ad ... Tutorial_1 ?
And if not, is it basically possible to add a custom resource manager to Mogre as described in the Ogre tutorial ?

Another simple question: Does the resource management in Ogre and also in Mogre support multi-threading. Do resources get loaded in another Thread in Ogre/Mogre too or do it use the application thread ?

In which way do you perform resource management with Mogre ? I`m very new to game development (but not directx and c#) and have no concrete idea yet (just recently ordered the book announced at the Ogre news page) on how to do that but i really want to develop my first game using Mogre !

Thanks !

Best regards,
Thomas

GantZ

27-09-2009 19:19:12

hi,

personally, i use the ResourceGroupManager singleton to get the list of custom resources (after initializing ResourceGroup), for exemple :

FileInfoListPtr FInfoList = ResourceGroupManager.Singleton.ListResourceFileInfo("General");

to get the filelist of a resourcegroup (here General). this way, you can get the file info of a specific resourcegroup (my advice here is to use a different resourcegroup for your custom resource)
after that, i just do a foreach on my list and open a dotnet stream.


foreach (FileInfo_NativePtr Fileinfo in FInfoList)
{
int ExtensionPosStart = Fileinfo.filename.LastIndexOf('.');
string Extension = string.Empty;

if(ExtensionPosStart > 0)
Extension = Fileinfo.filename.Substring(ExtensionPosStart,Fileinfo.filename.Length - ExtensionPosStart);

if (Extension == INFO_FILE_EXTENSION)
{

//get full path of the file
string AbsolutePath = Path.GetFullPath(Fileinfo.archive.Name + "/" + Fileinfo.filename);

//get a FileStream
FileStream Datastream = new FileStream(AbsolutePath, FileMode.Open, FileAccess.Read, FileShare.Read);
}
}


for a quick simple custom resource management, it work quite well. if haven't try the way it described in the tutorial you linked. i'm not sure if it's possible to derive from mogre class. still, it seem possible to use ResourceGroupManager.Singleton.DeclareResource with a class implementing the interface IManualResourceLoader.

regarding your second question. ogre support resource loading in a background thread (try searching background loading in the main forum), but you need to recompile it setting OGRE_THREAD_SUPPORT param to 2. (see this thread for more information http://www.ogre3d.org/forums/viewtopic.php?f=4&t=40205&p=278043 ). the problem lie with mogre, last time i tried to compile it using OGRE_THREAD_SUPPORT, i got error due to incompatibility between Boost 1.33 and c++/cli, but that was with the 1.4 branch.

Thomas233

29-09-2009 11:45:14

That does pass over Ogre`s resource loading mechanim right (Unknown --> Loaded) ? Doesn`t a more fashionable solution exist ?

But anyway that`s a first approach which I will try out. It helped me a lot thank you !