TGB/Other Resources/ImageMapManager

From TDN

ImageMap Datablock Manager


A TorqueScript management class to manage the loading/unload of ImageMaps into video memory. Also provides a callback for each image loaded to display progress on large batch loads.

Resource created by: William Hilke

Article

For a project I am working on I needed a method to control when ImageMaps got loaded into memory, and when they got unloaded. I also wanted to display loading progress to my users so that they didn't think the game had froze up on them. For my class to work you need to make sure any imagemaps that you want this class to control are not set to preload. You can also set them to allowUnload, if you want them to get removed from memory; like say if your switching to a new level and don't need the previous levels image data.

Instructions to use the class are provided in the example script. Please let me know if you see any problems, or know a better way to do this.

The pure script solution creates a hidden static sprite for each imagemap that it loads. If you want to remove this overhead, I've included a module to compile into the engine. Just add DynamicImageLoader.cc to your project and recompile TGB. The TorqueScript class will detect if you have compiled in the engine support and use that instead of the static sprites.

To download, follow this link.