Exemplo n.º 1
0
 public void setWindErosionPreset(windErosionPresetData preset)
 {
     erosionTypeInt = 3;
     erosionType = ErosionType.Wind;
     windIterations = preset.windIterations;
     windDirection = preset.windDirection;
     windForce = preset.windForce;
     windLift = preset.windLift;
     windGravity = preset.windGravity;
     windCapacity = preset.windCapacity;
     windEntropy = preset.windEntropy;
     windSmoothing = preset.windSmoothing;
 }
Exemplo n.º 2
0
 public void setTidalErosionPreset(tidalErosionPresetData preset)
 {
     erosionTypeInt = 2;
     erosionType = ErosionType.Tidal;
     tidalIterations = preset.tidalIterations;
     tidalRangeAmount = preset.tidalRangeAmount;
     tidalCliffLimit = preset.tidalCliffLimit;
 }
Exemplo n.º 3
0
 public void setVelocityHydraulicErosionPreset(velocityHydraulicErosionPresetData preset)
 {
     erosionTypeInt = 1;
     erosionType = ErosionType.Hydraulic;
     hydraulicTypeInt = 2;
     hydraulicType = HydraulicType.Velocity;
     hydraulicIterations = preset.hydraulicIterations;
     hydraulicVelocityRainfall = preset.hydraulicVelocityRainfall;
     hydraulicVelocityEvaporation = preset.hydraulicVelocityEvaporation;
     hydraulicVelocitySedimentSolubility = preset.hydraulicVelocitySedimentSolubility;
     hydraulicVelocitySedimentSaturation = preset.hydraulicVelocitySedimentSaturation;
     hydraulicVelocity = preset.hydraulicVelocity;
     hydraulicMomentum = preset.hydraulicMomentum;
     hydraulicEntropy = preset.hydraulicEntropy;
     hydraulicDowncutting = preset.hydraulicDowncutting;
 }
Exemplo n.º 4
0
 public void setFullHydraulicErosionPreset(fullHydraulicErosionPresetData preset)
 {
     erosionTypeInt = 1;
     erosionType = ErosionType.Hydraulic;
     hydraulicTypeInt = 1;
     hydraulicType = HydraulicType.Full;
     hydraulicIterations = preset.hydraulicIterations;
     hydraulicRainfall = preset.hydraulicRainfall;
     hydraulicEvaporation = preset.hydraulicEvaporation;
     hydraulicSedimentSolubility = preset.hydraulicSedimentSolubility;
     hydraulicSedimentSaturation = preset.hydraulicSedimentSaturation;
 }
Exemplo n.º 5
0
 public void setThermalErosionPreset(thermalErosionPresetData preset)
 {
     erosionTypeInt = 0;
     erosionType = ErosionType.Thermal;
     thermalIterations = preset.thermalIterations;
     thermalMinSlope = preset.thermalMinSlope;
     thermalFalloff = preset.thermalFalloff;
 }
Exemplo n.º 6
0
 public void FullHydraulicErosion(int iterations, float rainfall, float evaporation, float solubility, float saturation)
 {
     erosionTypeInt = 1;
     erosionType = ErosionType.Hydraulic;
     hydraulicTypeInt = 1;
     hydraulicType = HydraulicType.Full;
     hydraulicIterations = iterations;
     hydraulicRainfall = rainfall;
     hydraulicEvaporation = evaporation;
     hydraulicSedimentSolubility = solubility;
     hydraulicSedimentSaturation = saturation;
     neighbourhood = Neighbourhood.Moore;
     ErosionProgressDelegate erosionProgressDelegate = new ErosionProgressDelegate(dummyErosionProgress);
     erodeAllTerrain(erosionProgressDelegate);
 }
Exemplo n.º 7
0
 public void setFastHydraulicErosionPreset(fastHydraulicErosionPresetData preset)
 {
     erosionTypeInt = 1;
     erosionType = ErosionType.Hydraulic;
     hydraulicTypeInt = 0;
     hydraulicType = HydraulicType.Fast;
     hydraulicIterations = preset.hydraulicIterations;
     hydraulicMaxSlope = preset.hydraulicMaxSlope;
     hydraulicFalloff = preset.hydraulicFalloff;
 }
Exemplo n.º 8
0
 public void FastHydraulicErosion(int iterations, float maxSlope, float blendAmount)
 {
     erosionTypeInt = 1;
     erosionType = ErosionType.Hydraulic;
     hydraulicTypeInt = 0;
     hydraulicType = HydraulicType.Fast;
     hydraulicIterations = iterations;
     hydraulicMaxSlope = maxSlope;
     hydraulicFalloff = blendAmount;
     neighbourhood = Neighbourhood.Moore;
     ErosionProgressDelegate erosionProgressDelegate = new ErosionProgressDelegate(dummyErosionProgress);
     erodeAllTerrain(erosionProgressDelegate);
 }
