I want to create a walkthrough on how to create C# Bindings and then use PolyVox in a SunBurn/XNA graphics engine to render.
I had a little bit of a head start by checking out "Painect" which is a Kinect driven demo that uses PolyVox to render voxel generated art from what I suspect.
Alas, the project is old and no longer functions with the latest Kinect SDK. I was able to compile and run the project, however, I was unable to get it working properly. Once i finally gave up on it after having updated all the Kinect code and still not getting results, I decided to take what I found from that project, including it's PolyVox C# library that they already had included. At first it seemed to work well enough, but then I started running across odd error when using the SetSphereAt(0,0,0,12) in an attempt to generate some voxel data to be drawn.
This produced an unusual error:
Unable to find an entry point named '?' in DLL 'PolyVoxCore'.
Which is odd, because of the entry point '?' part mostly... So I'm not sure if this library is any good. I dont want to start with a faulty library. So I decided to get started using the real source code. I have tried both 0.2.1 and the GIT version.
I cannot produce CSharp libraries from either. Both have the same problem from what i can see. First off, I am able to run cmake, detects everything, everything turned on. Great.
Open the PolyVox.sln and build all (release) and I get three errors on three test/example projects:
error C2064: term does not evaluate to a function taking 2 arguments
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xrefwrap
This occures in the following projects:
OpenGLExample
TestAStarPathfinder
testvolume
However, i'm sure these are of no consequence. So I unload these and build all again, and all build successfully.
Now, I go to the next, step, where is the CSharp code? Where are the bindings we build? So I check out the folder: C:\polyvox\library\bindings
There are 2 batch files:
CleanCSharpBindings.bat
MakeCSharpBindings.bat
So this seems easy! Great, I run the "MakeCSharpBindings.bat" and the following output occurs:
C:\polyvox\library\bindings>swig -csharp -namespace PolyVoxCore -c++ -I../PolyVoxCore/include PolyVoxCore.i
PolyVoxCore.i(4) : Error: Unable to find 'Impl\TypeDef.h'
Vector.i(7) : Error: Unable to find 'Vector.h'
DefaultMarchingCubesController.i(6) : Error: Unable to find 'DefaultMarchingCube
sController.h'
Density.i(6) : Error: Unable to find 'MarchingCubesSurfaceExtractor.h'
Density.i(7) : Error: Unable to find 'Density.h'
Material.i(6) : Error: Unable to find 'DefaultIsQuadNeeded.h'
Material.i(7) : Error: Unable to find 'Material.h'
MaterialDensityPair.i(6) : Error: Unable to find 'MaterialDensityPair.h'
Region.i(12) : Error: Unable to find 'Region.h'
SimpleVolume.i(8) : Error: Unable to find 'BaseVolume.h'
SimpleVolume.i(9) : Error: Unable to find 'Material.h'
SimpleVolume.i(10) : Error: Unable to find 'Density.h'
SimpleVolume.i(11) : Error: Unable to find 'SimpleVolume.h'
VertexTypes.i(8) : Error: Unable to find 'Impl\TypeDef.h'
VertexTypes.i(9) : Error: Unable to find 'Vector.h'
VertexTypes.i(10) : Error: Unable to find 'VertexTypes.h'
SurfaceMesh.i(8) : Error: Unable to find 'Region.h'
SurfaceMesh.i(9) : Error: Unable to find 'VertexTypes.h'
SurfaceMesh.i(10) : Error: Unable to find 'SurfaceMesh.h'
MarchingCubesSurfaceExtractor.i(8) : Error: Unable to find 'SimpleVolume.h'
MarchingCubesSurfaceExtractor.i(9) : Error: Unable to find 'MarchingCubesSurfaceExtractor.h'
So I'm a bit confused now. I start looking around in the other folders, I see that there are folders:
C:\polyvox\library\PolyVoxCore
C:\polyvox\library\PolyVoxUtil
and inside these, there are include and source folders. The include folders have nothing in them but more folders:
C:\polyvox\library\PolyVoxCore\include\PolyVoxCore
C:\polyvox\library\PolyVoxUtil\include\PolyVoxUtil
so that's bizzare again. It's almost as if all the files are in the wrong place! I tried moving the files down one into the "include" folders, but that did not help, it only changed the output of the MakeCSharpBindings to be even more cryptic:
Vector.i(9) : Error: Syntax error in input(3).
So I checked out Vector.i's line 9 and at this point I'm in really uncharted waters because I know nothing about this SWIG thing that does these .i files and their syntax.
So now, I'm not sure how to proceed from here. There was a page on the internet (
http://tepidpond.com/polyvox-for-csharp/) that detailed the steps to produce the wrappers, but it's instructions fail and they never go over actually creating the CS stuff with the MakeCSharpBindings.bat file.
Which says that after having build I need to:
cd library\bindings
csc.exe /target:library /out:PolyVoxCoreActualCSharp.dll PolyVoxCorePINVOKE.cs Vector3Duint32_t.cs Region.cs SimpleVolumeuint8.cs SurfaceMeshPositionMaterialNormal.cs MarchingCubesSurfaceExtractorSimpleVolumeuint8.cs Vector3Dint32_t.cs BaseVolumeuint8.cs Vector3Dfloat.cs WrapMode.cs uint32Vector.cs PositionMaterialNormalVector.cs LodRecordVector.cs SWIGTYPE_p_PolyVox__DefaultMarchingCubesControllerT_unsigned_char_t.cs PositionMaterialNormal.cs LodRecord.cs
But of course this fails, because the folder they brought me to, does not have any of the files mentioned above. I assume thats what "MakeCSharpBindings.bat" is supposed to do, but something is not aligned correctly... I'll keep trying to figure this out if noone answers my post, but I was hoping at least someone could assist me a little bit.
I think in the end, I will make sure that I create a nice complete walkthrough on using the polyvox library in the way I want to use it, and it will make more clear for others who want to use it this way.