Jump to content
  • Advertisement
Sign in to follow this  
Lijmer

How do you manage assets?

This topic is 1183 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement

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? 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
In general when I use a manager, it feels wrong, because it's something that is global. So far I have made managers where I would give it a string, and return me the asset. But with 3D models that doesn't work. Since you have materials, textures, and meshes(, and more). A file is not an asset in this case. I do not know how to give the assets some kind of identifier to get them. I've once seen a system where it used linked lists to store store assets in. And you could get stuff by type, but it didn't seem that great either. BTW, for my project (Real Time Ray Tracer) I also need all of my assets to be copied to GPU memory to be used in CUDA.

Share this post


Link to post
Share on other sites

In general when I use a manager, it feels wrong, because it's something that is global.

Then don’t make them global.
 

But with 3D models that doesn't work. Since you have materials, textures, and meshes(, and more).

The model manager has a pointer to the model texture manager, animation manager, etc.
#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.
 

So my question is, I load a model that consists … and a scene

This relationship is backwards. A scene can contain any number of model instances (not models).
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.
 

A file is not an asset in this case.

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.

 

I do not know how to give the assets some kind of identifier to get them.

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.
Matching textures should be detected via CRC, not file name.
 

And you could get stuff by type, but it didn't seem that great either.

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).


L. Spiro Edited by L. Spiro

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!