Programming reference for procedural scenes
Use within procedural scenes is possible using the API.
First, ensure you have added the Nigiri Manager prefab to your scene and set up your Directional Light and Camera as per the Getting Started guide.
Instantiation
After instantiating your object, add the Nigiri_MeshEncoder component:
NKLI.Nigiri_MeshEncoder encoder = gameObject.AddComponent<NKLI.Nigiri_MeshEncoder>();
If the object is considered static. IE, it will remain stationary, and not be removed for the life of the scene. Mark as such:
encoder.MeshIsStatic = true;
(optional) If this is a small, detail object and not a large piece of scene geometry. Consider marking as important:
encoder.voxelImportance = true;
Update style defaults to Low Cost. If this is a fast moving object or requires real-time updates. Such as a carried lantern or vehicle. You may set as follows:
encoder.UpdateStyle = NKLI.Nigiri_MeshEncoder.UpdateStyleModes.ExpensiveRealtime;
Note: It is important to set these values immediately after adding the component!
Destruction
Before removing an object from your scene. You may call the following function to clear its voxels from the octree.
// Get reference to encoder component if not stored earlier (though, you really should cache this when it's initially created!)
NKLI.Nigiri_MeshEncoder encoder = gameObject.GetComponent<NKLI.Nigiri_MeshEncoder>();
// Clear the voxels
encoder.ClearVoxelsAndShutdown();