コード例 #1
0
        public void Generate(System.Random r)
        {
            switch (Type)
            {
            case 0:                     // OFF
                break;

            case 1:                     // Square Diamond
                sd = new SquareDiamond(512, r);
                int blur   = (int)Mathf.Pow(2.0f, Blur) + 1;
                int smooth = (int)Mathf.Pow(2.0f, Smoothness);
                sd.GenerateRandom(smooth, (double)Scale);
                //(256, 1.0f, SquareDiamond.InitMode.INIT_RANDOM, SquareDiamond.InitMode.INIT_RANDOM, SquareDiamond.InitMode.INIT_RANDOM, SquareDiamond.InitMode.INIT_RANDOM);
                if (Blur > 0)
                {
                    sd.Blur(blur);
                }
                sd.Normalize();
                Debug.Log("Generated Square Diamond Heightmap. Smoothness: " + smooth + " Scale: " + Scale + " Blur: " + blur);
                break;

            case 2:                     // Perlin Noise
                pn = new PerlinNoise(513);
                pn.Generate(PNFreq, PNScale, (int)PNOct);
                break;

            case 3:                     // Sine
                si = new Sine(513);
                si.Generate(SIFrequency, SIScale);
                break;
            }
        }
コード例 #2
0
ファイル: Heightmap.cs プロジェクト: tomarus/unity-terrainlib
 public void Generate(System.Random r)
 {
     switch (Type)
     {
         case 0: // OFF
             break;
         case 1: // Square Diamond
             sd = new SquareDiamond(512, r);
             int blur = (int)Mathf.Pow(2.0f, Blur) + 1;
             int smooth = (int)Mathf.Pow(2.0f, Smoothness);
             sd.GenerateRandom(smooth, (double)Scale);
             //(256, 1.0f, SquareDiamond.InitMode.INIT_RANDOM, SquareDiamond.InitMode.INIT_RANDOM, SquareDiamond.InitMode.INIT_RANDOM, SquareDiamond.InitMode.INIT_RANDOM);
             if (Blur > 0)
                 sd.Blur(blur);
             sd.Normalize();
             Debug.Log("Generated Square Diamond Heightmap. Smoothness: " + smooth + " Scale: " + Scale + " Blur: " + blur);
             break;
         case 2: // Perlin Noise
             pn = new PerlinNoise(513);
             pn.Generate(PNFreq, PNScale, (int)PNOct);
             break;
         case 3: // Sine
             si = new Sine(513);
             si.Generate(SIFrequency, SIScale);
             break;
     }
 }