Kalina Posted November 5, 2014 Share Posted November 5, 2014 (edited) I'm trying to figure out how to create an OpenVDB volume by writing out the voxels, to make a custom SOP. The OpenVDB Hello World example goes something like this: // Initialize the OpenVDB library. This must be called at least // once per program and may safely be called multiple times. openvdb::initialize(); // Create an empty floating-point grid with background value 0. openvdb::FloatGrid::Ptr grid = openvdb::FloatGrid::create(); // Get an accessor for coordinate-based access to voxels. openvdb::FloatGrid::Accessor accessor = grid->getAccessor(); // Define a coordinate with signed indices. openvdb::Coord xyz(5, 5, 5); // Set the voxel value at (5, 5, 5) to 1. accessor.setValue(xyz, 1.0); But now how would I get this to work in Houdini in my "cookMySop()" function? How do I attach this grid to a GU_PrimVDB (or something) to actually create the OpenVDB primitive in Houdini? Could I get a Houdini-specific "Hello World" example? Edited November 5, 2014 by Kalina Quote Link to comment Share on other sites More sharing options...
edward Posted November 6, 2014 Share Posted November 6, 2014 Perhaps not quite so Hello World: https://github.com/dreamworksanimation/openvdb/blob/master/openvdb_houdini/houdini/SOP_OpenVDB_Create.cc But all you really need to look for in that file is the createNewGrid() function. Quote Link to comment Share on other sites More sharing options...
Kalina Posted November 6, 2014 Author Share Posted November 6, 2014 (edited) Thanks, but that didn't get me very far. I now have: openvdb::GridBase::Ptr grid = openvdb::FloatGrid::create(); GEO_PrimVDB* vdb = GU_PrimVDB::buildFromGrid((GU_Detail&)gdp, grid, NULL, "gridName"); which segfaults and crashes: AP_Interface::coreDumpChaser(UTsignalHandlerArg) <libHoudiniUI.so> AP_Interface::si_CrashHandler::chaser(UTsignalHandlerArg) <libHoudiniUI.so> signalCallback(UTsignalHandlerArg) <libHoudiniUT.so> UT_Signal::UT_ComboSignalHandler::operator()(int, siginfo*, void*) const <libHoudiniUT.so> UT_Signal::processSignal(int, siginfo*, void*) <libHoudiniUT.so> [0xf70e] <libpthread.so.0> GA_PrimitiveFactory::lookupDefinition(GA_PrimitiveTypeId const&) const <libHoudiniGEO.so> GA_PrimitiveFactory::create(GA_PrimitiveTypeId const&, GA_Detail&, long) const <libHoudiniGEO.so> GEO_Detail::insertPrimitive(GA_PrimitiveTypeId const&, GEO_Primitive const*) <libHoudiniGEO.so> GU_PrimVDB::build(GU_Detail*, bool) <libHoudiniGEO.so> GU_PrimVDB::buildFromGridAdapter(GU_Detail&, void*, GEO_PrimVDB const*, char const*) <libHoudiniGEO.so> Edited November 6, 2014 by Kalina Quote Link to comment Share on other sites More sharing options...
edward Posted November 6, 2014 Share Posted November 6, 2014 gdp is a GU_Detail pointer, you should use *gdp to pass it as a reference. Quote Link to comment Share on other sites More sharing options...
Kalina Posted November 7, 2014 Author Share Posted November 7, 2014 Thank you, I got it working! openvdb::FloatGrid::Ptr grid = openvdb::FloatGrid::create(); openvdb::FloatGrid::Accessor accessor = grid->getAccessor(); openvdb::Coord xyz(5,5,5); accessor.setValue(xyz, 1.0); xyz.reset(0,0,0); accessor.setValue(xyz, 1.0); GU_PrimVDB* vdb = GU_PrimVDB::buildFromGrid((GU_Detail&)*gdp, grid, NULL, "gridName"); Quote Link to comment Share on other sites More sharing options...
Kalina Posted April 10, 2017 Author Share Posted April 10, 2017 (edited) I just updated to Houdini16, and all of a sudden this same little code snippet doesn't work anymore. Houdini crashes on the line: GU_PrimVDB* vdb = GU_PrimVDB::buildFromGrid((GU_Detail&)*gdp, grid, NULL, "gridName"); ...with no log or helpful error message, just: undefined symbol: _ZN7openvdb11v3_3_0_sesi4math9TransformC1ERKSt10shared_ptrINS1_7MapBaseEE Deciphering that with c++filt shows that it's complaining about: openvdb::v3_3_0_sesi::math::Transform::Transform(std::shared_ptr<openvdb::v3_3_0_sesi::math::MapBase> const&) ...even though I'm not even using a transform. Any thoughts? Edited April 11, 2017 by Kalina Quote Link to comment Share on other sites More sharing options...
Kalina Posted April 11, 2017 Author Share Posted April 11, 2017 (edited) Here is the full problematic code: SOP_Testing.C: #include "SOP_Testing.h" #include <UT/UT_DSOVersion.h> #include <OP/OP_OperatorTable.h> #include <OP/OP_AutoLockInputs.h> using namespace AVL_Testing; PRM_Template SOP_Testing::myTemplateList[] = { PRM_Template() }; void newSopOperator(OP_OperatorTable *table) { OP_Operator *op; op = new OP_Operator("avl_testing", "Testing", SOP_Testing::myConstructor, SOP_Testing::myTemplateList, 0, 0, NULL, OP_FLAG_GENERATOR ); table->addOperator(op); } OP_Node* SOP_Testing::myConstructor(OP_Network *net, const char *name, OP_Operator *op) { return new SOP_Testing(net, name, op); } SOP_Testing::SOP_Testing(OP_Network *net, const char *name, OP_Operator *op): SOP_Node(net, name, op){} SOP_Testing::~SOP_Testing() {} OP_ERROR SOP_Testing::cookMySop(OP_Context &context) { openvdb::FloatGrid::Ptr grid = openvdb::FloatGrid::create(); openvdb::FloatGrid::Accessor accessor = grid->getAccessor(); openvdb::Coord xyz(5,5,5); accessor.setValue(xyz, 1.0); xyz.reset(0,0,0); accessor.setValue(xyz, 1.0); GU_PrimVDB::buildFromGrid((GU_Detail&)*gdp, grid, NULL, "gridName"); // Crashes on this line! // Complains about openvdb::v3_3_0_sesi::math::Transform::Transform(std::shared_ptr<openvdb::v3_3_0_sesi::math::MapBase> const&) return error(); } SOP_Testing.h: #ifndef __SOP_Testing_h__ #define __SOP_Testing_h__ #include <GU/GU_PrimVDB.h> #include <SOP/SOP_Node.h> namespace AVL_Testing { class SOP_Testing : public SOP_Node { public: static OP_Node *myConstructor(OP_Network*, const char *, OP_Operator *); static PRM_Template myTemplateList[]; protected: SOP_Testing(OP_Network *net, const char *name, OP_Operator *op); virtual ~SOP_Testing(); virtual OP_ERROR cookMySop(OP_Context &context); }; } #endif Makefile: CXX=/share/apps/bin/gcc HOU_VERSION = 16.0 DSONAME = SOP_Testing.so LOCATION = ~/houdini${HOU_VERSION}/dso/ SOURCES = SOP_Testing.C include $(HFS)/toolkit/makefiles/Makefile.gnu OPTIMIZER = -g HOUDINI_DSO_ERROR = 2 CPPFLAGS += -fPIC install: mkdir -p ${LOCATION} cp ${DSONAME} ${LOCATION} Edited April 11, 2017 by Kalina Quote Link to comment Share on other sites More sharing options...
goldleaf Posted April 14, 2017 Share Posted April 14, 2017 What version of OpenVDB are you linking against, the one that ships with Houdini 16, or from Github? And there have been some HDK/OpenVDB changes in the logs; I'd try using 16.0.557 or later if you can. Quote Link to comment Share on other sites More sharing options...
Kalina Posted April 14, 2017 Author Share Posted April 14, 2017 I'm using whatever came with Houdini16. Should I be using a different one? Quote Link to comment Share on other sites More sharing options...
edward Posted April 19, 2017 Share Posted April 19, 2017 You need to compile with -DOPENVDB_3_ABI_COMPATIBLE (ie. define OPENVDB_3_ABI_COMPATIBLE) when you build your HDK plugin. This was accidentally left out of hcustom in early builds and looks like it's missing in the shipped Makefiles still. Quote Link to comment Share on other sites More sharing options...
edward Posted April 19, 2017 Share Posted April 19, 2017 Try adding this to your Makefile THIRDPARTYDEFS += -DOPENVDB_3_ABI_COMPATIBLE Quote Link to comment Share on other sites More sharing options...
Kalina Posted April 19, 2017 Author Share Posted April 19, 2017 Thanks, but that didn't help. The issue is still the same. A bit more info that may be relevant, though: I am on CentOS 6, which comes pre-packaged with gcc4.4. You may notice that my Makefile points to CXX=/share/apps/bin/gcc ...where I have gcc4.9.3, which I'm trying to use instead. Am I using the wrong gcc version, or pointing to it incorrectly? Quote Link to comment Share on other sites More sharing options...
edward Posted April 19, 2017 Share Posted April 19, 2017 H16 requires gcc 4.8 or later. To be safe I think I would try gcc 4.8 Quote Link to comment Share on other sites More sharing options...
Kalina Posted April 19, 2017 Author Share Posted April 19, 2017 (edited) OK, I'll try downgrading from 4.9.3 Edited April 19, 2017 by Kalina Quote Link to comment Share on other sites More sharing options...
Kalina Posted April 19, 2017 Author Share Posted April 19, 2017 Updating from Houdini 16.0.504.20 to 16.0.577 fixed the issue. Quote Link to comment Share on other sites More sharing options...
edward Posted April 21, 2017 Share Posted April 21, 2017 I'm pretty sure that this link error: undefined symbol: _ZN7openvdb11v3_3_0_sesi4math9TransformC1ERKSt10shared_ptrINS1_7MapBaseEE is caused by not compiling everything with -DOPENVDB_3_ABI_COMPATIBLE. One of the differences when this is defined is whether OpenVDB uses std::shared_ptr or boost::shared_ptr. 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.