Skip to main content

RampBrush

A class in Root.Township, the global namespace.

Editor tool for terrain: strokes a ramp along control points into the terrain heightmap, blending with brush size, softness and opacity. Needs a Terrain on the same object; not used at runtime.

  • Listed in Global namespace: Q to R
  • Inherits or implements MonoBehaviour
  • Attributes ExecuteInEditMode, AddComponentMenu

Constructors​

MemberWhat it is
RampBrush()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

MemberWhat it is
Vector3 backupVectorSpare vector kept by the tool.
Vector3 beginRampStart point of a single ramp.
bool brushOnWhether the brush is on.
float brushOpacityHow strongly the ramp replaces the existing height (0 to 1).
Vector3 brushPositionWhere the brush gizmo is drawn.
float brushSampleDensityHow often the brush is stamped along the path.
float brushSizeBrush width in world units.
float brushSoftnessHow soft the brush edge is.
List<Vector3> controlPointsPoints the ramp path runs through.
Vector3 endRampEnd point of a single ramp.
bool isBrushHiddenEditor flag to hide the brush.
bool multiPointWhether the ramp uses the control point list rather than one start point.
int numSubDivPerSegSubdivisions per path segment.
bool shiftProcessedEditor input flag.
float sizeJitterRandom variation in brush size.
float spacingJitterRandom sideways offset of each stamp, as a fraction of the brush size.
bool turnBrushOnVarWhether the brush gizmo is drawn.
4 private and internal fields
MemberWhat it is
private List<float> _distBetweenPointsLength of each segment between control points, filled by calculateDistBetweenPoints.
private float _totalLengthTotal path length through the control points in world units.
private float _totalLengthPixelsTotal path length in heightmap pixels, used to space brush samples when stroking a path.
private bool VERBOSEPrivate flag that turns on debug logging while painting; off by default.

Methods​

MemberWhat it is
void _StrokePath()Flattens the terrain into a ramp along the control points, blended by the brush settings.
float[] bitmapCordsToTerrain(TerrainData terData, int x, int y)Turns heightmap pixel coordinates into terrain-local x and z.
void OnDrawGizmos()Draws the brush and the ramp's control points and path in the scene view.
void rampBrush()Checks for a terrain and reads its data, but does nothing else in this build.
void StrokePath()Runs _StrokePath.
int[] terrainCordsToBitmap(TerrainData terData, Vector3 v)Turns terrain-local coordinates into heightmap pixel coordinates.
void toggleBrushOn()Flips whether the brush gizmo is drawn.
3 private and internal methods
MemberWhat it is
private void calculateDistBetweenPoints(List<Vector3> cps)Fills _distBetweenPoints and _totalLength from a list of control points.
private void calculateDistBetweenPointsInPixels(List<Vector3> cps, TerrainData terData)Sums the path length in heightmap pixels into _totalLengthPixels.
private Ray parameterizedLine(float t, List<Vector3> cps, StringBuilder sb = null)Returns the point and direction at fraction t along a Catmull-Rom spline through the control points.