コード例 #1
0
ファイル: WorldGenerator.cs プロジェクト: fenixnix/Fractals
 public void DrawPolyWorld()
 {
     Noise.NoiseAtom na = new Noise.NoiseAtom();
     na.Init(4, 0.5f, 2f, scale, offset);
     polyWorld.InitWorld(voronoi, na);
     worldMesh.Init();
     foreach (var r in polyWorld.regions)
     {
         //var ll = na.NoiseValue((r.position.x + noisePosition.x) / scale, (r.position.y + noisePosition.y) / scale);
         List <Vector3> p = new List <Vector3>();
         foreach (var v in r.Vertexs)
         {
             //var l = na.NoiseValue((v.x + noisePosition.x) / scale, (v.y + noisePosition.y) / scale);
             p.Add(v);
         }
         if (r.position.z < 0.5f)
         {
             worldMesh.AddPolygon(p.ToArray(), Color.blue);
         }
         else
         {
             worldMesh.AddPolygon(p.ToArray(), Color.green);
         }
     }
 }
コード例 #2
0
        public void Generate(Vector2Int size, float scale, int octave, float persistance, float lacunarity, Vector2 offset)
        {
            rawData = new float[size.y, size.x];
            var halfWidth  = size.x / 2;
            var halfHeight = size.y / 2;
            var noise      = new NoiseAtom();

            noise.Init(octave, persistance, lacunarity, scale, offset);

            for (int raw = 0; raw < size.y; raw++)
            {
                float y = (raw - halfHeight);
                for (int col = 0; col < size.x; col++)
                {
                    float x         = (col - halfWidth);
                    float sampleVal = noise.NoiseValue(x, y);
                    rawData[raw, col] = sampleVal;
                }
            }
        }