From Human Computer Interaction Laboratory
Our system supports a semi-automatic technique to quickly save and restore data between two Vrecko executions.
The data are saved into the "cache" directory and are used if the original data haven't changed since the creation of the cached file.
Automatic usage - loadGeometry()
This behaviour is fully automatic and transparent for 3D models loaded using the EnvironmentObject::loadGeometry() method. This is the way it works:
The file is loaded on the first time and then immediately saved into a binary OSG format (into the "cache" directory), which is very fast to load. Next time the loadGeometry() method is called, the cache is checked and if the cached data matches the original file (some date & time check is performed), the cached version is loaded instead. If the loadGeometry() method detects that the original file is modified, the cached version is automatically deleted and created again.
Manual usage in your methods
You can use the same schema for ANY of your data belonging to ANY file using the PersistentCache class (use world->getPersistentCache() to get the pointer).
The interface is VERY simple, so you can really easily save your own data. For example, you can see VoxelGrid_Object_Data::loadFromCache() and VoxelGrid_Object_Data::saveToCache() methods that employ caching of automatically calculated voxel data from a 3D model.
The ideas
When saving data into cache, you have to present a file name that you wish this data will be associated with. Additionally, you will have to present a name for this data and you private version number (e.g. "data\MyModel.obj" + "model_statistics" + 1). The file name and the data name will be used to uniquely identify the file. The version can be used to easily invalidate old data, when you change the code that calculates them - then you easily increment the cache version by one and the system automatically forgets the old data.
The system also automatically checks date & time of the cached file and the associated original file, compare them and reacts accordingly (may delete the cache and return "false" to indicate that the cache is no longer accurate.)