Esempio n. 1
0
            public PlanetBiome(MyPlanetMaterialGroup group)
            {
                Value = group.Value;

                Name = group.Name;

                Rules = new List <PlanetMaterialRule>(group.MaterialRules.Length);

                for (int i = 0; i < group.MaterialRules.Length; i++)
                {
                    Rules.Add(new PlanetMaterialRule(group.MaterialRules[i]));
                }

                MateriaTree = new MyDynamicAABBTree(Vector3.Zero);

                foreach (var rule in Rules)
                {
                    BoundingBox bb = new BoundingBox(new Vector3(rule.Height.Min, rule.Latitude.Min, rule.Longitude.Min), new Vector3(rule.Height.Max, rule.Latitude.Max, rule.Longitude.Max));
                    MateriaTree.AddProxy(ref bb, rule, 0);
                    if (rule.Latitude.Mirror)
                    {
                        float min = -bb.Max.Y;
                        bb.Max.Y = -bb.Min.Y;
                        bb.Min.Y = min;
                        MateriaTree.AddProxy(ref bb, rule, 0);
                    }
                }
            }
Esempio n. 2
0
 public PlanetBiome(MyPlanetMaterialGroup group, float minimumSurfaceLayerDepth)
 {
     this.Value = group.Value;
     this.Name  = group.Name;
     this.Rules = new List <MyPlanetMaterialProvider.PlanetMaterialRule>(group.MaterialRules.Length);
     for (int i = 0; i < group.MaterialRules.Length; i++)
     {
         this.Rules.Add(new MyPlanetMaterialProvider.PlanetMaterialRule(group.MaterialRules[i], i, minimumSurfaceLayerDepth));
     }
     this.MateriaTree = new MyDynamicAABBTree(Vector3.Zero, 1f);
     foreach (MyPlanetMaterialProvider.PlanetMaterialRule rule in this.Rules)
     {
         BoundingBox aabb = new BoundingBox(new Vector3(rule.Height.Min, rule.Latitude.Min, rule.Longitude.Min), new Vector3(rule.Height.Max, rule.Latitude.Max, rule.Longitude.Max));
         this.MateriaTree.AddProxy(ref aabb, rule, 0, true);
         if (rule.Latitude.Mirror)
         {
             float num2 = -aabb.Max.Y;
             aabb.Max.Y = -aabb.Min.Y;
             aabb.Min.Y = num2;
             this.MateriaTree.AddProxy(ref aabb, rule, 0, true);
         }
     }
 }