Exemplo n.º 9
0
 // -------------------------------------------------------------------------------------------------------- API FUNCTIONS
 public void FastThermalErosion(int iterations, float minSlope, float blendAmount)
 {
     erosionTypeInt = 0;
     erosionType = ErosionType.Thermal;
     thermalIterations = iterations;
     thermalMinSlope = minSlope;
     thermalFalloff = blendAmount;
     neighbourhood = Neighbourhood.Moore;
     ErosionProgressDelegate erosionProgressDelegate = new ErosionProgressDelegate(dummyErosionProgress);
     erodeAllTerrain(erosionProgressDelegate);
 }
Exemplo n.º 10
0
 // -------------------------------------------------------------------------------------------------------- UTILITIES
 private void convertIntVarsToEnums()
 {
     switch (erosionTypeInt) {
         case 0:
         erosionType = ErosionType.Thermal;
         break;
         case 1:
         erosionType = ErosionType.Hydraulic;
         break;
         case 2:
         erosionType = ErosionType.Tidal;
         break;
         case 3:
         erosionType = ErosionType.Wind;
         break;
         case 4:
         erosionType = ErosionType.Glacial;
         break;
     }
     switch (hydraulicTypeInt) {
         case 0:
         hydraulicType = HydraulicType.Fast;
         break;
         case 1:
         hydraulicType = HydraulicType.Full;
         break;
         case 2:
         hydraulicType = HydraulicType.Velocity;
         break;
     }
     switch (generatorTypeInt) {
         case 0:
         generatorType = GeneratorType.Voronoi;
         break;
         case 1:
         generatorType = GeneratorType.DiamondSquare;
         break;
         case 2:
         generatorType = GeneratorType.Perlin;
         break;
         case 3:
         generatorType = GeneratorType.Smooth;
         break;
         case 4:
         generatorType = GeneratorType.Normalise;
         break;
     }
     switch (voronoiTypeInt) {
         case 0:
         voronoiType = VoronoiType.Linear;
         break;
         case 1:
         voronoiType = VoronoiType.Sine;
         break;
         case 2:
         voronoiType = VoronoiType.Tangent;
         break;
     }
     switch (neighbourhoodInt) {
         case 0:
         neighbourhood = Neighbourhood.Moore;
         break;
         case 1:
         neighbourhood = Neighbourhood.VonNeumann;
         break;
     }
 }
Exemplo n.º 11
0
 public void WindErosion(int iterations, float direction, float force, float lift, float gravity, float capacity, float entropy, float smoothing)
 {
     erosionTypeInt = 3;
     erosionType = ErosionType.Wind;
     windIterations = iterations;
     windDirection = direction;
     windForce = force;
     windLift = lift;
     windGravity = gravity;
     windCapacity = capacity;
     windEntropy = entropy;
     windSmoothing = smoothing;
     neighbourhood = Neighbourhood.Moore;
     ErosionProgressDelegate erosionProgressDelegate = new ErosionProgressDelegate(dummyErosionProgress);
     erodeAllTerrain(erosionProgressDelegate);
 }
Exemplo n.º 12
0
 public void VelocityHydraulicErosion(int iterations, float rainfall, float evaporation, float solubility, float saturation, float velocity, float momentum, float entropy, float downcutting)
 {
     erosionTypeInt = 1;
     erosionType = ErosionType.Hydraulic;
     hydraulicTypeInt = 2;
     hydraulicType = HydraulicType.Velocity;
     hydraulicIterations = iterations;
     hydraulicVelocityRainfall = rainfall;
     hydraulicVelocityEvaporation = evaporation;
     hydraulicVelocitySedimentSolubility = solubility;
     hydraulicVelocitySedimentSaturation = saturation;
     hydraulicVelocity = velocity;
     hydraulicMomentum = momentum;
     hydraulicEntropy = entropy;
     hydraulicDowncutting = downcutting;
     neighbourhood = Neighbourhood.Moore;
     ErosionProgressDelegate erosionProgressDelegate = new ErosionProgressDelegate(dummyErosionProgress);
     erodeAllTerrain(erosionProgressDelegate);
 }
Exemplo n.º 13
0
 public void TidalErosion(int iterations, float seaLevel, float tidalRange, float cliffLimit)
 {
     erosionTypeInt = 2;
     erosionType = ErosionType.Tidal;
     tidalIterations = iterations;
     tidalSeaLevel = seaLevel;
     tidalRangeAmount = tidalRange;
     tidalCliffLimit = cliffLimit;
     neighbourhood = Neighbourhood.Moore;
     ErosionProgressDelegate erosionProgressDelegate = new ErosionProgressDelegate(dummyErosionProgress);
     erodeAllTerrain(erosionProgressDelegate);
 }
