Asset Management

Started by
0 comments, last by SiS-Shadowman 15 years, 11 months ago
What's a good way to manage game assets (images, sound, music, etc) within the game code architecture? All I can think of is to load all the needed assets depending on the current game state (intro, menu, play) and "unload" them when done. When done this way it seems pretty procedural, and hard to manage. What I'm really looking for is a way to manage all of this in an OO way. Any help is appreciated, thanks!
Advertisement
I think this depends on what you are doing. The scale of your project. If you're doing some asteroids clone, I doubt anything else than a database, that stores everything in a vector/list should be sufficent, since you can store everything in memory, withour running into trouble. But things change, when you can't load everything into memory at one moment (wich will most likely depend on the scale of your game world).

I'm no expert at all, but I think one method (that seem's to be used in alot of mmorpgs) is, that you create a database, that stores one instance of a model/sound/texture, but doesn't load everything into memory right now. That is you would have a CModel class, that knows wich model is associated with this particular instance and it will begin to load this model from the harddisk (create the vertex&index buffers) when anything requests this model to draw:

Database--A list of Models---- Model "Player" --> "Objects/Models/Player.md5"class CPlayer{private:    CModel *m_pModel;public:    CPlayer()    {        m_pModel = Database.GetModel( "Player" );    }    void Draw()    {        m_pModel->Draw();    }};


The model should keep a list, how many times it is referenced, so that the model "knows" if it should be kept in memory or not.

Whenever the Draw() method of the model is called, it will check, if the model has been loaded, if not, it will spawn a seperate thread that will take care of that, and will start drawing the mesh, once the thread has finished.

The benefit of this method is, that nothing is kept in memory, that is not needed (ofcourse it can be tweaked, the model could count the seconds it has not been drawn and it will unload itself after some threshold).
But the downside is, that the model is not being drawn, when it should be, not instantly (but it can be tweaked, the game would need to guess, if this model could be on the screen in the future).

But again, even games like UT3 don't seem to load objects during the game (except for the textures in the first 10 seconds). I think they load everything into memory when you wanna play, since it's just one level, some models and some sounds.

This topic is closed to new replies.

Advertisement