Terrain
Extends: MeshInstance2D
Description
The visual component of the terrain.
Accessed by through the Level instance.
Properties
Level | Level |
Image | splatImage |
Image | splatImage2 |
ImageTexture | splatTexture |
ImageTexture | splatTexture2 |
ShaderMaterial | ShaderMaterial |
Texture[] | textures |
bool | ExpandedSlots |
bool | SmoothBlending |
Shader | normalShader |
Shader | expandedShader |
Shader | smoothShader |
Shader | expandedSmoothShader |
int | width |
int | height |
Methods
Dictionary | Save ( bool copy = false ) |
void | Load ( Dictionary data ) |
void | Resize ( int x, int y, int w, int h ) |
Vector2 | WorldToTexture ( Vector2 position ) |
Vector2 | TextureToWorld ( Vector2 position ) |
Vector2 | SnapWorldToTextureBlob ( Vector2 position ) |
void | UpdateSplat ( ) |
void | Paint ( int terrainID, Image brush, Vector2 offset, Vector2 position, float rate ) |
void | Fill ( int terrainID ) |
void | RestoreSplat ( Image splat ) |
void | RestoreSplat2 ( Image splat, Image splat2 ) |
void | SetTexture ( Texture texture, int index ) |
Texture | GetTexture ( int index ) |
Image | CloneSplatImage ( ) |
Image | CloneSplatImage2 ( ) |
void | ExpandSlots ( bool value ) |
void | SetSmoothBlending ( bool enabled ) |
Property Descriptions
- Level Level:
The Level in which this Terrain resides.
- Image splatImage:
The splat map of the first 4 textures.
- Image splatImage2:
The splat map of the second 4 textures.
- ImageTexture splatTexture:
The texture of the splat map of the first 4 textures.
- ImageTexture splatTexture2:
The texture of the splat map of the second 4 textures.
- ShaderMaterial ShaderMaterial:
The material used to shade the Terrain.
- Texture[] textures:
The textures used by this Terrain. The size of the array is 4 or 8 based on the ExpandedSlots property.
- bool ExpandedSlots:
Gets if the user expanded the terrain slots. Call ExpandSlots() to modify. Do not modify directly.
- bool SmoothBlending:
Gets if the user set the terrain to smooth. Call SetSmoothBlending() to modify. Do not modify directly.
- Shader normalShader:
Gets the default shader of the terrain.
- Shader expandedShader:
Gets the default shader of the terrain with expanded slots.
- Shader smoothShader:
Gets the smooth shader of the terrain.
- Shader expandedSmoothShader:
Gets the smooth shader of the terrain with expanded slots.
- int width:
Gets the width of the terrain map. DO NOT MODIFY.
- int height:
Gets the height of the terrain map. DO NOT MODIFY.
Method Descriptions
- Dictionary Save ( bool copy = false ):
Save the Terrain into the save file format and return it as a Dictionary. The param copy is only used by copy-pasting feature of Dungeondraft.
- void Load ( Dictionary data ):
Load a saved Terrain data. Used by a saved map file to load existing terrain.
- void Resize ( int x, int y, int w, int h ):
Called automatically when the canvas is resized. DO NOT CALL DIRECTLY. FOR REFERENCE ONLY.
- Vector2 WorldToTexture ( Vector2 position ):
Convert a world position to texture space.
- Vector2 TextureToWorld ( Vector2 position ):
Convert a texture position to world space.
- Vector2 SnapWorldToTextureBlob ( Vector2 position ):
Snaps a world position, typically the mouse cursor, to center on a terrain pixel.
- void UpdateSplat ( ):
Send terrain changes from the CPU to the GPU so that it is rendered.
- void Paint ( int terrainID, Image brush, Vector2 offset, Vector2 position, float rate ):
Paints the image called bursh at the texture space position. Calls UpdateSplat() internally.
- void Fill ( int terrainID ):
Fill the terrain with the selected terrain texture. Calls UpdateSplat() internally.
- void RestoreSplat ( Image splat ):
Restore a splat image to the Terrain. Overwrites existing Terrain. Used by undo history.
- void RestoreSplat2 ( Image splat, Image splat2 ):
The expanded slot version of RestoreSplat().
- void SetTexture ( Texture texture, int index ):
Change the texture being used at the index slot.
- Texture GetTexture ( int index ):
Get the texture being used at index slot.
- Image CloneSplatImage ( ):
Copies the current splat image to a new Image.
- Image CloneSplatImage2 ( ):
Copies the second splat image to a new Image. (Used by the terrain texture 5-8).
- void ExpandSlots ( bool value ):
Toggles the Terrain between 4 and 8 slots.
- void SetSmoothBlending ( bool enabled ):
Toggles if the terrain is using texured blending or smooth blending.