// This function creates a spherical volume with ,multiple layers, which can then be used as a planet. // We used it (or an earlier version?) to create the Earth and Moon for the the 'solar system' example. void CreatePlanetVDB () { int planetRadius = 60; // Randomize the filename incase the file already exists System.Random randomIntGenerator = new System.Random(); int randomInt = randomIntGenerator.Next(); string saveLocation = Paths.voxelDatabases + "/planet-" + randomInt + ".vdb"; Region volumeBounds = new Region(-planetRadius, -planetRadius, -planetRadius, planetRadius, planetRadius, planetRadius); TerrainVolumeData data = VolumeData.CreateEmptyVolumeData<TerrainVolumeData>(volumeBounds, saveLocation); // The numbers below control the thickness of the various layers. TerrainVolumeGenerator.GeneratePlanet(data, planetRadius, planetRadius - 1, planetRadius - 10, planetRadius - 35); // We need to commit this so that the changes made by the previous,line are actually written // to the voxel database. Otherwise they are just kept in temporary storage and will be lost. data.CommitChanges(); Debug.Log("Voxel database has been saved to '" + saveLocation + "'"); }
/// \cond protected override void InitializeEmptyCubiquityVolume(Region region) { // We check 'mVolumeHandle' instead of 'volumeHandle' as the getter for the latter will in turn call this method. DebugUtils.Assert(mVolumeHandle == null, "Volume handle should be null prior to initializing volume"); if(!initializeAlreadyFailed) // If it failed before it will fail again - avoid spamming error messages. { try { // Create an empty region of the desired size. volumeHandle = CubiquityDLL.NewEmptyTerrainVolume(region.lowerCorner.x, region.lowerCorner.y, region.lowerCorner.z, region.upperCorner.x, region.upperCorner.y, region.upperCorner.z, fullPathToVoxelDatabase, DefaultBaseNodeSize); } catch(CubiquityException exception) { volumeHandle = null; initializeAlreadyFailed = true; Debug.LogException(exception); Debug.LogError("Failed to open voxel database '" + fullPathToVoxelDatabase + "'"); } } }
public static void BlurTerrainVolume(TerrainVolume volume, Region region) { CubiquityDLL.BlurTerrainVolumeRegion((uint)volume.data.volumeHandle, region.lowerCorner.x, region.lowerCorner.y, region.lowerCorner.z, region.upperCorner.x, region.upperCorner.y, region.upperCorner.z); }
/// \cond protected abstract void InitializeEmptyCubiquityVolume(Region region);