3D Models in the Resource Cache

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • 3D Models in the Resource Cache

      Hey Guys,

      I had a question about the best way to store the 3D models in the Resource Cache. I am using openGL so I decided to use the Open Asset Import Library, which takes a variety of different formats and gives you your vertex array's, indice's etc. in a nice easy to use interface.

      My question is, how are 3D models usually stored? Should they be stored in the resource Cache as the raw binary data, or should I have the Import Library convert the file and store the vertices and indices as directly usable data? My reasoning why I am confused about this is because I thought it was likely not the right way to go to be constantly rebuilding the 3D data for each object. This way it only get's rebuilt if the model was removed from the cache and requested again.

      Also, in my 'mesh node', should I simply hold an identifier to a 3D Model resource, which get's retrieved from the resource cache each time the node is rendered?

      Thanks
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • RE: 3D Models in the Resource Cache

      It depends somewhat on the API you use to load the model.

      If your model can be loaded from a memory stream, you can use GCC4's resource cache to store, load, and even post process the model once it is loaded.

      Take a look at the Audio chapter, and the OggResourceLoader class and see how OGGs are loaded - I'll bet you will be able to repurpose that code for your 3D models.

      Now, whether you store raw data or preprocessed data for super fast loading is somewhat dependent on your production process, and whether you need to support multiple platforms with vastly different 3D model formats. One solution that many game companies use is a special "baker" in the Editor - it creates a custom resource file specifically for each platform the game will run on, trading off a longer build process for a fast player load time.

      But - and this is important - make sure your game CAN load raw model files - that way your team doesn't have to rebuild/rebake the entire resource file during development. Sure they won't load very fast, but it will really help you as you tweak the model 78 times getting it to look just right.

      And, yes I'd hold on to a resource handle for each mesh so it gets loaded and processed once, but can be used to display many objects.
      Mr.Mike
      Author, Programmer, Brewer, Patriot