BBMOD_Terrain

Extends BBMOD_Class

constructor

new BBMOD_Terrain([_heightmap[, _subimage]])

Description

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

Arguments

Name Type Description
_heightmap Resource.GMSprite/Undefined 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.

Properties

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.

Methods

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.
Do you find this page helpful?

Copyright © 2022, BlueBurn. Built on June 19, 2022 using GMDoc.