A constructor defined in BBMOD_Terrain.gml

Implements BBMOD_IDestructible

new BBMOD_Terrain([_heightmap[, _subimage[, _chunkSize]]])


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.
_chunkSize Real The width and height of a single terrain chunk. Defaults to 128.


Name Description
ChunkRadius The radius (in chunk size) within which terrain chunks are visible around the camera. Zero means only the chunk that the camera is on is visible. Use infinity to make all chunks visible. Default value is infinity.
ChunkSize The width and height of a single terrain chunk.
Chunks Grid of vertex buffers, each representing an individual terrain chunk.
Colormap A texture to multiply the terrain colors with.
Layer Array of five terrain layers. Use undefined to disable certain layer.
Material The material used when rendering the terrain. Default is BBMOD_MATERIAL_TERRAIN.
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 OBSOLETE The vertex buffer or undefined if the terrain was not built yet.
VertexFormat The vertex format used by the terrain mesh.


Name Description
build_chunk Force-rebuilds a chunk mesh even if it's not dirty and clears its dirty state.
build_layer_index Builds an index of layers using the current splatmap.
build_mesh Rebuilds all dirty chunks of the terrain mesh.
build_normals Rebuilds normal vectors.
build_smooth_normals Rebuilds smooth normals.
destroy Frees memory used by the struct.
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.
Do you find this page helpful?

Copyright © 2023, BlueBurn. Built on September 11, 2023 using GMDoc.