blob: a4bc557d7b0225376817d10aac726a3c9bd57446 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
using System;
namespace LibNoise.Generator
{
/// <summary>
/// Provides a noise module that outputs a checkerboard pattern. [GENERATOR]
/// </summary>
public class Checker : ModuleBase
{
#region Constructors
/// <summary>
/// Initializes a new instance of Checker.
/// </summary>
public Checker()
: base(0)
{
}
#endregion
#region ModuleBase Members
/// <summary>
/// Returns the output value for the given input coordinates.
/// </summary>
/// <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>
/// <returns>The resulting output value.</returns>
public override double GetValue(double x, double y, double z)
{
var ix = (int) (Math.Floor(Utils.MakeInt32Range(x)));
var iy = (int) (Math.Floor(Utils.MakeInt32Range(y)));
var iz = (int) (Math.Floor(Utils.MakeInt32Range(z)));
return (ix & 1 ^ iy & 1 ^ iz & 1) != 0 ? -1.0 : 1.0;
}
#endregion
}
}
|