Method Wave
- Namespace
- Box3D
- Assembly
- Box3D.NET.dll
Wave(int, int, float, float, float, float)
Builds a rolling wave surface, useful for testing uneven ground.
public static CollisionMesh Wave(int xCount, int zCount, float cellWidth, float amplitude, float rowFrequency = 0.25, float columnFrequency = 0.25)Parameters
xCountint-
The number of cells along the x axis.
zCountint-
The number of cells along the z axis.
cellWidthfloat-
The size of each cell.
amplitudefloat-
The height of the waves.
rowFrequencyfloat-
The wave frequency along one axis.
columnFrequencyfloat-
The wave frequency along the other.
Returns
- CollisionMesh
-
The mesh.
Examples
// Sixteen cells of one metre, one wave every four cells.
using var waves = CollisionMesh.Wave(16, 16, cellWidth: 1.0f, amplitude: 2.0f,
rowFrequency: 0.25f, columnFrequency: 0.25f);
Remarks
Watch the frequency against the cell width. The surface is sampled
at sin(2 * pi * frequency * cellWidth * i) for each grid index
i, so whenever frequency * cellWidth lands on a whole
number every sample falls on a zero crossing and the result is perfectly
flat. The default frequency with a cell width of one does exactly that.
Keep frequency * cellWidth well below one — a quarter gives four
cells per wavelength, which is about the coarsest that still looks like a
wave.