//set up probitems static Substance() { List <double> surfIts = new List <double>(); List <double> surfWeights = new List <double>(); foreach (KeyValuePair <Sub, Substance> sub in subs) { if (sub.Value.surfAb > 0) { surfIts.Add((double)sub.Key); surfWeights.Add(sub.Value.surfAb); } } surfProb = new ProbItems(surfIts.ToArray(), surfWeights.ToArray()); }
//TODO: paramatize all other properties /// <summary> /// get a random gradient noise function(perlin, billow, ridged, maybe voronoi later) /// </summary> /// <returns>The gradient noise.</returns> /// <param name="prob">Prob.</param> /// <param name="val">Value.</param> /// <param name="scale">Scale.</param> private static ModuleBase getGradientNoise(ProbItems prob, double val, double scale, System.Random rand) { //FastNoise fn = new FastNoise (Random.Range (0, int.MaxValue)); //fn.Frequency = 1 / scale; //fn.OctaveCount = Random.Range (2, 6); //return fn; switch ((int)prob.getValue(rand.NextDouble())) { case 0: /*return new Perlin(1/scale,//randDoub(.00001, 0.1), * randDoub(1.8, 2.2, rand.NextDouble()), * randDoub(.4, .6, rand.NextDouble()), * rand.Next(2, 6), * rand.Next(int.MinValue, int.MaxValue), * QualityMode.High);*/ return(new FastNoise(rand.Next(0, int.MaxValue)) { Frequency = 1 / scale, Lacunarity = randDoub(1.8, 2.2, rand.NextDouble()), Persistence = randDoub(.4, .6, rand.NextDouble()), OctaveCount = rand.Next(2, 6), }); break; case 1: /*return new Billow(1/scale, * randDoub(1.8, 2.2, rand.NextDouble()), * randDoub(.4, .6, rand.NextDouble()), * rand.Next(2, 6), * rand.Next(int.MinValue, int.MaxValue), * QualityMode.High);*/ return(new FastBillow(rand.Next(0, int.MaxValue)) { Frequency = 1 / scale, Lacunarity = randDoub(1.8, 2.2, rand.NextDouble()), Persistence = randDoub(.4, .6, rand.NextDouble()), OctaveCount = rand.Next(2, 6), }); break; case 2: return(new FastRidgedMultifractal(rand.Next(0, int.MaxValue)) { Frequency = 1 / scale, Lacunarity = randDoub(1.8, 2.2, rand.NextDouble()), //Persistence = randDoub(.4, .6, rand.NextDouble()), OctaveCount = rand.Next(2, 6), }); /*return new RidgedMultifractal(1/scale, * randDoub(1.8, 2.2, rand.NextDouble()), * rand.Next(2, 6), * rand.Next(int.MinValue, int.MaxValue), * QualityMode.High);*/ break; default: return(new Const(0.0)); break; } }