Skip to main content

TerrainAccess

A class in Root.Township, the global namespace.

A copied rectangle of a terrain's heightmap and splat (paint) map that can be edited and written back. Made by TerrainInfo for forest generation and cached to disk as an ICacheable.

Constructors​

MemberWhat it is
TerrainAccess(TerrainInfo terrain)Creates a TerrainAccess from terrain, x, y, width, height, isHeight and isSplat.
1 private and internal constructor
MemberWhat it is
internal TerrainAccess(TerrainInfo terrain, int x, int y, int width, int height, bool isHeight, bool isSplat)Creates a TerrainAccess from terrain, x, y, width, height, isHeight and isSplat.

Fields​

1 private and internal field
MemberWhat it is
private static Logger loggerNLog logger for this class.

Properties​

MemberWhat it is
float[,] Heights { get; private set; }The copied heights, indexed [row, column] like Unity's GetHeights.
int HeightsHeight { get; private set; }Number of height rows in the region.
int HeightsWidth { get; private set; }Number of height columns in the region.
Vector3 Offset { get; private set; }World offset of the region's corner.
Vector3 Scale { get; private set; }The terrain's heightmap scale.
SplatData[,] Splat { get; private set; }Splat cells for the region, one per two height samples, or null if not requested.
int SplatHeight { get; private set; }Splat rows in the region.
int SplatWidth { get; private set; }Splat columns in the region.
TerrainInfo Terrain { get; }The terrain this region was taken from.
uint Version { get; }Cache format version (1).
int X { get; private set; }Heightmap X of the region's corner.
int Y { get; private set; }Heightmap Y of the region's corner.

Methods​

MemberWhat it is
void ApplyHeights()Writes Heights back to the terrain at X, Y.
void ApplySplat()Writes Splat back into the terrain's splat texture and applies it.
void ApplyTo(TerrainInfo other)Writes the same heights and splat region onto another terrain.
void FillSplat(SplatData splatData)Sets every splat cell to one value.
float GetAverage(int x, int y)Average of the four heights around a splat cell. The static overload reads a given array instead.
static float GetAverage(int x, int y, float[,] customSource)Average of the four heights around a splat cell. The static overload reads a given array instead.
float GetMaxDifference(int x, int y)Highest minus lowest of the four heights around a splat cell. The static overload reads a given array instead.
static float GetMaxDifference(int x, int y, float[,] customSource)Highest minus lowest of the four heights around a splat cell. The static overload reads a given array instead.
void SampleSplat()Reads the terrain's splat texture into Splat.
1 private and internal method
MemberWhat it is
private Task Alta.Static.ICacheable.SerializeAsync(uint version, Stream stream)Explicit ICacheable implementation: writes or reads the region bounds, heights and splat data to a cache stream.

Used in​

Members of other types that take, return or hold a TerrainAccess: