A constructor defined in BBMOD_Terrain.gml

Extends BBMOD_Class

new BBMOD_Terrain([_heightmap[, _subimage]])


A heightmap based terrain with five material layers controlled through a splatmap.


Name Type Description
_heightmap Asset.GMSprite The heightmap to make the terrain from. If undefined, then you will need to build the terrain mesh yourself later using the terrain's methods.
_subimage Real The sprite subimage to use for the heightmap. Defaults to 0.


Name Description
Layer Array of five material layers. Use undefined instead of a material to disable certain layer.
Position The position of the terrain in the world.
RenderQueue Render queue for terrain layers.
Scale The scale of the terrain.
Size The width and height of the terrain in world units.
Splatmap A texture that controls visibility of individual layers. The first layer is always visible (if the material is not undefined), the red channel of the splatmap controls visibility of the second layer, the green channel controls the third layer etc.
TextureRepeat Controls material texture repeat over the terrain mesh.
VertexBuffer The vertex buffer or undefined if the terrain was not built yet.
VertexFormat The vertex format used by the terrain mesh.


Name Description
build_layer_index Builds an index of layers using the current splatmap.
build_mesh Rebuilds the terrain's mesh.
build_normals Rebuilds normal vectors.
build_smooth_normals Rebuilds smooth normals.
from_heightmap Initializes terrain height from a sprite.
get_height Retrieves terrain's height at given coordinate.
get_height_index Retrieves terrain's height at given index.
get_layer Retrieves the topmost splatmap layer at given coordinate.
get_normal Retrieves terrain's normal at given coordinate.
get_random_position Retrieves a random position on the terrain.
in_bounds Checks whether the coordinate is within the terrain's bounds.
render Enqueues the terrain mesh for rendering.
smooth_height Smoothens out the terrain's height.
submit Immediately submits the terrain mesh for rendering.

Inherited methods

Name Description
destroy Frees resources used by the struct from memory.
implement Implements an interface into the struct.
implements Checks whether the struct implements an interface.
is_instance Checks if the struct inherits from given class.
Do you find this page helpful?

Copyright © 2023, BlueBurn. Built on May 02, 2023 using GMDoc.