Return to the tutorials list.

16 - Optimization / Using the API efficiently

Until now, you've seen how to use the API for reading and rendering some models, with the most common options exposed. If you plan to develop some more serious usage than the tutorials, you'll have to know more about how to get the best performance of the API.

After reading this documentation, you should know how to:
 * Use the Optimizer to reduce runtime memory usage and get the best rendering speed with the API for your models
 * Use JmfWriter to convert your models to optimize its loading (faster), reduce even more model file size and optimize the texture
 * Protect the model and textures with secure encryption (if needed)

Asset format (JMF,TEX)

The engine support most of the major 3d model format, such as dae/fbx and many more. Most of them are interchange model format, text based format or format close to modeling software. They are therefore not optimize for 'in-game' content.

We provide our own optimized model format (JMF). JMF is a binary format which preserves runtime model format. Therefore, it can be read and written very efficiently, without any conversion, computation or temporary allocation. JMF format ensure forward compatibly, which means any JMF format will be loadable by all next version of the engine.
The format also offer optional heavy compression (LZMA) and encryption (both optional) which may be usefull to securely share/download 3d content.

DDS texture format is the most complete format with support of mipmap, cubemap, float texture, compressions (S3TC aka DXTx, 3dc, rgtx/latc, etc1, ...).
It's no surprise that our texture format (TEX) is a DDS texture with some additional header (for faster loading within our engine). Therefore, TEX format support all features of DDS format and, additionaly, same LZMA compression and file encryption than with JMF.


Asset conversion

We'll see now how to convert any model to JMF format, and texture to TEX or DDS.

The next code block shows how to convert using the api:
 * Optimizing model for memory and speed: Optimizer.getBestOptions
 * Convert and optimizing texures: setTextureWriterOptions
 * High compression ratio:useLzmaCompression
 * Encryption: key
 * Converting to JMF: JmfWriter



All of these options are exposed in the viewer tool for quick and easy conversion:
Model conversion options


Note on animation compression
Animation information can consumed a resonable or heavy amount of memory, especially for long skinning motions. Most of the animation memory is taken by KeyFrame<Transform> to represent the mesh or joint positioning at a set of times.

Animation compression consist at compressing and reducing the number of keys. Key compression is done by KeyFrameTransform which is an optimized implementation of KeyFrame<Transform>. The key reduction is possible in two ways: lossless or loosy compression.

Most of the time, keyframe contains a huge number of duplicated keys, sometimes due to export from riging tool, motion capture or the our reader itself.

Lossless key reduction merge keys which contains strictly identical Transform value.
Loosy key reduction merge keys 'close enought', the optimizer implements 3 level of loosy compression: light, medium and heavy. Light and medium compression should result to no visual animation differences, but offer a good compression ratio. Heavy compression will potentially involves slight quality loose but much higher compression, sometime quality could be enought sometimes not so give a quick try .

TO BE COMPLETED