Asset Management
I’ve been going mad over asset management over the last few days. Everything I write, I hate. I cannot think of a good way to efficiently and cleanly handle asset data.
The goals of the asset management system are:
- To manage the releasing of assets at shut down time.
- To prevent an asset being loaded twice. I thought about having this in a file loading registry instead. This would probably be more sensible.
- To allow the asset resources to be flushed and regenerated at any time (such as textures).
I know this should be a simple task but I just can’t think straight. I know I need a reference to the asset, I need the asset data so that it can be regenerated, and I need the actual asset data. To clarify:
- The asset reference points to the generated asset. For example, it would store a pointer to a IDirect3DTexture9 object. Many of these objects share this pointer and when the list is regenerated, their pointers are updated.
- The asset data is the raw data that is used to generate the IDirect3DTexture9 object.
- The asser resource is the encapsulation of the asset: it stores the IDirect3DTexture9 object, for example.
Has anyone got any ideas? I’m getting the feeling I’m just being stupid and I’m trying to think of this in a way that’s overly complex and is obfuscating the simple answer.
August 3rd, 2005 at 8:05 pm
Odd that I was considering how I would approach this problem when it pops up…and I’ve been thinking of going with XML, or something similar - using the XML files to define assets used for each area as needed, and one main.xml file for the assets that remain unchanged (menu items/images, sounds, hud stuff, cinematics).
So…when the game is loading its level, it looks to the corresponding xml file and then fetches the needed assets. When it’s time to load the next level, the game compares the xml file from levelA to the xml file from levelB, and dumps ALL assets NOT listed in the levelB.xml or main.xml…wash, rinse, repeat.
Then again, I might be oversimplifying things…I tend to do that.
And no, I haven’t actually implemented it yet - but what I’ve described is the general idea.
Good Luck!
August 3rd, 2005 at 8:37 pm
That’s not a bad idea. In fact, it gives me several other ideas, but I’ll do those later.
I’ve actually got a rudimentary implementation working that meets the requirements. The internals are gross, but the interfaces are good enough.
I have 2 more things to do before I get on to shaders:
Loading models
A camera system
Both of these are easy enough, so hurrah! I might just get this to a satisfactory stage before next week (which was my personal deadline).