Table of Contents

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

xCount int

The number of cells along the x axis.

zCount int

The number of cells along the z axis.

cellWidth float

The size of each cell.

amplitude float

The height of the waves.

rowFrequency float

The wave frequency along one axis.

columnFrequency float

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.