OpenVDB is by Dreamworks. During Destiny we had to use OpenVDB for Maya 2014 using the code provided by OPenVDB. My job was to build the plugin successfully so that we could start using the plugin in our pipeline. It was not an easy task ,but finally I was able to compile it, it was during this project that made me learn many more amazing things on building maya plugins. I made a huge documentation on the errors that we encounter and have written the solutions too. The below text is not so organised, I will be working on making it more readable. Meanwhile I hope the information below helps someone.

 

PLUGIN BUILDING PROCESS :

 

Website link for VDB : http://www.openvdb.org/about/

You can find the paper here : http://ken.museth.org/Publications_files/Museth_TOG13.pdf

VDB means Volumteric dynamic grid developed by dreamworks Animation

It is a  novel data structure for efficiently representation of sparse, time-varying volumetric data on a 3d grid

Documentation on VDB:

http://www.openvdb.org/download/openvdb_introduction.pdf

http://www.openvdb.org/download/openvdb_toolset.pdf

All the python built libraries can be found here :

http://www.lfd.uci.edu/~gohlke/pythonlibs/#psutil

In order to build the vdb.lib file use the following link as reference

http://nidclip.wordpress.com/2014/02/25/compiling-openvdb-the-openvdb-viewer-on-windows-7/

https://groups.google.com/forum/#!topic/openvdb-forum/ZTEbIAk9kdc

And then use this to build the maya plugin as reference :

http://vimeo.com/73294767

Whiole building in debug mode and when using Joe kider tutorial , for debug build I had a error to solve it go to properties , c/C++ settings , command line  and put this /bigobj     . Thats it ,it will compile.

While building Ilmbase for debug 64 bit build , turn off incremental build to NO.

$r = rand(-0.0001,0.0001);

particle2.translateX = (noise(time)/5) + $r

_HAS_ITERATOR_DEBUGGING=0

/FORCE:MULTIPLE

————————————————————————————————————————————————————————

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Yes, I will be glad to share all the details of the problem.

These are the steps I followed in order to get the OpenVDB.mll file for Maya 2014 .

1)Initially I had to build the openVDB.lib file, so I followed the below 2 sources to get the openvdb.lib

  http://nidclip.wordpress.com/2014/02/25/compiling-openvdb-the-openvdb-viewer-on-windows-7/

https://groups.google.com/forum/#!topic/openvdb-forum/ZTEbIAk9kdc

2)Then I created a new Visual studio project using Maya plugin wizard 2014 and I added the necessary libraries, dependencies and Pre processor directives to remove all possible in errors while compiling and linking. I successfully got the .mll file for Maya. But when I load into Maya, it gives the following error .

// Error: Unable to dynamically load : C:/Users/vivek.reddy/Desktop/OpenVDB April/MayaPluginWizard1/MayaPluginWizard1/Debug/MayaPluginWizard1.mll

//

# Error: pymel : Failed to get controlCommand list from MayaPluginWizard1 #

# Error: pymel : Failed to get modelEditorCommand list from MayaPluginWizard1 #

# Error: pymel : Failed to get command list from MayaPluginWizard1 #

# Error: pymel : Failed to get constraintCommand list from MayaPluginWizard1 #

# Error: pymel.core : Failed to get depend nodes list from MayaPluginWizard1 #

// Error:  (MayaPluginWizard1) //

Here is the .mll file that I have built https://drive.google.com/file/d/0B9MGB8LphVjrWW9od0pvS21nYXc/edit?usp=sharing

3) In order to debug it by endlessly searching on the internet, I found out that I need to use common settings when I do my builds using visual studio. So, I downloaded all the source code for tbb,zlib,openexr and boost. I compiled everything in Debug , 64-bit, Multi Threaded Debug.  Including while I compiled my openVDB.lib.

4)When I started my visual studio project, the Maya plugin wizard had set the code generation to the default               “Multi threaded Debug DLL” ,  I changed it to “Multi threaded Debug” as I was never able to compile it in that mode. It was said in most forums to keep the same settings in all the dependencies, which is what I did.

5)The error I get in Maya was not showing anything more than what I have pasted above, I assumed that since I have built only static libraries, the openVDB plugin is trying to access some Microsoft DLL files and tried to download some service packs as mentioned in these forums :

http://forums.cgsociety.org/archive/index.php/t-1055408.html

http://forums.cgsociety.org/showthread.php?t=1042546

But again it did not work.

6)In order to avoid the multiple redefinition errors I added FORCE:MULTIPLE in the linker command line. And I added the following pre- processor directives while building the .mll file :

WIN32

_DEBUG

_WINDOWS

_AFXDLL

_MBCS

