Load, Transform and Save
In this tutorial, we will present how to load, transform and save VDB volumes.
Below is a simple example where it loads a OpenVDB file, apply affine tranformation and saves it to a NeuralVDB file:
import omni.vdb.neuralvdb
import omni.vdb.tool
# Acquire interfaces
ivdbtool = omni.vdb.tool.get_vdb_tool_interface()
# Create a default parameter settings for loading VDB file
load_params = omni.vdb.tool.LoadVDBParameters()
# Read VDB file
volume = ivdbtool.load_volume("/path/to/my_volume.vdb", load_params)
# Apply affine transformation to VDB volume
translation = [0, 1, 0]
rotation = [0, 0, 0]
scale = [1, 1, 1]
age = 0 # volume index
volume_transformed = ivdbtool.transform_volume(
volume,
translation[0],
translation[1],
translation[2],
rotation[0],
rotation[1],
rotation[2],
scale[0],
scale[1],
scale[2],
age,
)
# Create a default parameter settings for saving VDB file
save_params = omni.vdb.tool.SaveVDBParameters()
save_params.encode_params = [omni.vdb.neuralvdb.EncodeParams()]
# Write VDB file. Note that the extension decides the VDB destination (.vdb: OpenVDB, .nvdb: NanoVDB, .mvdb: NeuralVDB).
ivdbtool.save_volume(volume_transformed, "/path/to/my_transformed_volume.mvdb", save_params)
Other manipulations such as iso_to_levelset, csg_levelset, filter_levelset and multi_res_grid work similarly.
Please find more operations for manipulating VDB volumes here.