FTerrainIO
- Module
- Game
- Header
#include "Terrain/TerrainIO.h"- Namespace
Mowo
Public functions
| Returns | Name | Description |
|---|---|---|
bool | ImportHeights | |
bool | ImportHeightsFromMemory | |
bool | ImportHeightTile | Cuts tile (tileX, tileZ) out of an already-decoded source. |
FTerrainTileLayout | SuggestTileLayout | Largest square tiling of sourceSamples whose tiles stay at or under maxTileSamples and still line up on the one-texel overlap. |
void | SolveTileChunks | Chunk grid for one tile: the coarsest split whose chunk resolution stays inside the component's 4-128 range and still divides the tile's span exactly. |
void | TileCenter | Terrain-local centre of tile (tileX, tileZ) for a grid laid out around the origin. |
bool | ExportHeightsRaw16 | Headerless little-endian 16-bit — the .r16 World Machine, Gaea and UE landscape all speak. |
bool | ExportHeightsPng16 | |
bool | EncodeHeightsPng16 | 16-bit grayscale PNG bytes. |
bool | EncodeGrayPng8 | |
bool | ExportWeightmapLayerPng | One layer of a 4- or 8-layer weightmap as 8-bit grayscale (mapB null selects the 4-layer form) — UE5's per-layer weightmap export shape. |
bool | ImportWeightmapLayer | Reads a grayscale image into one layer channel and rescales the other channels to fill what is left, so the texel still sums to 255. |
bool | WriteFile |
Function details
ImportHeights
static bool ImportHeights(const std::string& path, float heightScale, FEditableHeightfield& out)ImportHeightsFromMemory
static bool ImportHeightsFromMemory(const void* data, size_t size, bool raw16, float heightScale, FEditableHeightfield& out)ImportHeightTile
static bool ImportHeightTile(const FDecodedHeightfield& source, const FTerrainTileLayout& layout, uint32_t tileX, uint32_t tileZ, float heightScale, FEditableHeightfield& out)Cuts tile (tileX, tileZ) out of an already-decoded source. Returns false when the tile falls outside the layout or the source is too small.
SuggestTileLayout
static FTerrainTileLayout SuggestTileLayout(uint32_t sourceSamples, uint32_t maxTileSamples)Largest square tiling of sourceSamples whose tiles stay at or under maxTileSamples and still line up on the one-texel overlap.
SolveTileChunks
static void SolveTileChunks(uint32_t tileSamples, int32_t& outChunksPerSide, int32_t& outChunkResolution)Chunk grid for one tile: the coarsest split whose chunk resolution stays inside the component's 4-128 range and still divides the tile's span exactly. An inexact split leaves the last chunk row short, which shows up as a crack along every tile's far edge.
TileCenter
static void TileCenter(const FTerrainTileLayout& layout, uint32_t tileX, uint32_t tileZ, float tileWorldSize, float& outX, float& outZ)Terrain-local centre of tile (tileX, tileZ) for a grid laid out around the origin. Tiles share an edge texel, so their centres sit exactly tileWorldSize apart — anything else double-counts the overlap and leaves a seam the stitcher cannot close.
ExportHeightsRaw16
static bool ExportHeightsRaw16(const FEditableHeightfield& field, const std::string& absPath, float heightScale)Headerless little-endian 16-bit — the .r16 World Machine, Gaea and UE landscape all speak. Square-only, like the decoder that reads it back.
ExportHeightsPng16
static bool ExportHeightsPng16(const FEditableHeightfield& field, const std::string& absPath, float heightScale)EncodeHeightsPng16
static bool EncodeHeightsPng16(const FEditableHeightfield& field, float heightScale, std::vector<uint8_t>& out)16-bit grayscale PNG bytes. The deflate stream uses stored blocks: the engine links no zlib, and an export that any tool can open matters more than the file being small.
EncodeGrayPng8
static bool EncodeGrayPng8(const uint8_t* gray, uint32_t width, uint32_t height, std::vector<uint8_t>& out)ExportWeightmapLayerPng
static bool ExportWeightmapLayerPng(const uint8_t* mapA, const uint8_t* mapB, uint32_t width, uint32_t height, int32_t layer, const std::string& absPath)One layer of a 4- or 8-layer weightmap as 8-bit grayscale (mapB null selects the 4-layer form) — UE5's per-layer weightmap export shape.
ImportWeightmapLayer
static bool ImportWeightmapLayer(const void* data, size_t size, uint8_t* mapA, uint8_t* mapB, uint32_t width, uint32_t height, int32_t layer)Reads a grayscale image into one layer channel and rescales the other channels to fill what is left, so the texel still sums to 255.
WriteFile
static bool WriteFile(const std::string& absPath, const void* data, size_t size)