Before the first rendering of a scene with DirectViz, building the geometry objects and computing the associated internal acceleration structure can take a significant time, especially for scenes with very large number of polygons. This internal structure can be saved to or loaded from the hard disk.
DirectViz allows you to associate a cache file with an Open Inventor scene graph. Launching DirectViz to render a scene graph with a corresponding cache file on disk avoids the re-creation of the internal structure and speeds up startup before the first render.
The file caching mechanism is enabled by the SoPreferences SoPreferences SoPreferences DIRECTVIZ_FILE_CACHING configuration parameter or the SoDirectVizManager SoDirectVizManager SoDirectVizManager fileCaching field.
To use this mechanism, the directory for cache files must be set via the SoPreferences SoPreferences SoPreferences parameter DIRECTVIZ_CACHE_DIR or using the method setCacheDirectory () of SoDirectVizManager SoDirectVizManager SoDirectVizManager . This directory will contain all the cache files needed by DirectViz for reading and writing. If cache files must be loaded, make sure that they are located in this directory.
![]() | |
File caching in cluster mode (see section below for more details)
|
There are two ways to use the cache mechanism: by method calls or automat ically.
This method sets the current cache directory:
void setCacheDirectory(SbString directory);
The following method specifies explicitly a cache file to be used. The file can be opened in read-only, write-only, or read/write mode (READ_MODE, WRITE_MODE, READ_WRITE_MODE).
void setCacheFile(SbString filename, CACHE_MODE mode);
The cache file can be automatically fetched from the current cache files directory by DirectViz based on a “signature” of the scene graph. A signature corresponding to a specific scene graph is stored in each cache file. One cache file can only represent one scene graph. In most cases there is no need to manually specify cache files. However your application is still responsible for managing and updating the cache files appropriately (e.g., deleting invalid files).
![]() | |
A scene graph signature association is started after the first traversed shape, i.e., it is not dependent on the property nodes traversed at the beginning of the scene graph. |
![]() | |
As they are tied to internal data structures, the cached files may not be compatible between different platform architectures, 32-bit and 64-bit systems, different operating systems, or different versions of DirectViz. The cached files may also be dependent on the shader package used. |