/// <summary>
        /// Returns a unique list of all VegetationPackages used in the scene.
        /// </summary>
        /// <returns></returns>
        public static List <VegetationPackagePro> GetVegetationPackageList(BiomeType biomeType)
        {
            List <VegetationPackagePro> vegetationPackageList = new List <VegetationPackagePro>();

            if (!Instance)
            {
                FindInstance();
            }

            if (!Instance)
            {
                return(vegetationPackageList);
            }

            for (int i = 0; i <= Instance.VegetationSystemList.Count - 1; i++)
            {
                VegetationSystemPro vegetationSystemPro = Instance.VegetationSystemList[i];
                if (vegetationSystemPro)
                {
                    VegetationPackagePro vegetationPackagePro =
                        vegetationSystemPro.GetVegetationPackageFromBiome(biomeType);
                    if (vegetationPackagePro)
                    {
                        vegetationPackageList.Add(vegetationPackagePro);
                    }
                }
            }

            return(vegetationPackageList);
        }
Ejemplo n.º 2
0
        public void GenerateSplatMap(bool clearLockedTextures, IVegetationStudioTerrain iVegetationStudioTerrain)
        {
            if (!VegetationSystemPro)
            {
                return;
            }

            VegetationSystemPro.ClearCache(iVegetationStudioTerrain.TerrainBounds);
            PrepareTextureCurves();

            float worldspaceMinHeight = VegetationSystemPro.VegetationSystemBounds.center.y -
                                        VegetationSystemPro.VegetationSystemBounds.extents.y;
            float worldspaceSeaLevel  = worldspaceMinHeight + VegetationSystemPro.SeaLevel;
            float worldspaceMaxHeight = VegetationSystemPro.VegetationSystemBounds.center.y +
                                        VegetationSystemPro.VegetationSystemBounds.extents.y;
            float heightCurveSampleHeight = worldspaceMaxHeight - worldspaceSeaLevel;

            VegetationPackagePro defaultBiomeVegetationPackagePro =
                VegetationSystemPro.GetVegetationPackageFromBiome(BiomeType.Default);

            if (defaultBiomeVegetationPackagePro == null)
            {
                Debug.LogWarning("You need a default biome in order to generate splatmaps. ");
                return;
            }

            iVegetationStudioTerrain.PrepareSplatmapGeneration(clearLockedTextures);

            iVegetationStudioTerrain.GenerateSplatMapBiome(VegetationSystemPro.VegetationSystemBounds,
                                                           BiomeType.Default, null, defaultBiomeVegetationPackagePro.TerrainTextureSettingsList,
                                                           heightCurveSampleHeight, worldspaceSeaLevel, clearLockedTextures);

            List <BiomeType> additionalBiomeList = VegetationSystemPro.GetAdditionalBiomeList();

            List <VegetationPackagePro> additionalVegetationPackageList = new List <VegetationPackagePro>();

            for (int i = 0; i <= additionalBiomeList.Count - 1; i++)
            {
                additionalVegetationPackageList.Add(
                    VegetationSystemPro.GetVegetationPackageFromBiome(additionalBiomeList[i]));
            }
            BiomeSortOrderComparer biomeSortOrderComparer = new BiomeSortOrderComparer();

            additionalVegetationPackageList.Sort(biomeSortOrderComparer);

            for (int i = 0; i <= additionalVegetationPackageList.Count - 1; i++)
            {
                VegetationPackagePro currentVegetationPackagePro = additionalVegetationPackageList[i];
                if (!currentVegetationPackagePro.GenerateBiomeSplamap)
                {
                    continue;
                }

                List <PolygonBiomeMask> biomeMaskList = VegetationStudioManager.GetBiomeMasks(currentVegetationPackagePro.BiomeType);
                iVegetationStudioTerrain.GenerateSplatMapBiome(VegetationSystemPro.VegetationSystemBounds,
                                                               currentVegetationPackagePro.BiomeType, biomeMaskList, currentVegetationPackagePro.TerrainTextureSettingsList, heightCurveSampleHeight, worldspaceSeaLevel, clearLockedTextures);
            }

            JobHandle.ScheduleBatchedJobs();
            iVegetationStudioTerrain.CompleteSplatmapGeneration();
            DisposeTextureCurves();
        }
