It is currently Sat Aug 22, 2020 2:02 pm


All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Edges cause an invisible Volume
PostPosted: Mon Apr 25, 2011 9:03 pm 

Joined: Sat Apr 23, 2011 11:13 pm
Posts: 7
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. :)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Edges cause an invisible Volume
PostPosted: Tue Apr 26, 2011 1:19 am 

Joined: Sun Jan 23, 2011 6:06 am
Posts: 92
What region size are you using in each case to extract the surface? Also, are you using cubic or marching cubes surface extractor?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Edges cause an invisible Volume
PostPosted: Tue Apr 26, 2011 3:23 am 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Edges cause an invisible Volume
PostPosted: Tue Apr 26, 2011 6:28 am 

Joined: Sun Jan 23, 2011 6:06 am
Posts: 92
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


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Edges cause an invisible Volume
PostPosted: Tue Apr 26, 2011 6:52 am 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
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)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Edges cause an invisible Volume
PostPosted: Tue Apr 26, 2011 7:24 am 

Joined: Sat Apr 23, 2011 11:13 pm
Posts: 7
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Edges cause an invisible Volume
PostPosted: Tue Apr 26, 2011 7:56 am 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Edges cause an invisible Volume
PostPosted: Tue Apr 26, 2011 8:30 am 

Joined: Sun Jan 23, 2011 6:06 am
Posts: 92
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Edges cause an invisible Volume
PostPosted: Tue Apr 26, 2011 9:32 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
I'm going to need to sit down and document this properly :-) I will aim to do so soon.

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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Edges cause an invisible Volume
PostPosted: Tue Apr 26, 2011 4:54 pm 

Joined: Sat Apr 23, 2011 11:13 pm
Posts: 7
Ah! Thanks to all of you, I understand this better now (especially after a read through the Volume classes documentation as well).


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net