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 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; }