Пример #1
0
        private void InitModules()
        {
            // init everything here so they don't need to be instantiated later
            VoronoiNoise.Init();
            MaterialController.Init();
            TextureController.Init();
            OptController.Init();
            Seeder.Init(islandDensity);

            method = Constants.NoiseFuncs [(int)noiseType];
        }
Пример #2
0
        public static float genNoise(Vector3 point, noiseFunc method)
        {
            float freq = frequency;
            float sum  = method(point * freq);

            float amplitude = 1f;
            float range     = 1f;

            for (int o = 1; o < octaves; o++)
            {
                freq      *= lacunarity;
                amplitude *= persistence;
                range     += amplitude;
                sum       += method(point * freq) * amplitude;
            }
            return(sum / range);
        }
Пример #3
0
        //==============================================
        // CONSTRUCTOR

        // creates a random island given a few parameters
        public Island(Vector3 init,
                      Vector3 scale,
                      noiseFunc method,
                      TextureTypes t,
                      int density,
                      MeshLib.MaskMethod m = null)
            : base(init, scale, method, t, density)
        {
            // adjust the y coordinate of the island
            this.Loc = new Vector3(Loc.x, -1 * Random.Range(1, islandRange), Loc.z);

            // assign the type of mask
            this.Mask = m != null ? m : MeshLib.Mask.GenRandom();

            if (this.Mask == null)
            {
                Debug.Log("WHAT1");
            }

            _debug("Initialized");

            StartCreateIsland();
        }
Пример #4
0
        //==============================================
        // CONSTRUCTOR

        public GenericTerrain(Vector3 init,
                              Vector3 scale,
                              noiseFunc method,
                              TextureTypes t = TextureTypes.NoTexture,
                              int density    = defDensity)
        {
            this.Method   = method;
            this.Material = MaterialController.GenDefault();

            // set default values
            this.Texture = new TTexture(init, textureResolution, density, t);

            this.Loc   = init;
            this.Scale = new Vector3(
                Mathf.Max(scale.x + GetDimensions(scale.x / sizeFactor), 200),
                Mathf.Max(scale.y + GetDimensions(scale.y / sizeFactor), 200),
                Mathf.Max(scale.z + GetDimensions(scale.z / sizeFactor), 200)
                );

            this.Coloring = randomGradient();

            _debug("Initialized");
        }