Class TerrainTools
Terrain* tools for editor. Allows to create and modify terrain.
Inheritance
Namespace: FlaxEditor
Assembly: FlaxEngine.CSharp.dll
Syntax
[Unmanaged]
public static class TerrainTools : Object
Methods
DeserializePatch(Terrain, ref Int2, String)
Deserializes the terrain chunk data from the JSON string.
Declaration
[Unmanaged]
public static void DeserializePatch(Terrain terrain, ref Int2 patchCoord, string value)
Parameters
Terrain
terrain
The terrain. |
Int2
patchCoord
The patch coordinates (x and z). |
System.String
value
The JSON string with serialized patch data. |
ExportTerrain(Terrain, String)
Export terrain's heightmap as a texture.
Declaration
[Unmanaged]
public static bool ExportTerrain(Terrain terrain, string outputFolder)
Parameters
Terrain
terrain
The terrain. |
System.String
outputFolder
The output folder path |
Returns
System.Boolean
True if failed, otherwise false. |
GenerateTerrain(Terrain, ref Int2, Texture, Single, Texture, Texture)
Generates the terrain from the input heightmap and splat maps.
Declaration
[Unmanaged]
public static bool GenerateTerrain(Terrain terrain, ref Int2 numberOfPatches, Texture heightmap, float heightmapScale, Texture splatmap1, Texture splatmap2)
Parameters
Terrain
terrain
The terrain. |
Int2
numberOfPatches
The number of patches (X and Z axis). |
Texture
heightmap
The heightmap texture. |
System.Single
heightmapScale
The heightmap scale. Applied to adjust the normalized heightmap values into the world units. |
Texture
splatmap1
The custom terrain splat map used as a source of the terrain layers weights. Each channel from RGBA is used as an independent layer weight for terrain layers composting. It's optional. |
Texture
splatmap2
The custom terrain splat map used as a source of the terrain layers weights. Each channel from RGBA is used as an independent layer weight for terrain layers composting. It's optional. |
Returns
System.Boolean
True if failed, otherwise false. |
GetHeightmapData(Terrain, ref Int2)
Gets the raw pointer to the heightmap data (cached internally by the c++ core in editor).
Declaration
[Unmanaged]
public static float *GetHeightmapData(Terrain terrain, ref Int2 patchCoord)
Parameters
Terrain
terrain
The terrain. |
Int2
patchCoord
The patch coordinates (x and z) to gather it. |
Returns
System.Single*
The pointer to the array of floats with terrain patch heights data. Null if failed to gather the data. |
GetHolesMaskData(Terrain, ref Int2)
Gets the raw pointer to the holes mask data (cached internally by the c++ core in editor).
Declaration
[Unmanaged]
public static byte *GetHolesMaskData(Terrain terrain, ref Int2 patchCoord)
Parameters
Terrain
terrain
The terrain. |
Int2
patchCoord
The patch coordinates (x and z) to gather it. |
Returns
System.Byte*
The pointer to the array of bytes with terrain patch holes mask data. Null if failed to gather the data. |
GetSplatMapData(Terrain, ref Int2, Int32)
Gets the raw pointer to the splatmap data (cached internally by the c++ core in editor).
Declaration
[Unmanaged]
public static Color32*GetSplatMapData(Terrain terrain, ref Int2 patchCoord, int index)
Parameters
Terrain
terrain
The terrain. |
Int2
patchCoord
The patch coordinates (x and z) to gather it. |
System.Int32
index
The zero-based splatmap texture index. |
Returns
Color32*
The pointer to the array of Color32 with terrain patch packed splatmap data. Null if failed to gather the data. |
InitializePatch(Terrain, ref Int2)
Initializes the patch heightmap and collision to the default flat level.
Declaration
[Unmanaged]
public static bool InitializePatch(Terrain terrain, ref Int2 patchCoord)
Parameters
Terrain
terrain
The terrain. |
Int2
patchCoord
The patch coordinates (x and z) to initialize it. |
Returns
System.Boolean
True if failed, otherwise false. |
ModifyHeightMap(Terrain, ref Int2, Single*, ref Int2, ref Int2)
Modifies the terrain patch heightmap with the given samples.
Declaration
[Unmanaged]
public static bool ModifyHeightMap(Terrain terrain, ref Int2 patchCoord, float *samples, ref Int2 offset, ref Int2 size)
Parameters
Terrain
terrain
The terrain. |
Int2
patchCoord
The patch coordinates (x and z) to modify it. |
System.Single*
samples
The samples. The array length is size.X*size.Y. It has to be type of float. |
Int2
offset
The offset from the first row and column of the heightmap data (offset destination x and z start position). |
Int2
size
The size of the heightmap to modify (x and z). Amount of samples in each direction. |
Returns
System.Boolean
True if failed, otherwise false. |
ModifyHolesMask(Terrain, ref Int2, Byte*, ref Int2, ref Int2)
Modifies the terrain patch holes mask with the given samples.
Declaration
[Unmanaged]
public static bool ModifyHolesMask(Terrain terrain, ref Int2 patchCoord, byte *samples, ref Int2 offset, ref Int2 size)
Parameters
Terrain
terrain
The terrain. |
Int2
patchCoord
The patch coordinates (x and z) to modify it. |
System.Byte*
samples
The samples. The array length is size.X*size.Y. It has to be type of byte. |
Int2
offset
The offset from the first row and column of the mask data (offset destination x and z start position). |
Int2
size
The size of the mask to modify (x and z). Amount of samples in each direction. |
Returns
System.Boolean
True if failed, otherwise false. |
ModifySplatMap(Terrain, ref Int2, Int32, Color32*, ref Int2, ref Int2)
Modifies the terrain patch splat map (layers mask) with the given samples.
Declaration
[Unmanaged]
public static bool ModifySplatMap(Terrain terrain, ref Int2 patchCoord, int index, Color32*samples, ref Int2 offset, ref Int2 size)
Parameters
Terrain
terrain
The terrain. |
Int2
patchCoord
The patch coordinates (x and z) to modify it. |
System.Int32
index
The zero-based splatmap texture index. |
Color32*
samples
The samples. The array length is size.X*size.Y. It has to be type of Color32. |
Int2
offset
The offset from the first row and column of the splatmap data (offset destination x and z start position). |
Int2
size
The size of the splatmap to modify (x and z). Amount of samples in each direction. |
Returns
System.Boolean
True if failed, otherwise false. |
SerializePatch(Terrain, ref Int2)
Serializes the terrain chunk data to JSON string.
Declaration
[Unmanaged]
public static string SerializePatch(Terrain terrain, ref Int2 patchCoord)
Parameters
Terrain
terrain
The terrain. |
Int2
patchCoord
The patch coordinates (x and z). |
Returns
System.String
The serialized chunk data. |
TryGetPatchCoordToAdd(Terrain, Ray, out Int2)
Checks if a given ray hits any of the terrain patches sides to add a new patch there.
Declaration
[Unmanaged]
public static bool TryGetPatchCoordToAdd(Terrain terrain, Ray ray, out Int2 result)
Parameters
Terrain
terrain
The terrain. |
Ray
ray
The ray to use for tracing (eg. mouse ray in world space). |
Int2
result
The result patch coordinates (x and z). Valid only when method returns true. |
Returns
System.Boolean
True if result is valid, otherwise nothing to add there. |