It is currently Sat Aug 22, 2020 1:05 pm


All times are UTC




Post new topic Reply to topic  [ 54 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject: Re: PolyVox compilation error
PostPosted: Wed Jan 05, 2011 10:54 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Yep, I hope so. I've not done much beyond C++ myself (a little C# and a little Java), but when I was playing with these bindings I was using ipython and could definitely see the appeal :-)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: PolyVox compilation error
PostPosted: Thu Jan 06, 2011 9:57 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
@Matt - Regarding that Linux compilation error you just mentioned in the SVN log (the conflict with XOrg Region) this was actually some code I commited by accident. I was just testing the MeshDecimator. I've reverted some stuff and it should all be fine again now...


Top
Offline Profile  
Reply with quote  
 Post subject: Re: PolyVox compilation error
PostPosted: Sat Jan 15, 2011 3:54 pm 

Joined: Sat Jan 15, 2011 3:49 pm
Posts: 38
I was just browsing to see if anyone has tried to use PolyVox with C#, I guess it has to wait for more stuff to get SWIG bindings. I just built the code and began looking into what would be required to manually p/invoke it, but then I saw all the template stuff in the headers and decided to check the forums instead, heh. Really looking forward to playing around with the library in XNA :>


Last edited by ape on Sat Jan 15, 2011 9:07 pm, edited 1 time in total.

Top
Offline Profile  
Reply with quote  
 Post subject: Re: PolyVox compilation error
PostPosted: Sat Jan 15, 2011 5:27 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Yeah, the existing SWIG bindings should work for C# as they do for Python, but currently all you can do is create/modify a volume as I haven't exposed the surface extractors. I'm not actively working on these bindings as I don't currently have a use for them myself, but will support any efforts to expand them to cover other PolyVox classes.

The heavy use of templates does make it a little more complex, but SWIG does a pretty good job of handling this. For the general Volume<Type> class in C++, SWIG generates a MaterialVolume, DensityVolume, etc for each input type which you specify. You can then just use them as normal.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: PolyVox compilation error
PostPosted: Sun Jan 16, 2011 9:36 am 

Joined: Sat Jan 15, 2011 3:49 pm
Posts: 38
I started looking into what I have to do to build the current swig bindings with a C# target and apparently CMake doesn't even support C#. Great :(
Apparently KDE uses a patched version with minimal support, not sure if I can use that yet. Maybe there is some way to use swig manually without cmake?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: PolyVox language bindings
PostPosted: Sun Jan 16, 2011 11:02 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
I'm assuming you are looking at this link:

http://www.paraview.org/Wiki/CMake_FAQ# ... braries.3F

And particularly the comment:
Quote:
# This example shows how to use python
# Currently these languages have been tested:
# perl tcl ruby php4 pike


Which does imply that C# may not work. However, if you look on the 'PolyVox\trunk\library\bindings' you can see the various '*.i' files which we've made - even without CMake it should be possible to call SWIG directly and pass it 'PolyVoxCore.i'(you'll have to look at the SWIG docs).

There is no need to use CMake to build your own C# project. I think the idea would be that SWIG generates the C# assemblies from the C++ code, and then you can just drop them into your Visual Studio project as you would normally. CMake is just used as a way of calling SWIG, but you can do this step manually if you prefer.

I assume you are working on Windows? [edit:] Sorry, of course you are, you mentioned XNA.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: PolyVox language bindings
PostPosted: Sun Jan 16, 2011 1:47 pm 

Joined: Sat Jan 15, 2011 3:49 pm
Posts: 38
Yeah, I'm working with visual studio 2010 on windows 7. I managed to get some .cs classes generated and a PolyVoxCore_wrap.cxx to include in the dll by using
Code:
swig -csharp -c++ -I../PolyVoxCore/include PolyVoxCore.i

There are a few warnings e.g.
Quote:
../PolyVoxCore/include\Density.h(69) : Warning 503: Can't wrap 'operator <' unless renamed to a valid identifier.
../PolyVoxCore/include\Vector.h(78) : Warning 503: Can't wrap 'operator =' unless renamed to a valid identifier.
../PolyVoxCore/include\Vector.h(80) : Warning 503: Can't wrap 'operator ==' unless renamed to a valid identifier.
../PolyVoxCore/include\Vector.h(82) : Warning 503: Can't wrap 'operator <' unless renamed to a valid identifier.

Hopefully the proxy classes will still work, going to try it out in a few min. If it works I'll try making some more .i files for the mesh generation classes so I can get some actual stuff rendering in xna :)

edit:
Apparently I have to rename all these operators or something
Quote:
(iii) SWIG will no longer wrap a declaration if its symbol
table name contains illegal identifier characters. If
illegal characters are detected, you will see an error
like this:

Warning. Can't wrap operator* unless renamed to a valid identifier.

The only way to fix this is to use %rename or %name to bind
the operator to a nice name like "add" or something. Note:
the legal identifier characters are determined by the target
language.


edit2: Okay, got it generating the proxies with no warnings. I haven't tested it yet in c# but here is the modified PolyVoxCore.i:
Code:
%module PolyVoxCore

#define POLYVOX_API

%rename(equals) operator==;
%rename(notEqualTo) operator!=;
%rename(lessThan) operator<;
%rename(greaterThan) operator>;
%rename(lessThanOrEqual) operator<=;
%rename(greaterThanOrEqual) operator>=;
%rename(assignment) operator=;
%rename(additionAssignment) operator+=;
%rename(subtractionAssignment) operator-=;
%rename(multiplicationAssignment) operator*=;
%rename(divisionAssignment) operator/=;

%include "stdint.i"
%include "Material.i"
%include "Density.i"
%include "Vector.i"
%include "Region.i"
%include "Volume.i"


edit3: Got interfaces made for SurfaceMesh and SurfaceExtractor, but I'm having trouble with VertexTypes because it doesn't know what POLYVOXCORE_API is.
Quote:
../PolyVoxCore/include\VertexTypes.h(35) : Error: Syntax error in input(1).


Top
Offline Profile  
Reply with quote  
 Post subject: Re: PolyVox language bindings
PostPosted: Sun Jan 16, 2011 3:18 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Wow, you're on fire :-)

The 'POLYVOXCORE_API' thing is a bit of a pain, but this is what I did for the Region class:

Code:
#ifdef SWIG
   class Region
#else
   class POLYVOXCORE_API Region
#endif


You may well find that trick can be useful elsewhere as well.

I'm a little suprised you managed to go straight to the SurfaceExtractor as I was expecting you would need to do a few others (VolumeSampler, Array, etc) first as these are used internally by the surface extractor. But I guess the fact that it is internal use means they don't have to be wrapped.

Anyway, excellent work!


Top
Offline Profile  
Reply with quote  
 Post subject: Re: PolyVox language bindings
PostPosted: Sun Jan 16, 2011 3:46 pm 

Joined: Sat Jan 15, 2011 3:49 pm
Posts: 38
Thanks for the quick reply, your solution worked like a charm!
I did generate an interface for volumesampler I just forgot to list it in my post.
Swig is no longer erroring, but there are plenty of build errors in PolyVoxCore when I try to use its generated wrapping class, I'm going to start going through them now.
I can't seem to find a definition for isOnGeometryEdge anywhere.

Quote:
Error 4 error C2039: 'isOnGeometryEdge' : is not a member of 'PolyVox::PositionMaterial' include\SurfaceMesh.inl 222 1 PolyVoxCore
Error 34 error C2039: 'isOnGeometryEdge' : is not a member of 'PolyVox::PositionMaterialNormal' include\SurfaceMesh.inl 222 1 PolyVoxCore
Error 8 error C2039: 'setNormal' : is not a member of 'PolyVox::PositionMaterial' include\SurfaceMesh.inl 275 1 PolyVoxCore
Error 1 error C2440: 'initializing' : cannot convert from 'PolyVox::PositionMaterial' to 'PolyVox::PositionMaterialNormal &' include\SurfaceMesh.inl 179 1 PolyVoxCore
Error 2 error C2440: 'initializing' : cannot convert from 'PolyVox::PositionMaterial' to 'PolyVox::PositionMaterialNormal &' include\SurfaceMesh.inl 182 1 PolyVoxCore
Error 3 error C2440: 'initializing' : cannot convert from 'PolyVox::PositionMaterial' to 'PolyVox::PositionMaterialNormal &' include\SurfaceMesh.inl 185 1 PolyVoxCore
Error 5 error C2440: 'initializing' : cannot convert from 'PolyVox::PositionMaterial' to 'PolyVox::PositionMaterialNormal &' include\SurfaceMesh.inl 252 1 PolyVoxCore
Error 6 error C2440: 'initializing' : cannot convert from 'PolyVox::PositionMaterial' to 'PolyVox::PositionMaterialNormal &' include\SurfaceMesh.inl 255 1 PolyVoxCore
Error 7 error C2440: 'initializing' : cannot convert from 'PolyVox::PositionMaterial' to 'PolyVox::PositionMaterialNormal &' include\SurfaceMesh.inl 258 1 PolyVoxCore
Error 9 error C2440: 'initializing' : cannot convert from 'PolyVox::PositionMaterial' to 'PolyVox::PositionMaterialNormal &' include\SurfaceMesh.inl 352 1 PolyVoxCore
Error 10 error C2440: 'initializing' : cannot convert from 'PolyVox::PositionMaterial' to 'PolyVox::PositionMaterialNormal &' include\SurfaceMesh.inl 353 1 PolyVoxCore
Error 11 error C2440: 'initializing' : cannot convert from 'PolyVox::PositionMaterial' to 'PolyVox::PositionMaterialNormal &' include\SurfaceMesh.inl 354 1 PolyVoxCore
Error 21 error C2440: 'initializing' : cannot convert from 'PolyVox::PositionMaterial' to 'PolyVox::PositionMaterialNormal &' include\SurfaceMesh.inl 295 1 PolyVoxCore
Error 22 error C2440: 'initializing' : cannot convert from 'PolyVox::PositionMaterial' to 'PolyVox::PositionMaterialNormal &' include\SurfaceMesh.inl 297 1 PolyVoxCore
Error 23 error C2440: 'initializing' : cannot convert from 'PolyVox::PositionMaterial' to 'PolyVox::PositionMaterialNormal &' include\SurfaceMesh.inl 299 1 PolyVoxCore
Error 18 error C2440: 'initializing' : cannot convert from 'std::_Vector_iterator<_Myvec>' to 'std::_Vector_iterator<_Myvec>' include\SurfaceMesh.inl 285 1 PolyVoxCore
Error 27 error C2440: 'initializing' : cannot convert from 'std::_Vector_iterator<_Myvec>' to 'std::_Vector_iterator<_Myvec>' include\SurfaceMesh.inl 320 1 PolyVoxCore
Error 15 error C2664: 'PolyVox::SurfaceMesh<VertexType>::addVertex' : cannot convert parameter 1 from 'PolyVox::PositionMaterialNormal' to 'const PolyVox::PositionMaterial &' include\SurfaceMesh.inl 364 1 PolyVoxCore
Error 16 error C2664: 'PolyVox::SurfaceMesh<VertexType>::addVertex' : cannot convert parameter 1 from 'PolyVox::PositionMaterialNormal' to 'const PolyVox::PositionMaterial &' include\SurfaceMesh.inl 371 1 PolyVoxCore
Error 17 error C2664: 'PolyVox::SurfaceMesh<VertexType>::addVertex' : cannot convert parameter 1 from 'PolyVox::PositionMaterialNormal' to 'const PolyVox::PositionMaterial &' include\SurfaceMesh.inl 378 1 PolyVoxCore
Error 19 error C2678: binary '!=' : no operator found which takes a left-hand operand of type 'std::_Vector_iterator<_Myvec>' (or there is no acceptable conversion) include\SurfaceMesh.inl 285 1 PolyVoxCore
Error 28 error C2678: binary '!=' : no operator found which takes a left-hand operand of type 'std::_Vector_iterator<_Myvec>' (or there is no acceptable conversion) include\SurfaceMesh.inl 320 1 PolyVoxCore
Warning 29 warning C4018: '<' : signed/unsigned mismatch include\SurfaceMesh.inl 439 1 PolyVoxCore
Warning 30 warning C4018: '<' : signed/unsigned mismatch include\SurfaceMesh.inl 461 1 PolyVoxCore
Warning 31 warning C4018: '<' : signed/unsigned mismatch include\SurfaceMesh.inl 492 1 PolyVoxCore
Warning 32 warning C4018: '<' : signed/unsigned mismatch include\SurfaceMesh.inl 500 1 PolyVoxCore
Warning 33 warning C4018: '<' : signed/unsigned mismatch include\SurfaceMesh.inl 512 1 PolyVoxCore
Warning 42 warning C4018: '<' : signed/unsigned mismatch include\SurfaceMesh.inl 439 1 PolyVoxCore
Warning 43 warning C4018: '<' : signed/unsigned mismatch include\SurfaceMesh.inl 461 1 PolyVoxCore
Warning 44 warning C4018: '<' : signed/unsigned mismatch include\SurfaceMesh.inl 492 1 PolyVoxCore
Warning 45 warning C4018: '<' : signed/unsigned mismatch include\SurfaceMesh.inl 500 1 PolyVoxCore
Warning 46 warning C4018: '<' : signed/unsigned mismatch include\SurfaceMesh.inl 512 1 PolyVoxCore
Warning 47 warning C4244: '=' : conversion from 'float' to 'int16_t', possible loss of data include\Vector.inl 109 1 PolyVoxCore
Warning 48 warning C4244: '=' : conversion from 'float' to 'int32_t', possible loss of data include\Vector.inl 109 1 PolyVoxCore
Warning 12 warning C4244: 'argument' : conversion from 'float' to 'const unsigned char', possible loss of data include\SurfaceMesh.inl 357 1 PolyVoxCore
Warning 13 warning C4244: 'argument' : conversion from 'float' to 'const unsigned char', possible loss of data include\SurfaceMesh.inl 358 1 PolyVoxCore
Warning 14 warning C4244: 'argument' : conversion from 'float' to 'const unsigned char', possible loss of data include\SurfaceMesh.inl 359 1 PolyVoxCore
Warning 35 warning C4244: 'argument' : conversion from 'float' to 'const unsigned char', possible loss of data include\SurfaceMesh.inl 357 1 PolyVoxCore
Warning 36 warning C4244: 'argument' : conversion from 'float' to 'const unsigned char', possible loss of data include\SurfaceMesh.inl 358 1 PolyVoxCore
Warning 37 warning C4244: 'argument' : conversion from 'float' to 'const unsigned char', possible loss of data include\SurfaceMesh.inl 359 1 PolyVoxCore
Warning 20 warning C4305: 'argument' : truncation from 'double' to 'float' include\SurfaceMesh.inl 287 1 PolyVoxCore
Warning 24 warning C4305: 'argument' : truncation from 'double' to 'float' include\SurfaceMesh.inl 304 1 PolyVoxCore
Warning 25 warning C4305: 'argument' : truncation from 'double' to 'float' include\SurfaceMesh.inl 308 1 PolyVoxCore
Warning 26 warning C4305: 'argument' : truncation from 'double' to 'float' include\SurfaceMesh.inl 312 1 PolyVoxCore
Warning 38 warning C4305: 'argument' : truncation from 'double' to 'float' include\SurfaceMesh.inl 287 1 PolyVoxCore
Warning 39 warning C4305: 'argument' : truncation from 'double' to 'float' include\SurfaceMesh.inl 304 1 PolyVoxCore
Warning 40 warning C4305: 'argument' : truncation from 'double' to 'float' include\SurfaceMesh.inl 308 1 PolyVoxCore
Warning 41 warning C4305: 'argument' : truncation from 'double' to 'float' include\SurfaceMesh.inl 312 1 PolyVoxCore



Top
Offline Profile  
Reply with quote  
 Post subject: Re: PolyVox language bindings
PostPosted: Sun Jan 16, 2011 4:12 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Ok, now it gets a a little interesting. The first error is about 'isOnGeometryEdge' which if you search the code you'll see it isn't defined anywhere. I thought I removed all references to that a few weeks ago.

The point is, when using templated code in C++ it is often not compiled unless it is actually being called (I'm a little hazy on the exact rules regarding this). So there may be parts of the code which simply don't compile for this kind of reason, but which haven't been noticed.

When making bindings, on the otherhand, it seems that SWIG compiles everything. In the case of 'isOnGeometryEdge' I'd probably just delete the whole 'smoothPositions' function which it is part of. That function shouldn't be necessary now that smooth terrains can be created using a continuous density function, but that said I'm not sure if other people are still using it for some reason.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 54 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net