public override bool Calculate() { if (!allInputsReady()) { return(false); } IModule3D value = Inputs[0].GetValue <IModule3D>(); if (value == null) { return(false); } IModule3D value2 = Inputs[1].GetValue <IModule3D>(); if (value2 == null) { return(false); } IModule3D value3 = Inputs[2].GetValue <IModule3D>(); if (value3 == null) { return(false); } IModule3D module3D = target.CreateModule(value, value3, value2); if (module3D == null) { return(false); } Outputs[0].SetValue(module3D); return(true); }
public IModule3D CreateModule(IModule3D sourceModule) { switch (modifyType) { case ModifyType.Abs: return(new Abs(sourceModule)); case ModifyType.Clamp: return(new Clamp(sourceModule, lower, upper)); case ModifyType.Exponent: return(new Exponent(sourceModule, exponent)); case ModifyType.Invert: return(new Invert(sourceModule)); case ModifyType.Curve: return(new Curve(sourceModule)); case ModifyType.Terrace: return(new Terrace(sourceModule)); case ModifyType.ScaleBias: return(new ScaleBias(sourceModule, scale, bias)); case ModifyType.Scale2d: return(new Scale2d(sourceModule, scale2d)); default: return(null); } }
public float getValue(Vector3 cubeWorldPosition) { this.frequency = 0.5f; this.lacunarity = 2; this.offset = 1; this.gain = 2; this.exponent = 1f; this.octaveCount = 4f; this.gradient = GradientColors.Grayscale; this.quality = PrimitiveModule.DefaultQuality; this.primitive = NoisePrimitive.ImprovedPerlin; this.filter = NoiseFilter.MultiFractal; this.pModule = new ImprovedPerlin(); this.pModule.Quality = quality; this.pModule.Seed = seed; this.fModule = new MultiFractal(); this.scale = new ScaleBias(fModule, 1f, -0.8f); this.fModule.Frequency = frequency; this.fModule.Lacunarity = lacunarity; this.fModule.OctaveCount = octaveCount; this.fModule.Offset = offset; this.fModule.Gain = gain; this.fModule.Primitive3D = (IModule3D)pModule; this.finalModule = scale; return(this.finalModule.GetValue(cubeWorldPosition.X, cubeWorldPosition.Y, cubeWorldPosition.Z)); }
private void SetUpRidgedMultiFractal3DModule() { // make a 3d ridged multifractal module PrimitiveModule pModule = null; pModule = new SimplexPerlin(); primitiveModule = pModule; pModule.Seed = 123; ScaleBias scale = null; filterModule = new Billow(); // new RidgedMultiFractal(); //new Pipe(); // filterModule.Primitive3D = (IModule3D)pModule; // Used to show the difference with our gradient color (-1 + 1) scale = new ScaleBias(filterModule, 1f, 0f); // 0.9f, -1.25f); float rmfScale = .75f; ScalePoint scalePoint = new ScalePoint(filterModule, rmfScale, rmfScale * 1f, rmfScale); noiseModule = scalePoint; // scale; }
/// <inheritdoc /> public override Vector3 GetOffset(IModule3D noise, BlockCoordinates position) { var noise1 = noise.GetValue(position.X, position.Y, position.Z); var noise2 = MathF.Abs(noise.GetValue(-position.X, -position.Y, position.Z)); var noise3 = noise.GetValue(-position.X, -position.Y, -position.Z); return(new Vector3(noise1 * 0.25f, -(noise2) * 0.25f, noise3 * 0.25f)); }
public IModule3D CreateModule(IModule3D selectModule, IModule3D leftModule, IModule3D rightModule) { if (selectType == SelectType.Blend) { return(new Blend(selectModule, rightModule, leftModule)); } return(new Select(selectModule, rightModule, leftModule, lower, upper, edge)); }
protected override void InitSeed(int seed) { _simplex = new SumFractal() { Primitive3D = new SimplexPerlin(seed + 666), Frequency = 1f, OctaveCount = 2, Lacunarity = 0.65f }; _random = new Random(); }
public override bool Calculate() { IModule3D value = Inputs[0].GetValue <IModule3D>(); if (value == null) { return(false); } ControlPointList value2 = Inputs[1].GetValue <ControlPointList>(); if (target.modifyType == ProcGen.Noise.Modifier.ModifyType.Curve && (value2 == null || value2.points.Count == 0)) { return(false); } FloatList value3 = Inputs[2].GetValue <FloatList>(); if (target.modifyType == ProcGen.Noise.Modifier.ModifyType.Terrace && (value3 == null || value3.points.Count == 0)) { return(false); } IModule3D module3D = target.CreateModule(value); if (module3D == null) { return(false); } if (target.modifyType == ProcGen.Noise.Modifier.ModifyType.Curve) { Curve curve = module3D as Curve; curve.ClearControlPoints(); List <ControlPoint> controls = value2.GetControls(); foreach (ControlPoint item in controls) { curve.AddControlPoint(item); } } else if (target.modifyType == ProcGen.Noise.Modifier.ModifyType.Terrace) { Terrace terrace = module3D as Terrace; terrace.ClearControlPoints(); foreach (float point in value3.points) { float input = point; terrace.AddControlPoint(input); } } Outputs[0].SetValue(module3D); return(true); }
public void SetSouces(IModule3D target, IModule3D controlModule, IModule3D rightModule, IModule3D leftModule) { if (selectType == SelectType.Blend) { Blend blend = target as Blend; blend.ControlModule = controlModule; blend.RightModule = rightModule; blend.LeftModule = leftModule; } Select select = target as Select; select.ControlModule = controlModule; select.RightModule = rightModule; select.LeftModule = leftModule; }
public IModule3D CreateModule(IModule3D sourceModule, IModule3D xModule, IModule3D yModule, IModule3D zModule) { if (transformerType == TransformerType.Turbulence) { return(new Turbulence(sourceModule, xModule, yModule, zModule, power)); } if (transformerType == TransformerType.RotatePoint) { Vector2f rotation = this.rotation; float x = rotation.x; Vector2f rotation2 = this.rotation; return(new RotatePoint(sourceModule, x, rotation2.y, 0f)); } return(new Displace(sourceModule, xModule, yModule, zModule)); }
private void SetUpAltNoise2D() { PrimitiveModule pModule2D = new SimplexPerlin(); pModule2D.Seed = primitiveModule.Seed + 6789; altFilterModule = new Pipe(); // RidgedMultiFractal(); altFilterModule.Primitive3D = (IModule3D)pModule2D; float alt_module_scale = 2.4f; ScalePoint scalePoint_alt = new ScalePoint(altFilterModule, alt_module_scale, alt_module_scale, alt_module_scale); altNoise2DModule = (IModule3D)scalePoint_alt; }
/// <summary> /// Generates an cube of values within a specified range based on the coordinates of the specified start values. /// <para>Caution: the <see cref="OutOfMemoryException"/> arrives quickly</para> /// </summary> /// <param name="module"><see cref="IModule3D"/> represent a noise generator.</param> /// <param name="width">The width of the cube (x-axis).</param> /// <param name="height">The height of the cube (y-axis).</param> /// <param name="depth">The depth" of the cube (z-axis).</param> /// <param name="scaleFactor">The scale factor of the cube.</param> /// <param name="range">Target range to convert the cube.</param> /// <param name="start_x">The start coordinate on the x-axis.</param> /// <param name="start_y">The start coordinate on the y-axis.</param> /// <param name="start_z">The start coordinate on the z-axis.</param> /// <returns>The resulting cube in target range.</returns> static public float[,,] GetCube(this IModule3D module, int width, int height, int depth, float scaleFactor, NoiseRange range, int start_x, int start_y, int start_z) { float[,,] rslt = new float[width, height, depth]; for (int w = 0; w < width; w++) { for (int h = 0; h < height; h++) { for (int d = 0; d < depth; d++) { rslt[w, h, d] = module.GetValue((start_x + w) * scaleFactor, (start_y + h) * scaleFactor, (start_z + d) * scaleFactor, range); } } } return(rslt); }
private void SetUpNoise2D() { //noise character should vary PrimitiveModule pModule2D = new SimplexPerlin(); // new ImprovedPerlin(); // pModule2D.Seed = primitiveModule.Seed + 1234; // noise2DModule = (IModule3D) pModule2D; FilterModule fModule = new SumFractal(); // new Billow(); // fModule.Primitive3D = (IModule3D)pModule2D; float rmfScale = .2f; ScalePoint scalePoint = new ScalePoint(fModule, rmfScale, rmfScale, rmfScale); noise2DModule = (IModule3D)scalePoint; }
public override bool Calculate() { if (!allInputsReady()) { return(false); } IModule3D value = Inputs[0].GetValue <IModule3D>(); if (value == null) { return(false); } IModule3D module3D = target.CreateModule(); if (module3D == null) { return(false); } ((FilterModule)module3D).Primitive3D = value; Outputs[0].SetValue(module3D); return(true); }
public IModule3D CreateModule(IModule3D leftModule, IModule3D rightModule) { switch (combineType) { case CombinerType.Add: return(new Add(leftModule, rightModule)); case CombinerType.Max: return(new Max(leftModule, rightModule)); case CombinerType.Min: return(new Min(leftModule, rightModule)); case CombinerType.Multiply: return(new Multiply(leftModule, rightModule)); case CombinerType.Power: return(new Power(leftModule, rightModule)); default: return(null); } }
public void SetSouces(IModule3D target, IModule3D sourceModule, IModule3D xModule, IModule3D yModule, IModule3D zModule) { if (transformerType == TransformerType.Turbulence) { Turbulence turbulence = target as Turbulence; turbulence.SourceModule = sourceModule; turbulence.XDistortModule = xModule; turbulence.YDistortModule = yModule; turbulence.ZDistortModule = zModule; } else if (transformerType == TransformerType.RotatePoint) { RotatePoint rotatePoint = target as RotatePoint; rotatePoint.SourceModule = sourceModule; } else { Displace displace = target as Displace; displace.SourceModule = sourceModule; displace.XDisplaceModule = xModule; displace.YDisplaceModule = yModule; displace.ZDisplaceModule = zModule; } }
public void SetSouces(IModule3D target, IModule3D sourceModule, FloatList controlFloats, ControlPointList controlPoints) { (target as ModifierModule).SourceModule = sourceModule; if (modifyType == ModifyType.Curve) { Curve curve = target as Curve; curve.ClearControlPoints(); List <ControlPoint> controls = controlPoints.GetControls(); foreach (ControlPoint item in controls) { curve.AddControlPoint(item); } } else if (modifyType == ModifyType.Terrace) { Terrace terrace = target as Terrace; terrace.ClearControlPoints(); foreach (float point in controlFloats.points) { float input = point; terrace.AddControlPoint(input); } } }
public OverworldGenerator() { int seed = Config.GetProperty("seed", "YoHoMotherducker!").GetHashCode(); Seed = seed; BiomeModifierX = new SimplexPerlin(seed + 3700); BiomeModifierZ = new SimplexPerlin(seed + 5000); var rainSimplex = new SimplexPerlin(seed); var rainNoise = new Voronoi(); rainNoise.Primitive3D = rainSimplex; rainNoise.Primitive2D = rainSimplex; rainNoise.Distance = false; rainNoise.Frequency = RainFallFrequency; rainNoise.OctaveCount = 2; RainNoise = rainNoise; var tempSimplex = new SimplexPerlin(seed + 100); var tempNoise = new Voronoi(); tempNoise.Primitive3D = tempSimplex; tempNoise.Primitive2D = tempSimplex; tempNoise.Distance = false; tempNoise.Frequency = TemperatureFrequency; tempNoise.OctaveCount = 2; // tempNoise.Gain = 2.5f; TempNoise = tempNoise; var mainLimitNoise = new SimplexPerlin(seed + 200); var mainLimitFractal = new SumFractal() { Primitive3D = mainLimitNoise, Primitive2D = mainLimitNoise, Frequency = MainNoiseFrequency, OctaveCount = 2, Lacunarity = MainNoiseLacunarity, Gain = MainNoiseGain, SpectralExponent = MainNoiseSpectralExponent, Offset = MainNoiseOffset, }; var mainScaler = new ScaleableNoise() { XScale = 1f / MainNoiseScaleX, YScale = 1f / MainNoiseScaleY, ZScale = 1f / MainNoiseScaleZ, Primitive3D = mainLimitFractal, Primitive2D = mainLimitFractal }; //ModTurbulence turbulence = new ModTurbulence(mainLimitFractal, new ImprovedPerlin(seed - 350, NoiseQuality.Fast), new ImprovedPerlin(seed + 350, NoiseQuality.Fast), null, 0.0125F); _mainNoise = mainScaler; //turbulence; var mountainNoise = new SimplexPerlin(seed + 300); var mountainTerrain = new HybridMultiFractal() { Primitive3D = mountainNoise, Primitive2D = mountainNoise, Frequency = DepthFrequency, OctaveCount = 4, Lacunarity = DepthLacunarity, SpectralExponent = DepthNoiseScaleExponent, //Offset = 0.7f, Gain = DepthNoiseGain }; ScaleableNoise scaling = new ScaleableNoise(); scaling.Primitive2D = mountainTerrain; scaling.Primitive3D = mountainTerrain; scaling.YScale = 1f / HeightScale; scaling.XScale = 1f / DepthNoiseScaleX; scaling.ZScale = 1f / DepthNoiseScaleZ; _depthNoise = scaling; BiomeUtils.FixMinMaxHeight(); }
public Clamp(IModule3D source, float lower, float upper) { Source = source; LowerBound = lower; UpperBound = upper; }
/// <summary> /// Generates an cube of values within a specified coordinates of the specified start values. /// <para>Caution: the <see cref="OutOfMemoryException"/> arrives quickly</para> /// </summary> /// <param name="module"><see cref="IModule3D"/> represent a noise generator.</param> /// <param name="width">The width of the cube (x-axis).</param> /// <param name="height">The height of the cube (y-axis).</param> /// <param name="depth">The depth" of the cube (z-axis).</param> /// <param name="scaleFactor">The scale factor of the cube.</param> /// <param name="start_x">The start coordinate on the x-axis.</param> /// <param name="start_y">The start coordinate on the y-axis.</param> /// <param name="start_z">The start coordinate on the z-axis.</param> /// <returns>The resulting cube.</returns> static public float[,,] GetCube(this IModule3D module, int width, int height, int depth, float scaleFactor, int start_x, int start_y, int start_z) { return(module.GetCube(width, height, depth, scaleFactor, _default, start_x, start_y, start_z)); }
/// <summary> /// Generates an cube of values within a specified range based on the coordinates of the specified start values. /// <para>Caution: the <see cref="OutOfMemoryException"/> arrives quickly</para> /// </summary> /// <param name="module"><see cref="IModule3D"/> represent a noise generator.</param> /// <param name="width">The width of the cube (x-axis).</param> /// <param name="height">The height of the cube (y-axis).</param> /// <param name="depth">The depth" of the cube (z-axis).</param> /// <param name="range">Target range to convert the cube.</param> /// <param name="start_x">The start coordinate on the x-axis.</param> /// <param name="start_y">The start coordinate on the y-axis.</param> /// <param name="start_z">The start coordinate on the z-axis.</param> /// <returns>The resulting cube in target range.</returns> static public float[,,] GetCube(this IModule3D module, int width, int height, int depth, NoiseRange range, int start_x, int start_y, int start_z) { return(module.GetCube(width, height, depth, 1, range, start_x, start_y, start_z)); }
/// <summary> /// Generates an cube of values. /// <para>Caution: the <see cref="OutOfMemoryException"/> arrives quickly</para> /// </summary> /// <param name="module"><see cref="IModule3D"/> represent a noise generator.</param> /// <param name="width">The width of the cube (x-axis).</param> /// <param name="height">The height of the cube (y-axis).</param> /// <param name="depth">The depth" of the cube (z-axis).</param> /// <returns>The resulting cube.</returns> static public float[,,] GetCube(this IModule3D module, int width, int height, int depth) { return(module.GetCube(width, height, depth, 1, _default)); }
/// <summary> /// Generates an cube of values within a specified range. /// <para>Caution: the <see cref="OutOfMemoryException"/> arrives quickly</para> /// </summary> /// <param name="module"><see cref="IModule3D"/> represent a noise generator.</param> /// <param name="width">The width of the cube (x-axis).</param> /// <param name="height">The height of the cube (y-axis).</param> /// <param name="depth">The depth" of the cube (z-axis).</param> /// <param name="scaleFactor">The scale factor of the cube.</param> /// <param name="range">Target range to convert the cube.</param> /// <returns>The resulting cube in target range.</returns> static public float[,,] GetCube(this IModule3D module, int width, int height, int depth, float scaleFactor, NoiseRange range) { return(module.GetCube(width, height, depth, scaleFactor, range, 0, 0, 0)); }
public Curve(IModule3D source) { Source = source; }
/// <summary> /// Generates an output value within a specified range based on the coordinates of the specified inputs values. /// </summary> /// <param name="module"><see cref="IModule3D"/> represent the noise generator.</param> /// <param name="x">The input coordinate on the x-axis.</param> /// <param name="y">The input coordinate on the y-axis.</param> /// <param name="z">The input coordinate on the z-axis.</param> /// <param name="range">Target range to convert the output value.</param> /// <returns>The resulting output value in target range.</returns> static public float GetValue(this IModule3D module, float x, float y, float z, NoiseRange range) { return(ToRange(module.GetValue(x, y, z), range)); }
public void SetSouces(IModule3D target, IModule3D leftModule, IModule3D rightModule) { (target as CombinerModule).LeftModule = leftModule; (target as CombinerModule).RightModule = rightModule; }
/// <summary> /// Constructor /// </summary> /// <param name="module">The noise module that is used to generate the output values</param> public Cylinder(IModule3D module) : base(module) { }
/// <summary> /// Constructor /// </summary> /// <param name="module">The noise module that is used to generate the output values</param> public Sphere(IModule3D module) : base(module) { }
public Abs(IModule3D source) { Source = source; }
public virtual Vector3 GetOffset(IModule3D noise, BlockCoordinates position) { return(Vector3.Zero); }
/// <summary> /// Constructor. /// </summary> /// <param name="module">The noise module that is used to generate the output values.</param> public Cylinder(IModule3D module) : base(module) { }
public void SetSouces(IModule3D target, IModule3D sourceModule) { (target as FilterModule).Primitive3D = sourceModule; }