Volumes Of Fun
http://www.volumesoffun.com/phpBB3/

PolyVox language bindings
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=2&t=118
Page 5 of 6

Author:  ape [ Mon Jan 17, 2011 12:09 am ]
Post subject:  Re: PolyVox language bindings

Ah. I just tried
Code:
GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;

in my draw routine but it still draws backwards if I don't reverse the indices :(

Author:  ape [ Mon Jan 17, 2011 1:17 am ]
Post subject:  Re: PolyVox language bindings

I got some simple perlin noise terrain working, the current annoyance is an overflow in the xna batch drawing code when i give it a large number of vertices at once (eg the result of a 64^3 volume surface extraction with holes in it). Hard to believe that generated enough vertices for int32.maxvalue. The mesh simplification stuff is definitely the next thing I want to make a wrapper for :P

http://dl.dropbox.com/u/6281166/voxelxna6.jpg

Author:  ape [ Mon Jan 17, 2011 4:07 pm ]
Post subject:  Re: PolyVox language bindings

Still having annoying issues with zfighting when I rotate to the back of the mesh :(. Also, for some reason volumedensity8 is giving me a SEH exception when i try to make any cubic volume less than 32 (eg 16x16x16). Any idea as to why?

edit: fixed zfighting, still haven't figured out the small volume exception, yet.

Author:  ape [ Mon Jan 17, 2011 5:14 pm ]
Post subject:  Re: PolyVox language bindings

Here's a release build of what I have done so far if anyone wants to play around with it:
http://dl.dropbox.com/u/6281166/GameClientRelease.rar
:P

Author:  David Williams [ Mon Jan 17, 2011 7:22 pm ]
Post subject:  Re: PolyVox language bindings

Right, sorry, I've been at work all day so had no chance to post...

ape wrote:
Ah. I just tried
Code:
GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;

in my draw routine but it still draws backwards if I don't reverse the indices :(


I know nothing of XNA, but I'll just point out you appear to be applying the proprty to 'RasterizerState', where as the snippet I posted before assigned to 'RasterizerState.CullMode'.

If you really do need to reverse the winding, then I expect it will be quicker to iterate over the array and swap the 2nd and 3rd index of each triangle, rather than reverse the whole index list.

ape wrote:
...the current annoyance is an overflow in the xna batch drawing code when i give it a large number of vertices at once (eg the result of a 64^3 volume surface extraction with holes in it). Hard to believe that generated enough vertices for int32.maxvalue.


Just to be clear, are you saying it's overflowing past int32.maxvalue? I.e. more than four billion vertices? Because that can't be right. Or you just mean it's working with 32 bits but you wanted to use 16 bits?

ape wrote:
Also, for some reason volumedensity8 is giving me a SEH exception when i try to make any cubic volume less than 32 (eg 16x16x16). Any idea as to why?


Internally the volume is stored as a series of blocks, and a volume cannot be smaller than the block size. But default the block size is 32, which is specified as a default parameter in the Volume constructor:

Code:
///Constructor
Volume(uint16_t uWidth, uint16_t uHeight, uint16_t uDepth, uint16_t uBlockSideLength = 32);


You'll need to check how this default parameter is exposed by SWIG, maybe your C# Volume has more than one constructor available or something?

I'll just note that if you are trying to make small volumes so you can tile them together, then that won't work. I can elaborate if that's what you were going to do. If not, carry on ;-)

Anyway, it looks like you've been making more great progress :-) I'll try your demo in a bit.

Author:  David Williams [ Mon Jan 17, 2011 7:23 pm ]
Post subject:  Re: PolyVox language bindings

Right, sorry, I've been at work all day so had no chance to post...
ape wrote:
Ah. I just tried
Code:
GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;

in my draw routine but it still draws backwards if I don't reverse the indices :(

I know nothing of XNA, but I'll just point out you appear to be applying the proprty to 'RasterizerState', where as the snippet I posted before assigned to 'RasterizerState.CullMode'.

If you really do need to reverse the winding, then I expect it will be quicker to iterate over the array and swap the 2nd and 3rd index of each triangle, rather than reverse the whole index list.
ape wrote:
...the current annoyance is an overflow in the xna batch drawing code when i give it a large number of vertices at once (eg the result of a 64^3 volume surface extraction with holes in it). Hard to believe that generated enough vertices for int32.maxvalue.

Just to be clear, are you saying it's overflowing past int32.maxvalue? I.e. more than four billion vertices? Because that can't be right. Or you just mean it's working with 32 bits but you wanted to use 16 bits?
ape wrote:
Also, for some reason volumedensity8 is giving me a SEH exception when i try to make any cubic volume less than 32 (eg 16x16x16). Any idea as to why?


Internally the volume is stored as a series of blocks, and a volume cannot be smaller than the block size. But default the block size is 32, which is specified as a default parameter in the Volume constructor:
Code:
///Constructor
Volume(uint16_t uWidth, uint16_t uHeight, uint16_t uDepth, uint16_t uBlockSideLength = 32);

You'll need to check how this default parameter is exposed by SWIG, maybe your C# Volume has more than one constructor available or something?

I'll just note that if you are trying to make small volumes so you can tile them together, then that won't work. I can elaborate if that's what you were going to do. If not, carry on ;-)

Anyway, it looks like you've been making more great progress :-) I'll try your demo in a bit.

Author:  ape [ Mon Jan 17, 2011 7:55 pm ]
Post subject:  Re: PolyVox language bindings

Ah okay. I wasn't providing the blocksidelength parameter (I'm stupid).
I did get the winding order fixed finally so it doesn't draw inside out anymore. Currently trying to stitch cells together (I posted the problems I'm having in the thread about seamless transitions).

The problem I'm having with an overflowed int is in this section of code in nuclex's batch primitive rendering
Code:
int indicesToProcess = Math.Min(spaceLeft, indexCount);

// Generate indices for the new vertices. This might not be faster than using
// a special non-indexed RenderOperation, but it yields stable speeds between
// indexed and non-indexed vertices and allows us to lessen the impact
// the worst-case scenario will have.
int endIndex = this.currentOperation.VertexCount + indicesToProcess;
for(int index = this.currentOperation.VertexCount; index < endIndex; ++index) {
  this.indices[this.usedIndexCount] = (short)index;
  ++this.usedIndexCount;

  int vertexIndex = indices[startIndex] + startVertex;
  this.vertices[this.usedVertexCount] = vertices[vertexIndex];
  ++this.usedVertexCount;

  ++startIndex;
}

The vertexIndex value somehow gets a value of -32767 when I try to render 47070 vertices with 282564 indices, so it generates an "Index was outside the bounds of the array." exception when it tries to read vertices[vertexIndex]. I'll try and track down the nuclex author and ask him whats going on there. It seems to be caused because one of the indices + startVertex yields -32767.

edit: fixed it. Stupid code.
Code:
int vertexIndex = (int)(ushort)indices[startIndex] + startVertex;

Author:  ape [ Tue Jan 18, 2011 6:25 am ]
Post subject:  Re: PolyVox language bindings

http://dl.dropbox.com/u/6281166/cubicvoxels.jpg
Cubic mesh extraction is wrapped. I tried to do mesh decimation as well, but array and subarray were causing some compilation errors that I don't know how to work around.

Author:  Loschi [ Tue Jan 18, 2011 5:02 pm ]
Post subject:  Re: PolyVox language bindings

could you upload what you've done so far? or is the dropbox link up to date? i want to try it out tomorrow or the day after tomorrow :)

Author:  David Williams [ Tue Jan 18, 2011 6:04 pm ]
Post subject:  Re: PolyVox language bindings

ape wrote:
Cubic mesh extraction is wrapped. I tried to do mesh decimation as well, but array and subarray were causing some compilation errors that I don't know how to work around.

Nice work! Though it's strange about the Array. I just skimmed the code and the MeshDeecimator doesn't appear to use Arrays at all. Whereas the SurfaceExtractor does use them (internally, not in the interface) and that one is wrapped and working :?

Page 5 of 6 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/