NT_PLUGIN

REQUIRE_IOSTREAM

Bits64_

_BOOL

NOMINMAX

ZLIB_DLL

_USRDLL

And the following additional libraries :

odbc32.lib

odbccp32.lib

Foundation.lib

OpenMaya.lib

OpenMayaUI.lib

OpenMayaFX.lib

zlibstat.lib

Half.lib

tbb_debug.lib

openVDB.lib

glew32.lib

glew32s.lib

OpenGL32.Lib

libboost_iostreams-vc100-sgd-1_55.lib

WS2_32.Lib

I find it very sad of me not able to build it successfully and am not able to figure out what I might be doing wrong. Hopefully all the above information would be helpful for you to see my mistakes.

Thank you

odbc32.lib

odbccp32.lib

Foundation.lib

OpenMaya.lib

OpenMayaUI.lib

OpenMayaFX.lib

zlibstat.lib

Half.lib

tbb_debug.lib

openVDB.lib

glew32.lib

glew32s.lib

OpenGL32.Lib

libboost_iostreams-vc100-sgd-1_55.lib

WS2_32.Lib

SONY VERSION

_DEBUG

WIN32

_WINDOWS

NT_PLUGIN

NOMINMAX

_USRDLL

REQUIRE_IOSTREAM

Bits64_

_HAS_ITERATOR_DEBUGGING=0

_SECURE_SCL=0

_SECURE_SCL_THROWS=0

_SECURE_SCL_DEPRECATE=0

_CRT_SECURE_NO_DEPRECATE

TBB_USE_DEBUG=0

__TBB_LIB_NAME=tbb.lib

AW_NEW_IOSTREAMS

VDB version

WIN32

_DEBUG

_WINDOWS

NT_PLUGIN

NOMINMAX

_USRDLL

REQUIRE_IOSTREAM

Bits64_

_AFXDLL

_MBCS

_BOOL

ZLIB_DLL

VDB version untouched

WIN32

_DEBUG

_WINDOWS

_AFXDLL

_MBCS

NT_PLUGIN

REQUIRE_IOSTREAM

Bits64_

_BOOL

NOMINMAX

ZLIB_DLL

_USRDLL

/bigobj

I have removed these for testing

_AFXDLL

_MBCS

_BOOL

ZLIB_DLL

This si the issue in the OpenVDB plugin

http://forums.cgsociety.org/archive/index.php/t-480346.html

_HAS_ITERATOR_DEBUGGING=0

http://around-the-corner.typepad.com/adn/visual-studio/

#define MNoPluginEntry is the key turning point

/export:initializePlugin /export:uninitializePlugin

glew32.lib

glew32s.lib

$(ProjectDir)\all_dependecies\glew-1.10.0\lib\Release\x64

createNode OpenVDBVisualize;

this helped a lot in http://stackoverflow.com/questions/12329082/glcreateshader-is-crashing

There are 5 main issues in this Plugin right now

1) In initializePlugin   , openvdb::initialize()  is not working .

2)In OpenVDBFilterNode.cc

filterGrid function has all the filter.mean , filter.gaussian are all commented out.

3)In OpenVDBMayaFluidNode.cc

Under copyGrid function all the openvdb statements are commented out

4)In OpenVDBFromPolygonNode.cc

Majority of the statements in compute function are commented

5)In OpenVDBVisualizeNode.cc

mvdb::processTypedGrid has errors in the chain

Inside OpenVDBUtil.h there is a issue with Grid Processor

op.operator()<GridType>(openvdb::gridConstPtrCast<GridType>(grid));  — Line with issue

Some of the things considered step by step in order to solve the issues : 

First and foremost install glew32.dll properly, all the files inside glew should go to

Appropriate Places. http://glew.sourceforge.net/install.html

1)In order to remove the DLLMain redfnition errors in OpenVDbPlugin.h I added

#define MNoPluginEntry

2)In OpenVDBPlugin.cc, I have commnentd in the NodeRegistry constructor

Lock lock(sRegistryMutex); — This enabled to load the Plugin

3)In openVDBVisualizeNode.cc to remove the glew errors go to

OpenVDBVisualizeNode()  and in the function mSurfaceShader.setVertShader I have added

GLenum err= glewInit();

these were the pre-processor directives in VS 2010

WIN32
_DEBUG
_WINDOWS
_AFXDLL
_MBCS
NT_PLUGIN
REQUIRE_IOSTREAM
Bits64_
_BOOL
NOMINMAX
ZLIB_DLL
_USRDLL

these were the library dependencies in VS2010

odbc32.lib
odbccp32.lib
Foundation.lib
OpenMaya.lib
OpenMayaUI.lib
OpenMayaFX.lib
zlibstat.lib

