Exemplo n.º 1
0
    //call automatical whenever one of scripts variables changes in its vector
    void OnValidate()
    {
        craterTypeNr = RandomizerType();

        //Generates a predefined Crater
        if (defaultCrater)
        {
            craters[craterTypeNr].ringWeight       = 6.91f;
            craters[craterTypeNr].ringWidth        = 0.04f;
            craters[craterTypeNr].falloffstart     = 0.07f;
            craters[craterTypeNr].falloffWeight    = 4.08f;
            craters[craterTypeNr].falloffIntensity = 0.82f;
            craters[craterTypeNr].stripeIntensity  = 0.381f;
            craters[craterTypeNr].stripeSin        = 4.97f;
            craters[craterTypeNr].stripeQuantity   = 2.69f;
            craters[craterTypeNr].stripeWidth      = 0.35f;
            craters[craterTypeNr].sinWIntensity    = 3.11f;
            craters[craterTypeNr].sinWCentress     = 1.49f;
            craters[craterTypeNr].sinWQuantity     = 0.1f;
            craters[craterTypeNr].sinWWidth        = 0.87f;
            craters[craterTypeNr].lineStart        = 0.65f;
            craters[craterTypeNr].lineIntensity    = 0.15f;
            craters[craterTypeNr].centralIntensity = 0.51f;
            craters[craterTypeNr].centralNoise     = 8.2f;
            craters[craterTypeNr].centralHeight    = 1.06f;
            craters[craterTypeNr].centralSize      = -0.12f;
            craters[craterTypeNr].centralPeakness  = -0.02f;
            craters[craterTypeNr].terraceIntensity = 0.21f;
            craters[craterTypeNr].terraceNoise     = 0;
            craters[craterTypeNr].terraceHeight    = 0.27f;
            craters[craterTypeNr].terraceSize      = 0.18f;
            craters[craterTypeNr].terracePeakness  = 0.39f;
        }

        //wont allow to drop values below that number
        if (lacunarity < 1)
        {
            lacunarity = 1;
        }
        if (octaves < 0)
        {
            octaves = 0;
        }
        if (craterSize < 0.01f)
        {
            craterSize = 0.01f;
        }
        if (ellipse.x < 0.01f)
        {
            ellipse.x = 0.01f;
        }
        if (ellipse.y < 0.01f)
        {
            ellipse.y = 0.01f;
        }
        if (craters[craterTypeNr].stripeSin < 0)
        {
            craters[craterTypeNr].stripeSin = 0;
        }
        if (craters[craterTypeNr].sinWIntensity < 0)
        {
            craters[craterTypeNr].sinWIntensity = 0;
        }
        if (craters[craterTypeNr].lineIntensity < 0)
        {
            craters[craterTypeNr].lineIntensity = 0;
        }
        if (craters[craterTypeNr].lineStart < 0)
        {
            craters[craterTypeNr].lineStart = 0;
        }
        if (craters[craterTypeNr].sinWWidth < 0)
        {
            craters[craterTypeNr].sinWWidth = 0;
        }
        if (pseudoPeaks < 0.01f)
        {
            pseudoPeaks = 0.01f;
        }
        if (pseudoIntensity < 0.001f)
        {
            pseudoIntensity = 0.001f;
        }
        if (pseudoVal < 0.01f)
        {
            pseudoVal = 0.01f;
        }
        if (octaves < 1)
        {
            octaves = 1;
        }

        //Dont forget to change Draw Mapeditor, too


        //craterRing = CraterRingGenerator.GenerateCraterRing(mapChunkSize, craterSize + craters[craterTypeNr].ringWidth,
        //    craterIntensity + craterSize + craters[craterTypeNr].ringWeight, position.x, position.y, ellipse.x, ellipse.y);



        //craterSidedParable = CraterSidedParable.GenerateCraterSidedParable(mapChunkSize, craters[craterTypeNr].diagScale, craters[craterTypeNr].diagParable, craters[craterTypeNr].diagDirection);



        craterPseudoRnd = CraterPseudoRndGenerator.GenerateCraterPseudoRnd(mapChunkSize, pseudoDensity, pseudoPeaks, pseudoVal);
    }
