Ogre Resource Archive support

Druha

23-11-2009 14:41:10

Hi, betajaen!
Does NxOgre has support for using .zip files as archives for resources, or I need to write my own implementation of such archive type?
If so, what should I do to properly fit my code into NxOgre?

And another idea. Is it possible to use same resource system as Ogre uses via special archive type?
I see it something like
NxOgre::ResourceSystem::getSingleton()->openArchive("OgreMedia","ogre:OgreResourceGroup");
I am now using Git master branch, so if Detritus has all that I've asked I'll be happy :)

betajaen

23-11-2009 16:24:25

You could do either; but you will have to write your own implementation of ResourceProtocol, Archive and Resource though, like how it is with memory and file at the moment.

It shouldn't be too difficult to do, the Ogre resource system is pretty straight forward and could easily be wrapped using Archives and Resources to make OgreResourceProtocol, OgreArchive and OgreResource.

I can give you some nudges in the right direction, and tell you what basically needs to be done. If you steal the FileResourceProtocol, FileArchive and FileResource .cpp/.h files your half way there already. ;)

Druha

23-11-2009 17:02:05

Well, If it is simple, I will better create OgreResource wrapper.
first thing i wanna know:
class NxOgrePublicClass MSWindowsFileResourceProtocol : public PointerClass<Classes::_MSWindowsFileResourceProtocol>, public ResourceProtocol
{
// ....
}

What exactly is that `PointerClass` for, and whether I need define my classes in Classes enum?

betajaen

23-11-2009 17:23:13

It's to handle memory debugging and allocation. Each class that uses PointerClass uses it's own enum value.

You can get an enum value from NxOgre, like in OGRE3DRenderSystem.

enum
{
_OGREResourceProtocol = ::NxOgre::Classes::RENDERSYSTEMS_CLASSES_BEGIN + 8888,
_OGREArchive,
_OGREResource
};


"8888" is just an example, OGRE3DRenderSystem uses 100. Glut uses 150, I think.

Druha

23-11-2009 18:50:03

well, i've finished draft code, but I can't compile it inside my project:
EsOgreResource.obj : error LNK2019: unresolved external symbol "class NxOgre::SharedStringStream & __cdecl NxOgre::operator<<(class NxOgre::SharedStringStream &,char const *)"
EsOgreResourceProtocol.obj : error LNK2019: unresolved external symbol "unsigned long __cdecl NxOgre::Functions::generateHash(char const *,enum NxOgre::Enums::HashAlgorithm)"
D:\backup\ogre\Esertia\Game\\bin\Debug\Esertia.exe : fatal error LNK1120: 2 unresolved externals

Looks like this functions available only inside NxOgre itself. Now I am thinking how to test it, cause I dont' want to recompile whole NxOgre every time i find a bug )

betajaen

23-11-2009 19:23:36

Urgh. Try adding NxOgreExportClass to the SharedStringStream (if it isn't done so already), and you can copy that hashing function into your own code. It's only 4-5 lines.

Shame, your not using Detritus, the Resource System in there is so much better.

Druha

25-11-2009 07:55:41

Finally, I got it working, but only with Git Master for now, because I am too lazy to make a new Ogre app to port and test the code for Detritus. And my current app is too large to rewrite just to test a resource system.
If anybody is interested, I can post a code here. Maybe later I will port it to Detritus.