Beispiel #1
0
void VoxelTerrain::requestVolume(
  const PolyVox::ConstVolumeProxy<BYTE>& volume,
  const PolyVox::Region& region)
{
  float interval = 1;
  //std::cout << "Begin filling VoxelTerrain." << std::endl;
  for (float z = region.getLowerCorner().getZ();
       z <= region.getUpperCorner().getZ(); z+=interval) {
    for (float y = region.getLowerCorner().getY();
         y <= region.getUpperCorner().getY(); y+=interval) {
      for (float x = region.getLowerCorner().getX();
           x <= region.getUpperCorner().getX(); x+=interval) {
        //std::cout << x/region.getUpperCorner().getX() << std::endl;

        BYTE voxel_value = ground_cave_multiply.get(
          5*x/region.getUpperCorner().getX(),
          y/region.getUpperCorner().getY(),
          5*z/region.getUpperCorner().getZ())*255;
        
        // if (static_cast<double>(voxel_value) != 0)
        //   std::cout << static_cast<double>(voxel_value) << std::endl;

        volume.setVoxelAt(x, y, z, voxel_value);
      }
    }
  }
  //std::cout << "Done filling VoxelTerrain." << std::endl;
}
Beispiel #2
0
void World::loadRegion(const PolyVox::ConstVolumeProxy<PolyVox::Material8>& volData, const PolyVox::Region& region) {
    std::stringstream ss;
    ss << "Info: loadRegion() is loading region: " << region.getLowerCorner() << " -> " << region.getUpperCorner();
    Utils::log(ss.str());
    uint8_t material = 2;

    int lo_x = region.getLowerCorner().getX() +1;
    int lo_y = region.getLowerCorner().getY() +1;
    int lo_z = region.getLowerCorner().getZ() +1;

    int hi_x = 7;
    int hi_y = 3;
    int hi_z = 7;

    for (int x=lo_x; x<hi_x; ++x) {
        for (int y=lo_y; y<hi_y; ++y) {
            for (int z=lo_z; z<hi_z; ++z) {
                PolyVox::Material8 voxel = volData.getVoxelAt(x,y,z);
                voxel.setMaterial(material);
                volData.setVoxelAt(x,y,z, voxel);
            }
        }
    }

}
void LargeVoxelSphere::VoxelSpherePager::pageIn(
    const PolyVox::Region& region,
    PolyVox::PagedVolume<BYTE>::Chunk* chunk)
{
 for (int z = region.getLowerCorner().getZ();
      z <= region.getUpperCorner().getZ(); z++) {
   for (int y = region.getLowerCorner().getY();
        y <= region.getUpperCorner().getY(); y++) {
     for (int x = region.getLowerCorner().getX();
          x <= region.getUpperCorner().getX(); x++) {
        PolyVox::Vector3DFloat current_pos(x,y,z);
        PolyVox::Vector3DFloat volume_center(0,0,0);
        float dist_to_center = (current_pos - volume_center).length();

        BYTE voxel_value = 0;
        if(dist_to_center <= 100) {
          voxel_value = 255;
        }

        chunk->setVoxel(x, y, z, voxel_value);
      }
    }
  }
}
Beispiel #4
0
	virtual void pageOut(const PolyVox::Region& region, PagedVolume<MaterialDensityPair44>::Chunk* /*pChunk*/)
	{
		std::cout << "warning unloading region: " << region.getLowerCorner() << " -> " << region.getUpperCorner() << std::endl;
	}
Beispiel #5
0
void World::unloadRegion(const PolyVox::ConstVolumeProxy<PolyVox::Material8>& volData, const PolyVox::Region& region) {
    std::stringstream ss;
    ss << "Info: unloadRegion() is unloading region: " << region.getLowerCorner() << " -> " << region.getUpperCorner();
    Utils::log(ss.str());
}