Half.lib
tbb_debug.lib
openVDB.lib
glew32.lib
OpenGL32.Lib
libboost_iostreams-vc100-sgd-1_55.lib
WS2_32.Lib

..\..\boost_1_55_0\boost_1_55_0

C:\Local\boost_1_55_0\lib64-msvc-10.0

libboost_iostreams-vc100-sgd-1_55.lib

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\x64

Changes that I did and experimented with, Notes to guide you :

1) Openvdb::Initialize() linker error is now solved, I was so stupid to not include openVDB.h and openVDB.cc files in the OpenVDB build that I did. Initially the openVDB.lb

file was just 33mb and then when I added all the appropriate headers it became 96mb. And then in my Maya project I did not get any linker errors. Linker was happy to

find the function it was searching for 🙂 🙂

2) But even though the linker did not complain. Maya was unhappy with the openVDB::Initialize() function. Whenever I had this function in the code, it was erroring, and when

it was commented the .mll was able to be imported.

3)Here is another strange observation, when I had openVDB::initialize() in the code, the file size was 2.4mb , But when I commented out this line , it came to 3.6mb, is that not

weird ? When I comment a line, should the size not decrease ? But in this case it is increasing.

4)Thinking that all these problems are pointing to boost. Initially I was only using the boost headers, so I thought I will compile the Boost libraries also using this tutorial ,But

unfortunately even though I added all the libraries in my code. I could not stop all these errors.

https://www.youtube.com/watch?v=5AmwIwedTCM

5)Finally I did use dependency walker on the .mll file that was generated. The funny part is that it said it could not find any of the files that were in the dependency, and complained a

lot of necessary DLL’s were 32-bit. I really have made sure , everything that I built was debug 64-bit and all of it compiled. It does not make sense the way it is complaining.

Alright here it is, TBB is the one causing all the issues.Some notes regrading what I found :

– I was using tbb 4.2.2 the latest version, I realized that I should be using Maya TBB include files as it might sync with what Maya wants , but unfortunately that did not help at all.

– How did I find it was TBB , since openVDB::Initialize() was not working in Maya and this function was in the lib file I had generated, I went in to the openVDB build that I was doing and inspected the initialize function in it

It had the following code

Lock lock(sInitMutex);

if (sIsInitialized) return;

// Register metadata.

Metadata::clearRegistry();

BoolMetadata::registerType();

DoubleMetadata::registerType();

FloatMetadata::registerType();

Int32Metadata::registerType();

Int64Metadata::registerType();

StringMetadata::registerType();

Vec2IMetadata::registerType();

Vec2SMetadata::registerType();

Vec2DMetadata::registerType();

Vec3IMetadata::registerType();

Vec3SMetadata::registerType();

Vec3DMetadata::registerType();

Mat4SMetadata::registerType();

Mat4DMetadata::registerType();

// Register maps

math::MapRegistry::clear();

math::AffineMap::registerMap();

math::UnitaryMap::registerMap();

math::ScaleMap::registerMap();

math::UniformScaleMap::registerMap();

math::TranslationMap::registerMap();

math::ScaleTranslateMap::registerMap();

math::UniformScaleTranslateMap::registerMap();

math::NonlinearFrustumMap::registerMap();

// Register common grid types.

GridBase::clearRegistry();

BoolGrid::registerGrid();

  FloatGrid::registerGrid();            —— PROBLEM STARTS ON THIS LINE

// DoubleGrid::registerGrid();

//Int32Grid::registerGrid();

//Int64Grid::registerGrid();

//HermiteGrid::registerGrid();

//StringGrid::registerGrid();

//Vec3IGrid::registerGrid();

//Vec3SGrid::registerGrid();

//Vec3DGrid::registerGrid();

So , when I was checking the line that throws errors, its exactly when it calls  FloatGrid::registerGrid();      that Maya does not like it. I went into the function call and checked to what it calls , it has couple of functions which both have TBB code in it,  well when I comment the code in it ofcourse it works. So whats the point in it ????  I have included TBB files of Maya 2014 and still something is screwing up. The fact that  BoolGrid::registerGrid(); is working makes it hard to know what might be going wrong inside.

errors—–

http://forums.autodesk.com/t5/Programming/Can-t-load-my-Plug-In-quot-The-specified-procedure-could-not-be/td-p/4270537

http://tech-artists.org/forum/showthread.php?2924-trouble-with-maya-2013-and-python-image-library

https://code.google.com/p/coral-repo/wiki/build_coralMaya

http://www.creativecrash.com/forums/api/topics/maya-and-boost

http://lists.boost.org/boost-users/2007/04/27162.php

]