How do you manage assets?
This question has been discussion many times already. Searching for "asset manage" or "resource manage" will give you plenty of hits. There you can find much about caches and loaders. However, many if not most of them suggest to manage assets separated by type. Why exactly do you feel it being wrong?
Hello everyone, I am doing a free time project, and I am currently working on loading models from the OpenGEX file format. Now there is this one thing that I have been getting stuck on for ages. It is managing my assets. I don't know where to store them, and how I should access them. So far I have been using a bunch of managers (because my teacher recommended it for now). The thing is I would like to know how to do it properly. I don't want to create a manager per asset type, but I have no idea how to do it otherwise and still keep it simple. So my question is, I load a model that consists out of a bunch of materials, a bunch of meshes, a few textures, and a scene, how and where do I store it?
I'm not clear if you're trying to figure out where to store the files on disk, or in memory, or both.
As far as keeping it simple, asset loading, caching, retrieval, releasing, and cache invalidation is not a simple thing. Imagine you've got all these different resources, and then you have Windows, Linux, and Console file systems to worry about.
Any elegant code you come up with to make all resources generic and the same will most likely come back to bite you. How many different types of resources do you have? Meshes, materials, textures, sounds, music, save files, level data, scripts, etc... These things are not the same. Don't try to whip computer science on them.
It seems like a lot at first, but most of the work is just saving and loading the data. You do it once and forget about it.
Then don’t make them global.In general when I use a manager, it feels wrong, because it's something that is global.
The model manager has a pointer to the model texture manager, animation manager, etc.But with 3D models that doesn't work. Since you have materials, textures, and meshes(, and more).
#1: It passes to the appropriate managers a file stream pointing to the correct part of the file.
#2: Materials don’t need to be managed. They are a very small chunk of data and typically should not be shared.
This relationship is backwards. A scene can contain any number of model instances (not models).So my question is, I load a model that consists … and a scene
There is no way for a model file to contain a scene. You can load an empty scene and then load a single model instance into it.
It is almost never an asset in any case. A file by itself is useless. It is only an asset when it is parsed and data is extracted. Clearly there should be one type of manager for one type of data in a file.A file is not an asset in this case.
Use shared pointers, not strange indirect identifiers. If for some reason you need direct access to a model’s texture, either get it through the model itself or if you want to use identifiers you can use the texture’s original file name (possibly including directories in order to force uniqueness). FBX and perhaps OpenGEX store the texture’s name as its own identifier, but these can’t be used to identify a texture uniquely, only uniquely within a single model. Another model could load a different texture with the same name.I do not know how to give the assets some kind of identifier to get them.
Matching textures should be detected via CRC, not file name.
I would assume not. Once you have a shared pointer to the model you have loaded you really don’t need anything else. This is what your scene should be holding. Again, especially for your purposes, you would access the rest through the model itself (its materials and textures).And you could get stuff by type, but it didn't seem that great either.
L. Spiro