I'm currently working on the part where you load and parse data. The idea of the engine is close to the one from Game coding complete 3.
GCC3's code isn't actually engine so I had to write on my own almost everything.
Currently I've got a resource cache. It has a list of resource files. Resource file is for example zip. I can load a file this way:
ResCache::Get()->AddResourceFile(ResourceFilePtr(new NoResourceFile("test.txt"))); // This way I can load files directly if there are not in resource file, however I wanted to keep the same "pattern" so I inhrerited and make this thing char buffer; Resource res("test.txt\ est.txt"); // doesn't look really intelligent however it means "Load test.txt, located in test.txt"...Yeah but it would look much better : Resource res("mainmenu.zip\\background.png"); memcpy(buffer, ResCache::Get()->GetHandle(res)->GetBuffer(), ResCache::Get()->GetHandle(res)->GetSize()); buffer[ResCache::Get()->GetHandle(res)->GetSize()] = '\0'; cout << buffer;
The problem is how to turn this data into something useful for my engine without everything becomming mess, and still to use the same way to transfer data like any other asset.
I came to something like this:
AssetData class which can store everything. Just inherite from AssetData, for example to XML (which will store my level/map data). Then I would call AssetData : XML_Data::Restore(res); and it would fill itself in its unique way. If I want I could pass the XML_Data to my logic and it would load the map as it is written in there. If it was a mesh I could easily call AssetData : Mesh::Render(const IRenderer &r);
However in my mind AssetData appear to be a tree structure where each assetdata can have children. There comes the problem how to fill the children and to pass the exact data they need to fill.
So my questions at the end are:
How you would do this?
Where would u parse the data? In class AssetManager, by list of supported formats? In the AssetData? Or A completely different way?
Edit: Sorry for not beeing enough direct. I wanted to explain everything from the beginning so you don't need to check the whole source code I've got. However the SC is can be found here if you need something: http://code.google.c.../ random-engine
Edited by Nickie, 21 August 2012 - 08:11 AM.