Ejemplo n.º 3
0
        public void GenerateSplatMap(bool clearLockedTextures)
        {
            if (!VegetationSystemPro)
            {
                return;
            }

            VegetationSystemPro.ClearCache();

            List <IVegetationStudioTerrain> overlapTerrainList =
                GetOverlapTerrainList(VegetationSystemPro.VegetationSystemBounds);

            PrepareTextureCurves();

            float worldspaceMinHeight = VegetationSystemPro.VegetationSystemBounds.center.y -
                                        VegetationSystemPro.VegetationSystemBounds.extents.y;
            float worldspaceSeaLevel  = worldspaceMinHeight + VegetationSystemPro.SeaLevel;
            float worldspaceMaxHeight = VegetationSystemPro.VegetationSystemBounds.center.y +
                                        VegetationSystemPro.VegetationSystemBounds.extents.y;
            float heightCurveSampleHeight = worldspaceMaxHeight - worldspaceSeaLevel;


            VegetationPackagePro defaultBiomeVegetationPackagePro =
                VegetationSystemPro.GetVegetationPackageFromBiome(BiomeType.Default);

            if (defaultBiomeVegetationPackagePro == null)
            {
                Debug.LogWarning("You need a default biome in order to generate splatmaps. ");
                return;
            }

            int terrainCount = overlapTerrainList.Count;

            for (int i = 0; i <= overlapTerrainList.Count - 1; i++)
            {
                overlapTerrainList[i].PrepareSplatmapGeneration(clearLockedTextures);
#if UNITY_EDITOR
                EditorUtility.DisplayProgressBar("Prepare generation",
                                                 "Terrain " + (i + 1) + "/" + terrainCount, (i + 1) / (float)terrainCount);
#endif
            }

            for (int i = 0; i <= overlapTerrainList.Count - 1; i++)
            {
                overlapTerrainList[i].GenerateSplatMapBiome(VegetationSystemPro.VegetationSystemBounds,
                                                            BiomeType.Default, null, defaultBiomeVegetationPackagePro.TerrainTextureSettingsList, heightCurveSampleHeight, worldspaceSeaLevel, clearLockedTextures);

#if UNITY_EDITOR
                EditorUtility.DisplayProgressBar("Generating default biome",
                                                 "Terrain " + (i + 1) + "/" + terrainCount, (i + 1) / (float)terrainCount);
#endif
            }

            List <BiomeType> additionalBiomeList = VegetationSystemPro.GetAdditionalBiomeList();


            List <VegetationPackagePro> additionalVegetationPackageList = new List <VegetationPackagePro>();
            for (int i = 0; i <= additionalBiomeList.Count - 1; i++)
            {
                additionalVegetationPackageList.Add(
                    VegetationSystemPro.GetVegetationPackageFromBiome(additionalBiomeList[i]));
            }
            BiomeSortOrderComparer biomeSortOrderComparer = new BiomeSortOrderComparer();
            additionalVegetationPackageList.Sort(biomeSortOrderComparer);

            for (int i = 0; i <= additionalVegetationPackageList.Count - 1; i++)
            {
                VegetationPackagePro currentVegetationPackagePro = additionalVegetationPackageList[i];

                List <PolygonBiomeMask> biomeMaskList = VegetationStudioManager.GetBiomeMasks(currentVegetationPackagePro.BiomeType);
                for (int j = 0; j <= overlapTerrainList.Count - 1; j++)
                {
                    overlapTerrainList[j].GenerateSplatMapBiome(VegetationSystemPro.VegetationSystemBounds,
                                                                currentVegetationPackagePro.BiomeType, biomeMaskList, currentVegetationPackagePro.TerrainTextureSettingsList, heightCurveSampleHeight, worldspaceSeaLevel, clearLockedTextures);
                }
            }

            JobHandle.ScheduleBatchedJobs();


            for (int i = 0; i <= overlapTerrainList.Count - 1; i++)
            {
#if UNITY_EDITOR
                EditorUtility.DisplayProgressBar("Updating terrain",
                                                 "Terrain " + (i + 1) + "/" + terrainCount, (i + 1) / (float)terrainCount);
      #endif
                overlapTerrainList[i].CompleteSplatmapGeneration();
            }
#if UNITY_EDITOR
            EditorUtility.ClearProgressBar();
#endif
            DisposeTextureCurves();
        }