protected void Init() { float rad = (float)m_data.Radius; float maxHeight = rad * Generator.HillParams.Max; float halfSize = rad + maxHeight; StorageSize = MyVoxelCoordSystems.FindBestOctreeSize(2 * halfSize); float halfStorageSize = StorageSize.X * 0.5f; Shape = new MyPlanetShapeProvider(new Vector3(halfStorageSize), rad, Generator); Material = new MyPlanetMaterialProvider(Generator, Shape); }
private void CleanRules() { if (m_rangeBiomes == null) { m_rangeBiomes = new List <PlanetMaterialRule> [256]; } foreach (var bio in m_biomes.Values) { m_rangeBiomes[bio.Value] = bio.Rules; } m_rangeClean = true; m_providerForRules = this; }
public PlanetMaterial(MyPlanetMaterialDefinition def, float minimumSurfaceLayerDepth) { base.Depth = def.MaxDepth; if (def.Material != null) { base.Material = MyPlanetMaterialProvider.GetMaterial(def.Material); } base.Value = def.Value; if (def.HasLayers) { int length = def.Layers.Length; if ((def.Layers[0].Depth < minimumSurfaceLayerDepth) && (MyPlanetMaterialProvider.GetMaterial(def.Layers[0].Material).RenderParams.Foliage != null)) { length++; } this.Layers = new MyPlanetMaterialProvider.VoxelMaterial[length]; int index = 0; for (int i = 0; index < def.Layers.Length; i++) { MyPlanetMaterialProvider.VoxelMaterial material1 = new MyPlanetMaterialProvider.VoxelMaterial(); material1.Material = MyPlanetMaterialProvider.GetMaterial(def.Layers[index].Material); material1.Depth = def.Layers[index].Depth; this.Layers[i] = material1; if ((i == 0) && (def.Layers[index].Depth < minimumSurfaceLayerDepth)) { if ((minimumSurfaceLayerDepth <= 1f) || (this.Layers[i].Material.RenderParams.Foliage == null)) { this.Layers[i].Depth = minimumSurfaceLayerDepth; } else { MyVoxelMaterialDefinition definition = string.IsNullOrEmpty(this.Layers[i].Material.BareVariant) ? this.Layers[i].Material : MyDefinitionManager.Static.GetVoxelMaterialDefinition(this.Layers[i].Material.BareVariant); this.Layers[i].Depth = 1f; i++; MyPlanetMaterialProvider.VoxelMaterial material2 = new MyPlanetMaterialProvider.VoxelMaterial(); material2.Material = definition; material2.Depth = minimumSurfaceLayerDepth - 1f; this.Layers[i] = material2; } } index++; } } }
private void CleanRules() { if (m_rangeBiomes == null) m_rangeBiomes = new List<PlanetMaterialRule>[256]; foreach (var bio in m_biomes.Values) { m_rangeBiomes[bio.Value] = bio.Rules; } m_rangeClean = true; m_providerForRules = this; }
private void PrepareRulesForBoxInternal(ref BoundingBox request) { if (m_rangeBiomes == null) m_rangeBiomes = new List<PlanetMaterialRule>[256]; BoundingBox box; request.Translate(-m_planetShape.Center()); // Inflate so we don't miss any rules. request.Inflate(request.Extents.Length() * .1f); GetRuleBounds(ref request, out box); foreach (var bio in m_biomes.Values) { if (ReferenceEquals(m_rangeBiomes[bio.Value], bio.Rules) || m_rangeBiomes[bio.Value] == null || m_providerForRules != this) m_rangeBiomes[bio.Value] = new List<PlanetMaterialRule>(); bio.MateriaTree.OverlapAllBoundingBox(ref box, m_rangeBiomes[bio.Value], clear: true); } m_rangeClean = false; m_providerForRules = this; }
public void Close() { if (m_providerForRules == this) m_providerForRules = null; // Clear to speed up collection m_blendingTileset = null; m_subsurfaceMaterial = null; m_generator = null; m_biomeMap = null; m_biomes = null; m_materials = null; m_planetShape = null; m_ores = null; m_materialMap = null; m_oreMap = null; m_biomeMap = null; m_occlusionMap = null; Closed = true; }
public MyPlanetDetailModulator(MyPlanetGeneratorDefinition planetDefinition, MyPlanetMaterialProvider oreDeposit, int seed, float radius) { m_planetDefinition = planetDefinition; m_oreDeposit = oreDeposit; m_radius = radius; foreach (var distortionDefinition in m_planetDefinition.DistortionTable) { MyModuleFast modulator = null; float frequency = distortionDefinition.Frequency; frequency *= radius / 6.0f; switch (distortionDefinition.Type) { case "Billow": { modulator = new MyBillowFast( seed: seed, quality: MyNoiseQuality.High, frequency: frequency, layerCount: distortionDefinition.LayerCount); } break; case "RidgedMultifractal": { modulator = new MyRidgedMultifractalFast( seed: seed, quality: MyNoiseQuality.High, frequency: frequency, layerCount: distortionDefinition.LayerCount); } break; case "Perlin": { modulator = new MyPerlinFast( seed: seed, quality: MyNoiseQuality.High, frequency: frequency, octaveCount: distortionDefinition.LayerCount); } break; case "Simplex": { modulator = new MySimplexFast() { Seed = seed, Frequency = frequency, }; } break; default: System.Diagnostics.Debug.Fail("Unknown modulator type!"); break; } if (modulator != null) { m_modulators.Add(distortionDefinition.Value, new MyModulatorData() { Height = distortionDefinition.Height, Modulator = modulator } ); } } }
private void PrepareRulesForBoxInternal(ref BoundingBox request) { if (m_rangeBiomes == null) m_rangeBiomes = new List<PlanetMaterialRule>[256]; BoundingBox box; request.Translate(-m_planetShape.Center()); // Inflate so we don't miss any rules. request.Inflate(request.Extents.Length() * .1f); GetRuleBounds(ref request, out box); foreach (var bio in m_biomes.Values) { if (Object.ReferenceEquals(m_rangeBiomes[bio.Value], bio.Rules) || m_rangeBiomes[bio.Value] == null || m_providerForRules != this) m_rangeBiomes[bio.Value] = new List<PlanetMaterialRule>(); m_rangeBiomes[bio.Value].Clear(); bio.MateriaTree.Query(delegate(int x) { m_rangeBiomes[bio.Value].Add(bio.MateriaTree.GetUserData<PlanetMaterialRule>(x)); return true; }, ref box); } m_rangeClean = false; m_providerForRules = this; }