Exemplo n.º 14
0
    // Redraws the menu on each GUI draw
    void OnGUI()
    {
        // Field to attach the terrain to generate too.
        GUILayout.Label("Terrain Generator", EditorStyles.boldLabel);
        GUILayout.Space(16);
        terrain = (GameObject)EditorGUILayout.ObjectField("Terrain", terrain, typeof(UnityEngine.Object), true);

        //================= Terrain Generation =================\\
        GUILayout.Space(16);
        GUILayout.Label("Generation:", EditorStyles.boldLabel);

        // Select Algorithm and show options
        type = (AlgorithmType)EditorGUILayout.EnumPopup("Algorithm to Use:", type);
        switch (type)
        {
        case AlgorithmType.Random:
            ShowRandomGuiOptions();
            break;

        case AlgorithmType.Perlin:
            ShowPerlinGuiOptions();
            break;

        case AlgorithmType.DiamondSquare:
            ShowDiamondSquareGuiOptions();
            break;
        }

        // Run selected algorithm if possible
        if (GUILayout.Button("Generate!"))
        {
            if (terrain == null || terrain.GetComponent <Terrain>() == null)
            {
                ShowNotification(new GUIContent("Terrain Field is empty or not a valid Terrain!"));
            }
            else
            {
                // Set the undo array
                Terrain     ter         = terrain.GetComponent <Terrain>();
                TerrainData terrainData = ter.terrainData;
                int         w           = terrainData.heightmapWidth;
                int         h           = terrainData.heightmapWidth;

                undoArray = terrainData.GetHeights(0, 0, w, h);

                switch (type)
                {
                case AlgorithmType.Random:
                    randomGen.Generate(terrain);
                    break;

                case AlgorithmType.Perlin:
                    perlinGen.Generate(terrain);
                    break;

                case AlgorithmType.DiamondSquare:
                    diamondSquareGen.Generate(terrain);
                    break;
                }
            }
        }

        //================= Erosion Generation =================\\
        GUILayout.Space(16);
        GUILayout.Label("Erosion:", EditorStyles.boldLabel);
        erodeType = (ErosionType)EditorGUILayout.EnumPopup("Algorithm to Use:", erodeType);

        // Select erosion type
        switch (erodeType)
        {
        case ErosionType.Thermal:
            ShowThermalGuiOptions();
            break;

        case ErosionType.ImprovedThermal:
            ShowImprovedThermalGuiOptions();
            break;
        }

        // Erode if possible
        if (GUILayout.Button("Erode!"))
        {
            if (terrain == null || terrain.GetComponent <Terrain>() == null)
            {
                ShowNotification(new GUIContent("Terrain Field is empty or not a valid Terrain!"));
            }
            else
            {
                // Set the undo array
                Terrain     ter         = terrain.GetComponent <Terrain>();
                TerrainData terrainData = ter.terrainData;
                int         w           = terrainData.heightmapWidth;
                int         h           = terrainData.heightmapWidth;

                undoArray = terrainData.GetHeights(0, 0, w, h);
                switch (erodeType)
                {
                case ErosionType.Thermal:
                    thermalGen.Erode(terrain);
                    break;

                case ErosionType.ImprovedThermal:
                    improvedThermalGen.Erode(terrain);
                    break;
                }
            }
        }

        //================= Smoothing =================\\
        GUILayout.Space(16);
        GUILayout.Label("Smooth:", EditorStyles.boldLabel);
        smoothenIterations = EditorGUILayout.IntField("Iterations: ", smoothenIterations);

        if (GUILayout.Button("Smooth!"))
        {
            // Set the undo array
            Terrain     ter         = terrain.GetComponent <Terrain>();
            TerrainData terrainData = ter.terrainData;
            int         w           = terrainData.heightmapWidth;
            int         h           = terrainData.heightmapWidth;

            undoArray = terrainData.GetHeights(0, 0, w, h);

            Smoother.Smoothen(terrain, smoothenIterations);
        }


        //================= Undo =================\\
        GUILayout.Space(16);
        if (GUILayout.Button("Undo Last Action!"))
        {
            if (terrain == null || terrain.GetComponent <Terrain>() == null || undoArray == null)
            {
                ShowNotification(new GUIContent("Can't undo!"));
            }
            else
            {
                Terrain     ter         = terrain.GetComponent <Terrain>();
                TerrainData terrainData = ter.terrainData;
                terrainData.SetHeights(0, 0, undoArray);
            }
        }
    }