コード例 #1
0
ファイル: MoreHeuristics.cs プロジェクト: otaTrunda/PADD
        public static NoiseGenerator createInstance(NoiseGenerationType type, double parameter)
        {
            switch (type)
            {
            case NoiseGenerationType.constantUniform:
                return(new ConstantUniformNoiseGenerator(parameter));

            case NoiseGenerationType.ProportionalUniform:
                return(new ProportionalUniformNoiseGenerator(parameter));

            case NoiseGenerationType.ConstantNormal:
                return(new ConstantNormalNoiseGenerator(parameter));

            case NoiseGenerationType.ProportionalNormal:
                return(new ProportionalNormalNoiseGenerator(parameter));

            default:
                return(null);

                break;
            }
        }
コード例 #2
0
    //Operates in place
    protected void AddPerlinNoise(List <NavigablePoint> points, float octave, float scale, NoiseGenerationType genType = NoiseGenerationType.Smooth, Vector2?seed = null)
    {
        if (seed.HasValue == false)
        {
            seed = new Vector2(Random.Range(-1000f, 1000f), Random.Range(-1000f, 1000f));
        }

        points.ForEach(p =>
        {
            float noise = Mathf.PerlinNoise((p.GridPosition.x * octave) + seed.Value.x, (p.GridPosition.y * octave) + seed.Value.y) * scale;

            if (genType == NoiseGenerationType.Ridged)
            {
                //Sink so midpoint is zero
                noise -= scale / 2;

                noise = -Mathf.Abs(noise);

                noise += scale / 2;
            }

            p.Position = new Vector3()
            {
                x = p.Position.x,
                y = p.Position.y + noise,
                z = p.Position.z
            };
        });
    }
コード例 #3
0
    //Operates in place
    protected void AddPerlinNoise(List <NavigablePoint> points, PerlinNoiseIterationArgs args, NoiseGenerationType genType = NoiseGenerationType.Smooth, Vector2?seed = null)
    {
        float octave = args.startingOctave;
        float res    = args.startingScale;

        for (int i = 0; i < args.iterations; i++)
        {
            AddPerlinNoise(points, octave, res, genType);

            octave *= args.octaveIterationModifier;
            res    *= args.scaleIterationModifier;
        }
    }