Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
Edges cause an invisible Volume http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=207 |
Page 1 of 1 |
Author: | Deedel [ Mon Apr 25, 2011 9:03 pm ] |
Post subject: | Edges cause an invisible Volume |
Hi all, I'm integrating PolyVox into Ogre with a ManualObject and using the following code to fill in voxels with a max density. Code: for (int z = 1; z < volData.getWidth() - 1; z++) { for (int y = 1; y < volData.getHeight() - 1; y++) { for (int x = 1; x < volData.getDepth() - 1; x++) { // New density value. uint8_t uDensity = PolyVox::MaterialDensityPair44::getMaxDensity(); // Get the old voxel. PolyVox::MaterialDensityPair44 voxel = volData.getVoxelAt(x, y, z); // Modify the density. voxel.setDensity(uDensity); // Write the voxel value into the volume. volData.setVoxelAt(x, y, z, voxel); } } } However, as you can probably see, this skips the edges. This method renders perfectly, however, and all blocks can be seen. To fix the edge issue, I attempted to change the code to: Code: for (int z = 0; z < volData.getWidth(); z++) { for (int y = 0; y < volData.getHeight(); y++) { for (int x = 0; x < volData.getDepth(); x++) { // New density value. uint8_t uDensity = PolyVox::MaterialDensityPair44::getMaxDensity(); // Get the old voxel. PolyVox::MaterialDensityPair44 voxel = volData.getVoxelAt(x, y, z); // Modify the density. voxel.setDensity(uDensity); // Write the voxel value into the volume. volData.setVoxelAt(x, y, z, voxel); } } } However, now nothing is rendered at all. Am I attempting to do something stupid, or is this a bug? Any help is appreciated, thanks. ![]() |
Author: | DefiniteIntegral [ Tue Apr 26, 2011 1:19 am ] |
Post subject: | Re: Edges cause an invisible Volume |
What region size are you using in each case to extract the surface? Also, are you using cubic or marching cubes surface extractor? |
Author: | Shanee [ Tue Apr 26, 2011 3:23 am ] |
Post subject: | Re: Edges cause an invisible Volume |
Oh, it is known already. I reported it to David some time. The edges must be near empty voxels in order to have anything show, so filling everything with density will result in invisible volume. Fill everything BUT the edges. |
Author: | DefiniteIntegral [ Tue Apr 26, 2011 6:28 am ] |
Post subject: | Re: Edges cause an invisible Volume |
Really? I have set voxels to solid right on the volume border before and it worked... but I guess I probably haven't tried filling the entire volume, only the full width/depth but not height... do you have to fill literally the entire volume for this to happen? Isn't this what the PolyVox::Volume<VoxelType>::setBorderValue function is meant to be for? I don't remember exactly but I did experiment with it a while ago, and setting border solid made my volume not render, and setting border non-solid made it render OK.... I might have to repeat that experiment |
Author: | Shanee [ Tue Apr 26, 2011 6:52 am ] |
Post subject: | Re: Edges cause an invisible Volume |
Well, in my case, if I fill the edges they became invisible (though you will still see a surface on the height if that one isn't full) |
Author: | Deedel [ Tue Apr 26, 2011 7:24 am ] |
Post subject: | Re: Edges cause an invisible Volume |
If it is necessary to fill the volumes would I have to take this into account when placing two volumes next to each other? That could get a bit messy, but it seems it becomes invisible with any region size. I'll have to have another experiment with it when I get back. |
Author: | Shanee [ Tue Apr 26, 2011 7:56 am ] |
Post subject: | Re: Edges cause an invisible Volume |
Deedel, it is very recommended instead of placing one volume next to the other to have one large volume and use the surface extractor to create region parts of the volume instead of extracting the full volume as one single mesh. This with the new paging system should help you overcome both RAM usage and handling larger volumes. |
Author: | DefiniteIntegral [ Tue Apr 26, 2011 8:30 am ] |
Post subject: | Re: Edges cause an invisible Volume |
I wonder if there is a difference between Marching Cubes and Cubic surface then... because I have definitely extracted surfaces successfully from solid voxels right on the volume border. I am using Cubic extractor without normals. |
Author: | David Williams [ Tue Apr 26, 2011 9:32 am ] |
Post subject: | Re: Edges cause an invisible Volume |
I'm going to need to sit down and document this properly ![]() But basically, there is a difference in the behaviour between the CubicSurfaceExtractor and the marching cubes SurfaceExtractor. The difference exists because the CubicSurfaceExtractor generates geometry for a particular voxel, but the marching cubes surface extractor generates geometry for a particular cell. A cell is a group of eight voxels. I will need to draw diagrams to explain this properly, but in the case where you have filled the whole volume and you want to extract a surface with the marching cubes surface extractor, you can actually specify a region which is larger then the volume. But you might find it easier to simply never fill in the edge voxels of the volume. As was noted above, you should not place multiple volumes next to each other but instead use a single large volume. You can still break it down into seperate meshes by passing a Region to the surface extractor. |
Author: | Deedel [ Tue Apr 26, 2011 4:54 pm ] |
Post subject: | Re: Edges cause an invisible Volume |
Ah! Thanks to all of you, I understand this better now (especially after a read through the Volume classes documentation as well). |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |