kgmcnamara Posted April 20, 2014 Share Posted April 20, 2014 (edited) Hi, I want to be able to write data into individual voxels inside of a VDB that is input to my HDK node. So far I have done the following: // Get the first VDB primitive in the geometry GEO_PrimVDB* vdbPrim = NULL; for (GA_Iterator it(gdp->getPrimitiveRange()); !it.atEnd(); it.advance()) { GEO_Primitive* prim = gdp->getGEOPrimitive(it.getOffset()); if(dynamic_cast<const GEO_PrimVDB *>(prim)) { vdbPrim = dynamic_cast<GEO_PrimVDB *>(prim); break; } } // Make sure we got a valid prim if(!vdbPrim) { addError(SOP_MESSAGE, "Input geometry must contain a VDB"); return error(); } // Docs say to do this in case the grid is shared vdbPrim->makeGridUnique(); Next I try to get the Grid from vdbPrim, but I can't get it to work. I've tried a handful of functions like getGrid(), getGridPtr(), etc. Can anyone recommend what I need to do next? EDIT - SOLVED. Posting for any others who might find themselves in a similar struggle: Some more digging through the VDB docs lead me to this. Works! // Docs say to do this in case the grid is shared vdbPrim->makeGridUnique(); // Try to get the vdb's grid openvdb::GridBase::Ptr baseGrid; if(vdbPrim->hasGrid()) baseGrid = vdbPrim->getGridPtr(); openvdb::FloatGrid::Ptr grid = openvdb::gridPtrCast<openvdb::FloatGrid>(baseGrid); openvdb::FloatGrid::Accessor accessor = grid->getAccessor(); openvdb::Coord xyz(0,0,0); accessor.setValue(xyz, 1.0); Edited April 20, 2014 by kgmcnamara 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.