Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
Problem extracting Voxels http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=466 |
Page 1 of 1 |
Author: | 57005 [ Sat Dec 15, 2012 6:12 pm ] |
Post subject: | Problem extracting Voxels |
Hi I was experimenting with the PolyVox Library and it worked great. But now I ran into a problem which I don't know how to fix. It seems like the extractor does not extract everything. I get patches of no material, but if I print out the Material into a file I can see, that there should be a surface. Here are two images to visualize it: ![]() http://i.imgur.com/9f3Xl.png For my testing I am using Irrlicht to render the meshes. Here is my conversion code: Code: SurfaceMesh<PositionMaterialNormal> surfaceMesh; CubicSurfaceExtractorWithNormals<LargeVolume<Material16> > extractor(m_pVolume, region, &surfaceMesh); extractor.execute(); createIrrlichtMesh(surfaceMesh); //... // createIrrlichtMesh method: const std::vector<uint32_t>& indices = surfaceMesh->getIndices(); const std::vector<PositionMaterialNormal>& vertices = surfaceMesh->getVertices(); irr::scene::SMesh* smesh = new irr::scene::SMesh(); irr::scene::SMeshBuffer* buf = new irr::scene::SMeshBuffer(); smesh->addMeshBuffer(buf); buf->drop(); buf->Vertices.set_used(surfaceMesh->getNoOfVertices()); buf->Indices.set_used(surfaceMesh->getNoOfIndices()); for(uint32_t v = 0 ; v < surfaceMesh->getNoOfVertices() ; v++) { const PolyVox::Vector3DFloat& position = vertices[v].getPosition(); const PolyVox::Vector3DFloat& normal = vertices[v].getNormal(); buf->Vertices[v].Pos.set(position.getX(), position.getY(), position.getZ()); buf->Vertices[v].Normal.set(normal.getX(), normal.getY(), normal.getZ()); buf->Vertices[v].Color.set(255, 255, 255, 255); } for(uint32_t i = 0 ; i < surfaceMesh->getNoOfIndices(); i++) { buf->Indices[i] = indices[i]; } buf->recalculateBoundingBox(); //..... And here is the code for the initialization of the Volume: Code: m_pVolume = new LargeVolume<Material16>(&VoxelWorld::loadPage, &VoxelWorld::unloadPage, VOXEL_PAGE_SIZE); m_pVolume->setMaxNumberOfBlocksInMemory(4096); m_pVolume->setMaxNumberOfUncompressedBlocks(64); m_pVolume->setBorderValue(0); Region reg(Vector3DInt32(0,0,0), Vector3DInt32(64,64,64)); m_pVolume->prefetch(reg); VOXEL_PAGE_SIZE is 32 in this test but making it smaller or bigger does not make a difference (just where the holes are located). I would appreciate your help, thanks is advance. Edit: Sorry, the problem was that I tried to extract the Regions one by one. I feel really stupid, but is there any way to get smaller regions out of the Volume so I don't have to recreate the whole region if I change one Voxel? |
Author: | David Williams [ Sun Dec 16, 2012 10:30 am ] |
Post subject: | Re: Problem extracting Voxels |
Ok, I'm glad you fixed it and sorry I was a little slow to reply. Is it working exactly as expected now? I was going to say that you might have some issues with the CubicSurfaceExtractorWithNormals as generally it's a little less robust than the CubicSurfaceExtractor (without normals), and long term you should switch to that one. 57005 wrote: Sorry, the problem was that I tried to extract the Regions one by one. I'm not clear what you mean by this, can you elaborate? 57005 wrote: I feel really stupid, but is there any way to get smaller regions out of the Volume so I don't have to recreate the whole region if I change one Voxel? The size of the region you extract is completely up to you and is specified by one of the parameters to the surface extractor. If you want to generate a single mesh corresponding to the whole volume then you can use volume->getEnclosingRegion() but generally this is a bad idea. You will instead want a number of non-overlapping regions and 32x32x32 would be an appropriate size for this. If you then change a single voxel then you have to regenerate the whole mesh for that region, but you do not have to regenerate other meshes for the rest of the volume. You cannot update an existing mesh with a change corresponding to a one-voxel modification. Does that answer your question? |
Author: | 57005 [ Sun Dec 16, 2012 1:46 pm ] |
Post subject: | Re: Problem extracting Voxels |
Thanks for your reply. Wow, looks like I did everything right in the first place but using the CubicSurfaceExtractorWithNormals (I did a little "hack" to get it working with this extractor by generating meshes from 33x33x33 regions). The CubicSurfaceExtractor works like a charm without any problems. Thanks! |
Author: | David Williams [ Sun Dec 16, 2012 5:13 pm ] |
Post subject: | Re: Problem extracting Voxels |
Yeah, the CubicSurfaceExtractorWithNormals is mostly intended to get you started with PolyVox, as people often find it confusing if no normals are present. But trying to generate normals complicates the logic (and increases the mesh size) because vertices can no longer be shared as easily. Long term it will be possible to generate a mesh without normals, and then add them seperatly if they are needed. At this point the CubicSurfaceExtractorWithNormals can be removed and everyone will be less confused ![]() Edit - See also: http://www.volumesoffun.com/polyvox/doc ... bic-meshes |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |