Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
Questions http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=359 |
Page 1 of 1 |
Author: | nicoo [ Sat Apr 07, 2012 6:17 pm ] |
Post subject: | Questions |
Hi, I have severals questions ![]() Question 1 I use this code : Code: #define _VD_ 300 //... MyPolyVoxMethod() { //... SimpleVolume<MaterialDensityPair44> volData(Region(Vector3DInt32(0,0,0), Vector3DInt32(_VD_, _VD_, _VD_)),1); uint8_t uDensity = VoxelTypeTraits<MaterialDensityPair44>::MaxDensity; int x,y,z; int X,Y,Z; int VecteurX, VecteurY, VecteurZ=80; int gap = 2; for(Z=1; Z < _VD_-VecteurZ-gap; Z+=VecteurZ+gap) { for (z = Z; z <= Z+VecteurZ; z++) { for ( y = 1; y < (int) (0.01*_VD_); y++) { for ( x = 1; x < (int) (0.1*_VD_); x++) { MaterialDensityPair44 voxel = volData.getVoxelAt(x,y,z); voxel.setDensity(uDensity); volData.setVoxelAt(x, y, z, voxel); } } } } } //... } If I'm using the next method to get the surface, Code: CubicSurfaceExtractorWithNormals<SimpleVolume, MaterialDensityPair44 > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh); I get what I expected ![]() ![]() right-angle and a space (gap) created at regular intervals. but I can't set a gap of 1, 2 seems to be the smaller. I don't understant this, one should be the smallest... actualy I don't want to use Code: CubicSurfaceExtractorWithNormals<SimpleVolume, MaterialDensityPair44 > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh); but Code: SurfaceExtractor<SimpleVolume, MaterialDensityPair44 > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh); to obtain later, some things more smoother, If I use my example, I get this ![]() I lost the right-angle, I guess it's about the interpolation method, how can I fix that ? Question 2: as you can see, all for() loops start from 1 not 0. If they start from 0 I get, ![]() ![]() faces on the borders of the volume aren't considered, why ? Question 3: all of these tests needed ~15 sec. to get the mesh. It's not possible to do that in realtime ? |
Author: | David Williams [ Sun Apr 08, 2012 8:43 am ] |
Post subject: | Re: Questions |
nicoo wrote: Code: SimpleVolume<MaterialDensityPair44> volData(Region(Vector3DInt32(0,0,0), Vector3DInt32(_VD_, _VD_, _VD_)),1); Two points here. Firstly, be aware that you are actually creating a volume with a side length of _VD_ + 1 (not _VD_) because the range will be 0 to _VD_ and is inclusive of both end points. Secondly, the last parameter (the block size) should not be '1'. The default of 32 is much better here. This may be a cause of performance problems. In fact, I'll adjust the asserts to catch this. nicoo wrote: but I can't set a gap of 1, 2 seems to be the smaller. I don't understant this, one should be the smallest... I'm not sure, I can't quite follow your code. Maybe there can be a rounding error when you cast the float to an int? You'll have to experiment with this... nicoo wrote: I lost the right-angle, I guess it's about the interpolation method, how can I fix that ? This is correct, the SurfaceExtractor will never generate a right angle. This is a limitation of the Marching Cubes algorithm. There are other algorithms such as Dual Contour Marching Cubes which handle this better but they are not implemented in PolyVox. nicoo wrote: Question 2: as you can see, all for() loops start from 1 not 0. If they start from 0 I get, ![]() ![]() faces on the borders of the volume aren't considered, why ? This is the expected behaviour of the SurfaceExtractor though it is slightly confusing. Within the region you are specifying (by getEnclosingRegion()) all of the voxels are solid, so no surface is generated. You can tell the SurfaceExtractor to also look at voxels outside the volume, and by default these should be zero so then you will get a surface. Try this (untested code!) to expand the region: Code: Region myRegion = volData.getEnclosingRegion(); myRegion.setUpperCorner(myRegion.getUpperCorner() + Vector3DInt32(1,1,1)); myRegion.setLowerCorner(myRegion.getLowerCorner() - Vector3DInt32(1,1,1)); SurfaceExtractor<SimpleVolume, MaterialDensityPair44 > surfaceExtractor(&volData, myRegion, &mesh); Yeah, we need a utility function for that... nicoo wrote: Question 3: all of these tests needed ~15 sec. to get the mesh. It's not possible to do that in realtime ? See my earlier point about the block size as this could addect peformance a lot. Also, you are running in release mode? |
Author: | nicoo [ Fri Apr 13, 2012 4:43 am ] |
Post subject: | Re: Questions |
David Williams wrote: Two points here. Firstly, be aware that you are actually creating a volume with a side length of _VD_ + 1 (not _VD_) because the range will be 0 to _VD_ and is inclusive of both end points. you right, actualy that does'nt matter for me. David Williams wrote: Secondly, the last parameter (the block size) should not be '1'. The default of 32 is much better here. This may be a cause of performance problems. In fact, I'll adjust the asserts to catch this. well I change to 32 for now. David Williams wrote: I'm not sure, I can't quite follow your code. Maybe there can be a rounding error when you cast the float to an int? You'll have to experiment with this... Ok, I'll check that next week, I'm actually busy with another library. David Williams wrote: This is correct, the SurfaceExtractor will never generate a right angle. This is a limitation of the Marching Cubes algorithm. There are other algorithms such as Dual Contour Marching Cubes which handle this better but they are not implemented in PolyVox. Ok, for now that's not a big deal. David Williams wrote: This is the expected behaviour of the SurfaceExtractor though it is slightly confusing. Within the region you are specifying (by getEnclosingRegion()) all of the voxels are solid, so no surface is generated. You can tell the SurfaceExtractor to also look at voxels outside the volume, and by default these should be zero so then you will get a surface. Try this (untested code!) to expand the region: Code: Region myRegion = volData.getEnclosingRegion(); myRegion.setUpperCorner(myRegion.getUpperCorner() + Vector3DInt32(1,1,1)); myRegion.setLowerCorner(myRegion.getLowerCorner() - Vector3DInt32(1,1,1)); SurfaceExtractor<SimpleVolume, MaterialDensityPair44 > surfaceExtractor(&volData, myRegion, &mesh); Yeah, we need a utility function for that... ok, will be on my worklist too for next week. David Williams wrote: See my earlier point about the block size as this could addect peformance a lot. Also, you are running in release mode? I running in release mode, I didn't see a real difference (concerning polyvox) with debug mode. Anyway I will do some tests and getting some data about this point. |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |