It is currently Fri Nov 24, 2017 10:20 pm


All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: extractMarchingCubesMesh not producing vertices.
PostPosted: Tue Aug 08, 2017 7:25 pm 

Joined: Fri Jul 21, 2017 6:11 am
Posts: 5
Hello, I'm trying to use this function to produce terrain using the built-in paging system.

Here's the code:
Code:
class PerlinNoisePager : public PolyVox::PagedVolume<MaterialDensityPair44>::Pager
{
public:
   /// Constructor
   PerlinNoisePager()
      :PagedVolume<MaterialDensityPair44>::Pager()
   {
   }

   /// Destructor
   virtual ~PerlinNoisePager() {};

   virtual void pageIn(const PolyVox::Region& region, PagedVolume<MaterialDensityPair44>::Chunk* pChunk)
   {

            FastNoise n;
            n.SetFractalOctaves(2);
           
           
            for (int x = region.getLowerX(); x <= region.getUpperX(); x++)
            {
                for (int y = region.getLowerY(); y <= region.getUpperY(); y++)
                {
                    for (int z = region.getLowerZ(); z <= region.getUpperZ(); z++)
                    {
                       
                        MaterialDensityPair44 voxel;
                        //Even setting this to 245 or 255 doesn't produce vertices.
                        voxel.setMaterial(n.GetValueFractal(x, y, z) * 40);

                        voxel.setDensity(MaterialDensityPair44::getMaxDensity());
                        //Wrte the voxel value into the volume
                        pChunk->setVoxel(x - region.getLowerX(), y - region.getLowerY(), z -region.getLowerZ(), voxel);
                       
                    }
                }
            }
   }

   virtual void pageOut(const PolyVox::Region& region, PagedVolume<MaterialDensityPair44>::Chunk* /*pChunk*/)
   {
      std::cout << "warning unloading region: " << region.getLowerCorner() << " -> " << region.getUpperCorner() << std::endl;
   }
};


Here's the code that calls this stuff:

Code:
PerlinNoisePager* pager = new PerlinNoisePager();
    PagedVolume<MaterialDensityPair44> volData(pager, 8 * 1024 * 1024, 32);
    PolyVox::Region reg2(Vector3DInt32(0, 0, 0), Vector3DInt32(154, 154, 154));
    auto mesh = extractMarchingCubesMesh(&volData, reg2);
    std::cout << "#vertices: " << mesh.getNoOfVertices() << std::endl;


This does not produce vertices but if I use the cubic extractor it does. Any ideas?

Thank you!


Top
Offline Profile  
Reply with quote  
 Post subject: Re: extractMarchingCubesMesh not producing vertices.
PostPosted: Thu Aug 10, 2017 5:28 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1816
The Marching Cubes extractor uses thedensity (not the material) to decide whether to generate a vertex. In your case you are setting all the voxels to maximum density which means there is no isosurface present and so no mesh is generated.

As a first improvement, set voxels to have a density of zero if you want them to be empty space and to max density if you want them to be solid.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 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