Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
[Resolved]: Duplicate faces in surface extractor http://www.volumesoffun.com/phpBB3/viewtopic.php?f=15&t=195 |
Page 1 of 2 |
Author: | DefiniteIntegral [ Sun Apr 10, 2011 2:50 am ] |
Post subject: | [Resolved]: Duplicate faces in surface extractor |
Topic split of from here: viewtopic.php?f=14&t=190 Hey psquare or beyzend, since you guys having working paging+decimation, would one of you mind doing me a favor? Could you post a couple of screenshots of your scene with/without decimation using wireframe only? I am getting a few bugs with the resulting decimated meshes and are not sure if it is my code, or PolyVox. In particular I am having issues with vertex collapse along region borders. |
Author: | David Williams [ Sun Apr 10, 2011 6:42 pm ] |
Post subject: | Re: Faster decimation? |
DefiniteIntegral wrote: I am getting a few bugs with the resulting decimated meshes and are not sure if it is my code, or PolyVox. In particular I am having issues with vertex collapse along region borders. Aren't you actually working with the smooth meshes though, rather than the cubic ones? Also, does the problem go away if you edit the function 'canCollapseRegionEdge' to always return false? |
Author: | DefiniteIntegral [ Mon Apr 11, 2011 2:45 am ] |
Post subject: | Re: Faster decimation? |
Actually I am using cubic meshes without normals. I haven't tried forcing no edge collapse yet, I will try that later once I have time. I do have another issue as well though, to do with mesh extraction, not decimation. Extracting meshes from two adjacent regions where one face is flush against the region border results in a duplicate mesh along the border. See the screenshots below. The red lines indicate the region border. Non-flush edge / normal face: ftp://definiteintegral.net/regionedge_meshextract_normal.png Flush-edge / duplicate face: ftp://definiteintegral.net/regionedge_meshextract_duplicateface.png |
Author: | David Williams [ Mon Apr 11, 2011 8:17 pm ] |
Post subject: | Re: Faster decimation? |
I believe I might have seen something like this in the past though a quick and basic test didn't manage to reproduce it. I opened the BasicExample and replaced the main() function with this: Code: int main(int argc, char *argv[]) { //Create and show the Qt OpenGL window QApplication app(argc, argv); OpenGLWidget openGLWidget(0); openGLWidget.show(); //Create an empty volume and then place a sphere in it Volume<MaterialDensityPair44> volData(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(63, 63, 63))); //createSphereInVolume(volData, 30); //Our new density value uint8_t uDensity = MaterialDensityPair44::getMaxDensity(); //Get the old voxel MaterialDensityPair44 voxel; //Modify the density voxel.setDensity(uDensity); voxel.setMaterial(1); //Wrte the voxel value into the volume volData.setVoxelAt(32,32,32, voxel); volData.setVoxelAt(32,32,33, voxel); volData.setVoxelAt(32,33,32, voxel); volData.setVoxelAt(32,33,33, voxel); volData.setVoxelAt(33,32,32, voxel); volData.setVoxelAt(33,32,33, voxel); volData.setVoxelAt(33,33,32, voxel); volData.setVoxelAt(33,33,33, voxel); //Extract the surface /*SurfaceMesh<PositionMaterialNormal> mesh; CubicSurfaceExtractorWithNormals<MaterialDensityPair44> surfaceExtractor(&volData, PolyVox::Region(Vector3DInt32(32,32,32), Vector3DInt32(33,33,33)), &mesh); surfaceExtractor.execute();*/ SurfaceMesh<PositionMaterial> mesh; CubicSurfaceExtractor<MaterialDensityPair44> surfaceExtractor(&volData, PolyVox::Region(Vector3DInt32(32,32,32), Vector3DInt32(33,33,33)), &mesh); //CubicSurfaceExtractor<MaterialDensityPair44> surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh); surfaceExtractor.execute(); std::cout << "Vertices = " << mesh.getNoOfVertices() << ", Indices = " << mesh.getNoOfIndices() << ", Triangles = " << mesh.getNoOfIndices()/3 << std::endl; //Pass the surface to the OpenGL window //openGLWidget.setSurfaceMeshToRender(mesh); //Run the message pump. return app.exec(); } It prints out 48 triangles, which seems correct to me. Is there any chance you can make an example which shows the problem? Or can you see what I missed? It doesn't need to render anything, just printing stuff out like above would be enough. |
Author: | DefiniteIntegral [ Tue Apr 12, 2011 2:47 am ] |
Post subject: | Re: Faster decimation? |
The problem only occurs with CubicSurfaceExtractor, but not CubicSurfaceExtractorWithNormals. Code example: Code: #include "MaterialDensityPair.h" #include "CubicSurfaceExtractor.h" #include "CubicSurfaceExtractorWithNormals.h" #include "SurfaceMesh.h" #include "Volume.h" //#define USE_NORMALS using namespace PolyVox; int main(int argc, char *argv[]) { typedef MaterialDensityPair<uint8_t, 4, 4> Material44; // Create a volume Volume<Material44> volData(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(63, 63, 63))); // Set up a voxel material uint8_t density = Material44::getMaxDensity(); Material44 voxel; voxel.setDensity(density); voxel.setMaterial(1); // Set some voxels just inside the edge of the region to be extracted. Don't set any voxels on the other side of the region border volData.setVoxelAt(0, 0, 31, voxel); volData.setVoxelAt(1, 0, 31, voxel); volData.setVoxelAt(2, 0, 31, voxel); volData.setVoxelAt(3, 0, 31, voxel); // Extract the surface mesh from Region0 (contains voxels) #ifdef USE_NORMALS SurfaceMesh<PositionMaterialNormal> meshRegion0; CubicSurfaceExtractorWithNormals<Material44> surfaceExtractorRegion0(&volData, PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 31)), &meshRegion0); #else SurfaceMesh<PositionMaterial> meshRegion0; CubicSurfaceExtractor<Material44> surfaceExtractorRegion0(&volData, PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 31)), &meshRegion0); #endif surfaceExtractorRegion0.execute(); // Extract the surface mesh from Region1 (does not contain voxels) #ifdef USE_NORMALS SurfaceMesh<PositionMaterialNormal> meshRegion1; CubicSurfaceExtractorWithNormals<Material44> surfaceExtractorRegion1(&volData, PolyVox::Region(Vector3DInt32(0, 0, 32), Vector3DInt32(63, 63, 63)), &meshRegion1); #else SurfaceMesh<PositionMaterial> meshRegion1; CubicSurfaceExtractor<Material44> surfaceExtractorRegion1(&volData, PolyVox::Region(Vector3DInt32(0, 0, 32), Vector3DInt32(63, 63, 63)), &meshRegion1); #endif surfaceExtractorRegion1.execute(); // Check vertices on meshRegion0 - should be 20 vertices std::cout << "meshRegion0 Vertices = " << meshRegion0.getNoOfVertices() << ", Indices = " << meshRegion0.getNoOfIndices() << ", Triangles = " << meshRegion0.getNoOfIndices()/3 << std::endl; // Check vertices on meshRegion1 - should be 0 vertices std::cout << "meshRegion1 Vertices = " << meshRegion1.getNoOfVertices() << ", Indices = " << meshRegion1.getNoOfIndices() << ", Triangles = " << meshRegion1.getNoOfIndices()/3 << std::endl; return 0; } With USE_NORMALS defined: meshRegion0 Vertices = 16, Indices = 24, Triangles = 8 meshRegion1 Vertices = 0, Indices = 0, Triangles = 0 With USE_NORMALS undefined meshRegion0 Vertices = 20, Indices = 108, Triangles = 36 meshRegion1 Vertices = 10, Indices = 24, Triangles = 8 Somehow the extractor without normals is putting out more vertices than it should be, even when the result should have 0 vertices such in the region border case. |
Author: | DefiniteIntegral [ Tue Apr 12, 2011 8:10 am ] |
Post subject: | Re: Faster decimation? |
Sorry I probably should have posted that in a new thread in PolyVox Bugs. Perhaps you can chop my posts out into a new thread in there.... |
Author: | David Williams [ Tue Apr 12, 2011 7:59 pm ] |
Post subject: | Re: Duplicate faces in surface extractor |
Great, thanks for the example, it does indeed look like there is an issue here. Note that I don't necessarily expect the number of vertices and triangles to be the same between the two extractors though. The version with normals may have more vertices because they cannot be shared as easily (adjacent faces on a cube have different normals). It may also have less triangles because I think it doesn't close of the final slice of the region (I might not fix this - this extractor is just for testing purposes really). I'm mostly concerned about your last line as I agree this should probably be empty. I should have a chance to look at it at the weekend. |
Author: | DefiniteIntegral [ Wed Apr 13, 2011 1:50 am ] |
Post subject: | Re: Duplicate faces in surface extractor |
Thanks. I have some time over the next couple of days and might take a look into the CubicSurfaceExtractor code myself. But I really know nothing about mesh extraction so I might not be very useful ![]() |
Author: | DefiniteIntegral [ Wed Apr 13, 2011 3:06 pm ] |
Post subject: | Re: Duplicate faces in surface extractor |
OK I think I have it. Only required a minor change. ftp://definiteintegral.net/CubicSurfaceExtractor.inl |
Author: | David Williams [ Wed Apr 13, 2011 8:11 pm ] |
Post subject: | Re: Duplicate faces in surface extractor |
Great, thanks, I've applied your change to the Git repository. |
Page 1 of 2 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |