TerrainTool
Package: Libraries.Game.Graphics.Worlds · Inherits from: Libraries.Language.Object
TerrainTool names the kinds of change a terrain brush can make. A brush has a tool, which says what it changes, and an operation, which says how: - SCULPT changes the ground's shape. ADD raises it, SUBTRACT lowers it, AVERAGE smooths it, GRADIENT pulls it toward a ramp between two points, and ERODE wears it down with rain, as weather would (it needs a TerrainGenerator, given to the stroke). - HEIGHT with REPLACE flattens the ground toward one height. - TEXTURE changes the splat weights. ADD paints one ground texture, AVERAGE blurs the weights so textures blend more softly, and AUTO paints by a TerrainGenerator's rules: rock on slopes, sand low down, dirt in hollows and grass elsewhere. - REGION adds (ADD) or removes (SUBTRACT) the whole region under the brush's center. This follows Terrain3D's editor, which also pairs a tool with an operation, so "raise" is sculpt and add, and "flatten" is height and replace.
Example Code
use Libraries.Game.Graphics.Worlds.TerrainTool
use Libraries.Game.Graphics.Worlds.TerrainBrush
TerrainTool tools
TerrainBrush brush
brush:SetTool(tools:SCULPT, tools:AVERAGE)
output tools:GetName(brush:GetTool(), brush:GetOperation())
Variables
integer HEIGHTinteger REGIONinteger AVERAGEinteger SCULPTinteger SUBTRACTinteger TEXTUREinteger REPLACEinteger GRADIENTinteger ADDinteger AUTO: This action returns true if a tool and operation make sense together.integer ERODE
Actions
ChangesShape(integer tool)
This action returns true if a tool changes the ground's shape, so the terrain's meshes must be rebuilt after it.
Parameters
toolinteger: The tool.
Returns
boolean: True for SCULPT, HEIGHT and REGION.
ChangesSplat(integer tool)
This action returns true if a tool changes splat weights, so the terrain's splat texture must be rebuilt after it.
Parameters
toolinteger: The tool.
Returns
boolean: True for TEXTURE and REGION.
GetName(integer tool, integer operation)
This action returns a short, plain name for a tool and operation, such as "raise" or "paint", for menus, undo names and speech.
Parameters
toolinteger: The tool.operationinteger: The operation.
Returns
text: The name, or "unknown" if the pair is not valid.
IsValid(integer tool, integer operation)
This action returns true if a tool and operation make sense together.
Parameters
toolinteger: The tool, such as SCULPT.operationinteger: The operation, such as ADD.
Returns
boolean: True if the brush can use this pair.