Exemplo n.º 2
0
    public void DrawMapInEditor()
    {
        craterTypeNr = RandomizerType();

        MapData mapData = GenerateMapData(Vector2.zero);

        MapDisplay display = FindObjectOfType <MapDisplay>(); //reference to mapdisplay, gives different options

        if (drawMode == DrawMode.NoiseMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(NoiseGenerator.GenerateNoiseMap(mapChunkSize + 2, mapChunkSize + 2, seed, noiseScale, octaves, persistance, lacunarity, Vector2.zero + offset, normalizeMode)));
        }
        if (drawMode == DrawMode.MixedHeightMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(mapData.heightMap));
        }
        else if (drawMode == DrawMode.ColourMap)
        {
            display.DrawTexture(TextureGenerator.ColourMapTexture(mapData.colourMap, mapChunkSize, mapChunkSize));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(MeshGenerator.GenerateTerrainMesh(mapData.heightMap, meshHeightMultiplier, meshHeightCurve, LOD),
                             TextureGenerator.ColourMapTexture(mapData.colourMap, mapChunkSize, mapChunkSize));
        }
        else if (drawMode == DrawMode.Crater)
        {
            display.DrawTexture(
                TextureGenerator.TextureFromHeightMap(CraterGenerator.GenerateCrater(mapChunkSize, craterSize, craterIntensity, position.x, position.y,
                                                                                     ellipse.x, ellipse.y)));
        }
        else if (drawMode == DrawMode.CraterRing)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(CraterRingGenerator.GenerateCraterRing(mapChunkSize, craterSize + craters[craterTypeNr].ringWidth,
                                                                                                             craterIntensity + craterSize + craters[craterTypeNr].ringWeight, position.x, position.y, ellipse.x, ellipse.y)));
        }
        else if (drawMode == DrawMode.CraterFalloff)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(CraterFalloffGenerator.GenerateCraterFalloff(mapChunkSize, craterSize + craters[craterTypeNr].ringWidth + craters[craterTypeNr].falloffstart,
                                                                                                                   craterIntensity + craterSize + craters[craterTypeNr].falloffWeight, position.x, position.y, ellipse.x, ellipse.y)));
        }
        else if (drawMode == DrawMode.CraterStripes)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(CraterStripesGenerator.GenerateCraterStripes(mapChunkSize, craters[craterTypeNr].stripeSin, craters[craterTypeNr].stripeQuantity)));
        }
        else if (drawMode == DrawMode.CraterSinW)
        {
            display.DrawTexture(
                TextureGenerator.TextureFromHeightMap(CraterSinW.GenerateCraterSinW(mapChunkSize, craters[craterTypeNr].sinWCentress, position.x, position.y, ellipse.x, ellipse.y, craters[craterTypeNr].sinWQuantity)));
        }
        else if (drawMode == DrawMode.CraterQuadFalloff)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(CraterQuadFalloffGenerator.GenerateCraterQuadFalloff(mapChunkSize, position.x, position.y, craters[craterTypeNr].lineStart, 0)));
        }
        //else if (drawMode == DrawMode.CraterSidedParable)
        //{
        //    display.DrawTexture(TextureGenerator.TextureFromHeightMap(CraterSidedParable.GenerateCraterSidedParable(mapChunkSize, craters[craterTypeNr].diagScale, craters[craterTypeNr].diagParable, craters[craterTypeNr].diagDirection)));
        //}
        else if (drawMode == DrawMode.CraterCentralPeak)
        {
            display.DrawTexture(
                TextureGenerator.TextureFromHeightMap(CraterCentralPeak.GenerateCreaterCentralPeak(mapChunkSize, craters[craterTypeNr].centralSize, craters[craterTypeNr].centralPeakness, position.x + craters[craterTypeNr].centralPosition.x, position.y + craters[craterTypeNr].centralPosition.y, ellipse.x,
                                                                                                   ellipse.y)));
        }
        else if (drawMode == DrawMode.CraterTerrace)
        {
            display.DrawTexture(
                TextureGenerator.TextureFromHeightMap(CraterTerrace.GenerateCraterTerrace(mapChunkSize, craters[craterTypeNr].terraceSize, craters[craterTypeNr].terracePeakness, position.x + craters[craterTypeNr].terracePosition.x, position.y + craters[craterTypeNr].terracePosition.y, ellipse.x,
                                                                                          ellipse.y)));
        }
        else if (drawMode == DrawMode.CraterPseudoRnd)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(CraterPseudoRndGenerator.GenerateCraterPseudoRnd(mapChunkSize, pseudoDensity, pseudoPeaks, pseudoVal)));
        }
    }