Esempio n. 3
0
        protected override unsafe void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);
            MyObjectBuilder_PlanetGeneratorDefinition definition = builder as MyObjectBuilder_PlanetGeneratorDefinition;

            if ((definition.InheritFrom != null) && (definition.InheritFrom.Length > 0))
            {
                this.InheritFrom(definition.InheritFrom);
            }
            if (definition.Environment != null)
            {
                this.EnvironmentId = new MyDefinitionId?(definition.Environment.Value);
            }
            else
            {
                this.m_pgob = definition;
            }
            if (definition.PlanetMaps != null)
            {
                this.PlanetMaps = definition.PlanetMaps.Value;
            }
            if (definition.HasAtmosphere != null)
            {
                this.HasAtmosphere = definition.HasAtmosphere.Value;
            }
            if (definition.CloudLayers != null)
            {
                this.CloudLayers = definition.CloudLayers;
            }
            if (definition.SoundRules != null)
            {
                this.SoundRules = new MyPlanetEnvironmentalSoundRule[definition.SoundRules.Length];
                for (int i = 0; i < definition.SoundRules.Length; i++)
                {
                    MyPlanetEnvironmentalSoundRule rule = new MyPlanetEnvironmentalSoundRule {
                        Latitude           = definition.SoundRules[i].Latitude,
                        Height             = definition.SoundRules[i].Height,
                        SunAngleFromZenith = definition.SoundRules[i].SunAngleFromZenith,
                        EnvironmentSound   = MyStringHash.GetOrCompute(definition.SoundRules[i].EnvironmentSound)
                    };
                    rule.Latitude.ConvertToSine();
                    rule.SunAngleFromZenith.ConvertToCosine();
                    this.SoundRules[i] = rule;
                }
            }
            if (definition.MusicCategories != null)
            {
                this.MusicCategories = definition.MusicCategories;
            }
            if (definition.HillParams != null)
            {
                this.HillParams = definition.HillParams.Value;
            }
            if (definition.Atmosphere != null)
            {
                this.Atmosphere = definition.Atmosphere;
            }
            if (definition.GravityFalloffPower != null)
            {
                this.GravityFalloffPower = definition.GravityFalloffPower.Value;
            }
            if (definition.HostileAtmosphereColorShift != null)
            {
                this.HostileAtmosphereColorShift = definition.HostileAtmosphereColorShift;
            }
            if (definition.MaterialsMaxDepth != null)
            {
                this.MaterialsMaxDepth = definition.MaterialsMaxDepth.Value;
            }
            if (definition.MaterialsMinDepth != null)
            {
                this.MaterialsMinDepth = definition.MaterialsMinDepth.Value;
            }
            if ((definition.CustomMaterialTable != null) && (definition.CustomMaterialTable.Length != 0))
            {
                this.SurfaceMaterialTable = new MyPlanetMaterialDefinition[definition.CustomMaterialTable.Length];
                for (int i = 0; i < this.SurfaceMaterialTable.Length; i++)
                {
                    this.SurfaceMaterialTable[i] = definition.CustomMaterialTable[i].Clone() as MyPlanetMaterialDefinition;
                    if ((this.SurfaceMaterialTable[i].Material == null) && !this.SurfaceMaterialTable[i].HasLayers)
                    {
                        MyLog.Default.WriteLine("Custom material does not contain any material ids.");
                    }
                    else if (this.SurfaceMaterialTable[i].HasLayers)
                    {
                        float depth = this.SurfaceMaterialTable[i].Layers[0].Depth;
                        for (int j = 1; j < this.SurfaceMaterialTable[i].Layers.Length; j++)
                        {
                            float *singlePtr1 = (float *)ref this.SurfaceMaterialTable[i].Layers[j].Depth;
                            singlePtr1[0] += depth;
                            depth          = this.SurfaceMaterialTable[i].Layers[j].Depth;
                        }
                    }
                }
            }
            if ((definition.DistortionTable != null) && (definition.DistortionTable.Length != 0))
            {
                this.DistortionTable = definition.DistortionTable;
            }
            if (definition.DefaultSurfaceMaterial != null)
            {
                this.DefaultSurfaceMaterial = definition.DefaultSurfaceMaterial;
            }
            if (definition.DefaultSubSurfaceMaterial != null)
            {
                this.DefaultSubSurfaceMaterial = definition.DefaultSubSurfaceMaterial;
            }
            if (definition.SurfaceGravity != null)
            {
                this.SurfaceGravity = definition.SurfaceGravity.Value;
            }
            if (definition.AtmosphereSettings != null)
            {
                this.AtmosphereSettings = definition.AtmosphereSettings;
            }
            this.FolderName = (definition.FolderName != null) ? definition.FolderName : definition.Id.SubtypeName;
            if ((definition.ComplexMaterials != null) && (definition.ComplexMaterials.Length != 0))
            {
                this.MaterialGroups = new MyPlanetMaterialGroup[definition.ComplexMaterials.Length];
                int index = 0;
                while (index < definition.ComplexMaterials.Length)
                {
                    this.MaterialGroups[index] = definition.ComplexMaterials[index].Clone() as MyPlanetMaterialGroup;
                    MyPlanetMaterialGroup           group         = this.MaterialGroups[index];
                    MyPlanetMaterialPlacementRule[] materialRules = group.MaterialRules;
                    List <int> indices = new List <int>();
                    int        num6    = 0;
                    while (true)
                    {
                        if (num6 >= materialRules.Length)
                        {
                            if (indices.Count > 0)
                            {
                                materialRules = materialRules.RemoveIndices <MyPlanetMaterialPlacementRule>(indices);
                            }
                            group.MaterialRules = materialRules;
                            index++;
                            break;
                        }
                        if ((materialRules[num6].Material == null) && ((materialRules[num6].Layers == null) || (materialRules[num6].Layers.Length == 0)))
                        {
                            MyLog.Default.WriteLine("Material rule does not contain any material ids.");
                            indices.Add(num6);
                        }
                        else
                        {
                            if ((materialRules[num6].Layers != null) && (materialRules[num6].Layers.Length != 0))
                            {
                                float depth = materialRules[num6].Layers[0].Depth;
                                for (int i = 1; i < materialRules[num6].Layers.Length; i++)
                                {
                                    float *singlePtr2 = (float *)ref materialRules[num6].Layers[i].Depth;
                                    singlePtr2[0] += depth;
                                    depth          = materialRules[num6].Layers[i].Depth;
                                }
                            }
                            materialRules[num6].Slope.ConvertToCosine();
                            materialRules[num6].Latitude.ConvertToSine();
                            materialRules[num6].Longitude.ConvertToCosineLongitude();
                        }
                        num6++;
                    }
                }
            }
            if (definition.OreMappings != null)
            {
                this.OreMappings = definition.OreMappings;
            }
            if (definition.MaterialBlending != null)
            {
                this.MaterialBlending = definition.MaterialBlending.Value;
            }
            if (definition.SurfaceDetail != null)
            {
                this.Detail = definition.SurfaceDetail;
            }
            if (definition.AnimalSpawnInfo != null)
            {
                this.AnimalSpawnInfo = definition.AnimalSpawnInfo;
            }
            if (definition.NightAnimalSpawnInfo != null)
            {
                this.NightAnimalSpawnInfo = definition.NightAnimalSpawnInfo;
            }
            if (definition.SectorDensity != null)
            {
                this.SectorDensity = definition.SectorDensity.Value;
            }
            MyObjectBuilder_PlanetMapProvider mapProvider = definition.MapProvider;

            if (definition.MapProvider == null)
            {
                MyObjectBuilder_PlanetMapProvider        local1    = definition.MapProvider;
                MyObjectBuilder_PlanetTextureMapProvider provider1 = new MyObjectBuilder_PlanetTextureMapProvider();
                provider1.Path = this.FolderName;
                mapProvider    = provider1;
            }
            this.MapProvider          = mapProvider;
            this.MesherPostprocessing = definition.MesherPostprocessing;
            if (this.MesherPostprocessing == null)
            {
                MyLog.Default.Warning("PERFORMANCE WARNING: Postprocessing voxel triangle decimation steps not defined for " + this, Array.Empty <object>());
            }
            this.MinimumSurfaceLayerDepth = definition.MinimumSurfaceLayerDepth;
        }