Voxel dimensions?

605 views
Skip to first unread message

pratik...@cctech.co.in

unread,
Sep 27, 2017, 9:50:30 AM9/27/17
to OpenVDB Forum
What is the size of voxel(in millimeter or meter), if voxel size =1?

chris golchert

unread,
Oct 5, 2017, 4:35:24 PM10/5/17
to OpenVDB Forum
I asked this a while back and was told that it is up to your app to determine.  That doesn't help if the file was created outside of your app.   I was expecting for it to be metadata... but then that wouldn't always help since metadata isn't required for every file.  ...add the fact that Maya uses centemeters as a default....  :).

Ken Museth

unread,
Oct 5, 2017, 9:38:09 PM10/5/17
to OpenVDB Forum
An OpenVDB grid is essentially made up of three parts: a tree, a transform and metadata. The tree is basically just a collection of voxels (and so-called tiles), organized in a VDB tree structure and accessible by integer coordinates (e.g. i,j,k), and the transform defines the mapping from index space of the tree to world space, and the metadata is (as you correctly noted) largely optional. So when you ask "what is the size of a voxel" the answer depends on what space you're referring to - world space or index space? By design a voxel is the smallest addressable unit in index space so the voxel size is always one in index space. Consequently the size of a voxel in world space is uniquely given by the transform of the grid! So, if we assume (which is often the case) that the transform of a grid only has uniform scaling, this scaling factor is exactly the voxel size. Long story short, if someone gives you an OpenVDB grid and you're wondering what the voxel size is, all you have to do is inspect the transform of this grid. If the transform has uniform scaling (use grid.hasUniformVoxels()) then the voxel size is simply by grid.voxelSize()[0]. (Else the voxel size may vary along the coordinate axis or even be a function of world space position, e.g. for frustrum transforms). On the other hand if you want to create a new grid with a specific voxel size simply do:

auto grid = openvdb::FloatGrid::create( 0.0f );// 0.0f is the "background value"
grid->setTransform(openvdb::math::Transform::createLinearTransform( 0.25f ));// 0.25f corresponds to the voxel size in world units (could be cm, meters or light-years - that's up to your application :)

Hope this clarifies things!?
Ken

pratik...@cctech.co.in

unread,
Oct 6, 2017, 2:37:29 AM10/6/17
to OpenVDB Forum
Thanks Ken.
Reply all
Reply to author
Forward
0 new messages