reckfellENGINE

HeightMapShape3D

A 3D heightmap shape used for physics collision.

On this page
class HeightMapShape3DReckfellSharpInherits Shape3D

A 3D heightmap shape used for physics collision.

A 3D heightmap shape, intended for use in physics to provide a shape for a CollisionShape3D. This type is most commonly used for terrain with vertices placed in a fixed-width grid. The heightmap is represented as a 2D grid of height values, which represent the position of grid points on the Y axis. Grid points are spaced 1 unit apart on the X and Z axes, and the grid is centered on the origin of the CollisionShape3D node. Internally, each grid square is divided into two triangles. Due to the nature of the heightmap, it cannot be used to model overhangs or caves, which would require multiple vertices at the same vertical location. Holes can be punched through the collision by assigning @C#.NAN to the height of the desired vertices. You could then insert meshes with their own separate collision to provide overhangs, caves, and so on. Performance: HeightMapShape3D is faster to check collisions against than ConcavePolygonShape3D, but it is significantly slower than primitive shapes like BoxShape3D. A heightmap collision shape can also be built by using an Image reference:

Note: If you need to use a spacing different than 1 unit, you can adjust the Entity3D.Scale of the shape. However, keep in mind that ReckfellPhysics3D does not support non-uniform scaling: you'll need to scale the Y axis by the same amount as the X and Z axes, which means the values in HeightMapShape3D.MapData will need to be pre-scaled by the inverse of that scale. Also note that ReckfellPhysics3D does not support scaling at all for dynamic bodies (that is, non-frozen RigidBody3D nodes); to use a scaled HeightMapShape3D with those, you will need to use Jolt Physics.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

HeightMapShape3DConstructor
# HeightMapShape3D
C#
public HeightMapShape3D();

Properties3

MapDataProperty
# MapData
C#
public float[] MapData { get; set; }

Heightmap data. The array's size must be equal to HeightMapShape3D.MapWidth multiplied by HeightMapShape3D.MapDepth.

MapDepthProperty
# MapDepth
C#
public int MapDepth { get; set; }

Number of vertices in the depth of the heightmap. Changing this will resize the HeightMapShape3D.MapData.

MapWidthProperty
# MapWidth
C#
public int MapWidth { get; set; }

Number of vertices in the width of the heightmap. Changing this will resize the HeightMapShape3D.MapData.

Methods10

GetMapDatafloat[]
# GetMapData
C#
public float[] GetMapData();
Returns float[]
GetMapDepthint
# GetMapDepth
C#
public int GetMapDepth();
Returns int
GetMapWidthint
# GetMapWidth
C#
public int GetMapWidth();
Returns int
GetMaxHeightfloat
# GetMaxHeight
C#
public float GetMaxHeight();

Returns the largest height value found in HeightMapShape3D.MapData. Recalculates only when HeightMapShape3D.MapData changes.

Returns float
GetMinHeightfloat
# GetMinHeight
C#
public float GetMinHeight();

Returns the smallest height value found in HeightMapShape3D.MapData. Recalculates only when HeightMapShape3D.MapData changes.

Returns float
SetMapData2 overloads
# SetMapData · 1/2
C#
public void SetMapData(ReadOnlySpan<float> data);
Parameters
NameTypeDefault
dataReadOnlySpan<float>—
# SetMapData · 2/2
C#
public void SetMapData(float[] data);
Parameters
NameTypeDefault
datafloat[]—
SetMapDepthvoid
# SetMapDepth
C#
public void SetMapDepth(int height);
Parameters
NameTypeDefault
heightint—
SetMapWidthvoid
# SetMapWidth
C#
public void SetMapWidth(int width);
Parameters
NameTypeDefault
widthint—
UpdateMapDataFromImagevoid
# UpdateMapDataFromImage
C#
public void UpdateMapDataFromImage(Image image, float heightMin, float heightMax);

Updates HeightMapShape3D.MapData with data read from an Image reference. Automatically resizes heightmap HeightMapShape3D.MapWidth and HeightMapShape3D.MapDepth to fit the full image width and height. The image needs to be in either Image.Format.Rf (32 bit), Image.Format.Rh (16 bit), or Image.Format.R8 (8 bit). Each image pixel is read in as a float on the range from 0.0 (black pixel) to 1.0 (white pixel). This range value gets remapped to height_min and height_max to form the final height value. Note: Using a heightmap with 16-bit or 32-bit data, stored in EXR or HDR format is recommended. Using 8-bit height data, or a format like PNG that Reckfell imports as 8-bit, will result in a terraced terrain.

Parameters
NameTypeDefault
imageImage—
heightMinfloat—
heightMaxfloat—
Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.