This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Unigine.ObjectGrass Class

Inherits from: Object

This class is used to create grass. The grass object is rendered in grid cells.

You can use a mask to cut out grass in the areas of intersection with other objects and decals (e.g. to remove vegetation under houses or from the surface of roads projected using decals).

ObjectGrass Class

Properties

int CutoutInverse#

The A value indicating if the grass is rendered inside or outside the areas determined by the cutout intersection mask.

int CutoutIntersectionMask#

The current cutout intersection mask. this mask allows you to cut out the grass in the areas of intersection with objects and decals (e.g. can be used to remove grass under houses or from the surface of roads projected using decals). the grass will be cut out by objects and decals that have their intersection mask matching this one (one bit at least).
Notice
To set intersection masks the following methods can be used:

int MaskInverse#

The A flag indicating if the grass is rendered inside or outside the mask mesh contour.

int MaskMaxValue#

The maximum value of the mask application range.

int MaskMinValue#

The minimum value of the mask application range.

int MaskFlipY#

The A flag indicating if a mask is flipped by y axis.

int MaskFlipX#

The A flag indicating if a mask is flipped by x axis.

vec4 Probability#

The current grass rendering probability per column (in the diffuse texture). the higher the value for some column, the more frequently it will be rendered.

float Angle#

The current angle cosine defining the slope steepness appropriate for grass growing.

float Threshold#

The current threshold for density, starting from which the grass is rendered.

float Density#

The current density factor for the grass per square unit.

int Subdivision#

The current divisor used to subdivide grass rendering cells into smaller sub-cells. subdividing is used if a grass node is used as a distant lod for WorldClutter or ObjectMeshClutter with smaller cells. This way, positions of randomly scattered objects will coincide with those of grass-based impostors.

float Step#

The current step for cells used to render grass.

float SizeY#

The current length of the grass object along the y-coordinate.

float SizeX#

The current width of the grass object along the x-coordinate.

int Seed#

The seed used for pseudo-random positioning of grass.

int SpawnCount#

The number of cells to be generated.

int NumTextures#

The number of rows contained in the grass diffuse texture.

int Intersection#

The A value indicating whether grass grow upon the ground: either the terrain or a mesh set as a parent node.

int Orientation#

The A flag indicating if grass polygons are oriented along the normal of its parent (for example, a terrain).

int Variation#

The A value indicating if the random horizontal flip for grass polygons is set.

int Thinning#

The A flag indicating if the grass is thinned out with a distance (random grass polygons are not rendered across the grass fade distance).

int FieldMask#

The A mask specifying the area of the field node to be applied to the grass.

ivec4 TerrainMasks#

The current set of Landscape Terrain masks used for grass placement.

Members


ObjectGrass ( ) #

Constructor. Creates a new grass object.

void SetAspect ( vec4 mean, vec4 spread ) #

Sets the aspect of the grass polygons (width to height ratio).

Arguments

  • vec4 mean - Mean value of grass aspect.
  • vec4 spread - Spread value of grass aspect.

vec4 GetAspectMean ( ) #

Returns the current mean value of the grass aspect (width to height ratio), defined for four diffuse texture columns.

Return value

Mean value of grass aspect.

vec4 GetAspectSpread ( ) #

Returns the current spread value of the grass aspect (width to height ratio), defined for four diffuse texture columns.

Return value

Spread value of grass aspect.

int SetMaskImage ( Image image, int invalidate = 1 ) #

Sets an image that defines the areas of growing grass. Possible mask formats are R8, RG8, RGB8 and RGBA8.

Arguments

  • Image image - Pointer to the image.
  • int invalidate - Invalidate flag. Set 1 to invalidate all grass cells; otherwise, set 0. All invalidated cells will be regenerated.

Return value

1 if the mask image is successfully set; otherwise, 0.

int GetMaskImage ( Image image ) #

Writes the image that is currently used to define the areas of grass growing into the given buffer. Possible mask formats are R8, RG8, RGB8 and RGBA8.

Arguments

  • Image image - Image buffer to store a mask into.

Return value

1 if the mask image is successfully written into the buffer; otherwise, 0.

void SetMaskImageName ( string image_name, int invalidate = 1 ) #

Sets the name of a mask image that defines the areas of growing grass. Possible mask formats are R8, RG8, RGB8 and RGBA8.

Arguments

  • string image_name - Name (path) of the mask image.
  • int invalidate - Invalidate flag. Set 1 to invalidate all grass cells; otherwise, set 0. All invalidated cells will be regenerated.

string GetMaskImageName ( ) #

Returns a name of the current mask image that defines the areas of grass growing. Possible mask formats are R8, RG8, RGB8 and RGBA8.

Return value

Name (path) of the mask image.

int SetMaskMesh ( Mesh mesh, int invalidate = 1 ) #

Sets a mesh to be used as a mask on-the-fly. Limitations:
  • Before the method is called, another mesh must be set via setMaskMeshName() first.
  • If the world is reloaded, the mesh set via setMaskMeshName() will be loaded.
  • If the memory limit is exceeded, the new mesh might be replaced with the mesh set via setMaskMeshName().

Arguments

  • Mesh mesh - Mesh instance.
  • int invalidate - Invalidate flag. Set 1 to invalidate all grass cells; otherwise, set 0. All invalidated cells will be regenerated.

Return value

1 if the mesh is set successfully; otherwise - 0.

int GetMaskMesh ( Mesh mesh ) #

Copies the current mask mesh (if it exists) to the specified target mesh.

Arguments

  • Mesh mesh - Mesh instance to copy the current mask mesh to.

Return value

1 if mesh mask exists; otherwise - 0.

void SetMaskMeshName ( string mesh_name, int invalidate = 1 ) #

Sets a mesh to be used as a mask for the grass. This mesh should be plane.

Arguments

  • string mesh_name - Path to the *.mesh file.
  • int invalidate - Invalidate flag. Set 1 to invalidate all grass cells; otherwise, set 0. All invalidated cells will be regenerated.

string GetMaskMeshName ( ) #

Returns the name (path) of the current mesh used as a mask for the grass. This mesh should be plane.

Return value

Path to the *.mesh file.

void SetMaxBend ( vec4 mean, vec4 spread ) #

Sets the maximum grass bending parameters (rendered in areas with the highest density according to the mask). Bend angles (mean and spread) are defined for four diffuse texture columns. The resulting value is determined as follows: Result = Mean + Random * Spread, where Random is a random value in range from -1 to 1.

Arguments

  • vec4 mean - Vector of mean values of grass bending angles to be set for four diffuse texture columns.
  • vec4 spread - Vector of spread values of grass bending angles to be set for four diffuse texture columns.

vec4 GetMaxBendMean ( ) #

Returns the mean value for the maximum grass bending (rendered in areas with the highest density according to the mask). Bend angles are defined for four diffuse texture columns.

Return value

Vector of mean values of grass bending angles for four diffuse texture columns.

vec4 GetMaxBendSpread ( ) #

Returns the spread value for the maximum grass bending (rendered in areas with the highest density according to the mask). Bend angles are defined for four diffuse texture columns.

Return value

Vector of spread values of grass bending angles for four diffuse texture columns.

void SetMinBend ( vec4 mean, vec4 spread ) #

Sets the minimum grass bending parameters (rendered in areas with the lowest density according to the mask). Bend angles (mean and spread) are defined for four diffuse texture columns. The resulting value is determined as follows: Result = Mean + Random * Spread, where Random is a random value in range from -1 to 1.

Arguments

  • vec4 mean - Vector of mean values of grass bending angles to be set for four diffuse texture columns.
  • vec4 spread - Vector of spread values of grass bending angles to be set for four diffuse texture columns.

vec4 GetMinBendMean ( ) #

Returns the mean value for the minimum grass bending (rendered in areas with the lowest density according to the mask). Bend angles are defined for four diffuse texture columns.

Return value

Vector of mean values of grass bending angles for four diffuse texture columns.

vec4 GetMinBendSpread ( ) #

Returns the spread value for the minimum grass bending (rendered in areas with the lowest density according to the mask). Bend angles are defined for four diffuse texture columns.

Return value

Vector of spread values of grass bending angles for four diffuse texture columns.

void SetMaxHeight ( vec4 mean, vec4 spread ) #

Sets the maximum grass height (rendered in areas with the highest density according to the mask). The height is defined for four diffuse texture columns, as mean and spread values ( Result = Mean + Random * Spread, where Random is a random value in range from -1 to 1).

Arguments

  • vec4 mean - Mean value for the maximum grass height in units. If a negative value is provided, EPSILON will be used instead.
  • vec4 spread - Spread value for the maximum grass height in units.

vec4 GetMaxHeightMean ( ) #

Returns the mean value for the maximum grass height (rendered in areas with the highest density according to the mask). The height is defined for four diffuse texture columns.

Return value

Mean value for the maximum grass height in units.

vec4 GetMaxHeightSpread ( ) #

Returns the spread value for the maximum grass height (rendered in areas with the highest density according to the mask). The height is defined for four diffuse texture columns.

Return value

Spread value for the maximum grass height in units.

void SetMinHeight ( vec4 mean, vec4 spread ) #

Sets the minimum grass height (rendered in areas with the lowest density according to the mask). The height is defined for four diffuse texture columns, as mean and spread values ( Result = Mean + Random * Spread, where Random is a random value in range from -1 to 1).

Arguments

  • vec4 mean - Mean value for the minimum grass height in units. If a negative value is provided, EPSILON will be used instead.
  • vec4 spread - Spread value for the minimum grass height in units.

vec4 GetMinHeightMean ( ) #

Returns the mean value for the minimum grass height (rendered in areas with the lowest density according to the mask). The height is defined for four diffuse texture columns.

Return value

Mean value for the minimum grass height in units.

vec4 GetMinHeightSpread ( ) #

Returns the spread value for the minimum grass height (rendered in areas with the lowest density according to the mask). The height is defined for four diffuse texture columns.

Return value

Spread value for the minimum grass height in units.

void SetOffset ( vec4 mean, vec4 spread ) #

Sets the grass offset from the surface along the surface normal, defined for four diffuse texture columns. If a negative mean value is provided, vec4_eps will be used instead.

Arguments

  • vec4 mean - Mean value of grass polygons offset in units.
  • vec4 spread - Spread value of grass polygons offset in units.

vec4 GetOffsetMean ( ) #

Returns the current mean value of the grass offset from the surface along the surface normal, defined for four diffuse texture columns.

Return value

Mean value of grass polygons offset in units.

vec4 GetOffsetSpread ( ) #

Returns the current spread value for the grass offset from the surface along the surface normal, defined for four diffuse texture columns.

Return value

Spread value for grass polygons offset in units.

void SetRotation ( vec4 mean, vec4 spread ) #

Sets the grass rotation. Rotation is defined for four diffuse texture columns, as mean and spread values ( Result = Mean + Random * Spread, where Random is a random value in range from -1 to 1).

Arguments

  • vec4 mean - Mean value of grass polygons rotation, in degrees.
  • vec4 spread - Spread value of grass polygons rotation, in degrees.

vec4 GetRotationMean ( ) #

Returns the current mean value for the grass rotation, defined for four diffuse texture columns.

Return value

Mean value of grass polygons rotation, in degrees.

vec4 GetRotationSpread ( ) #

Returns the current spread value for the grass rotation, defined for four diffuse texture columns.

Return value

Spread value of grass polygons rotation, in degrees.

static int type ( ) #

Returns the type of the node.

Return value

Object type identifier.

void Invalidate ( ) #

Invalidates all grass cells. All invalidated cells will be regenerated.

void Invalidate ( WorldBoundBox bounds ) #

Invalidates all grass cells within the area specified by the given bounding box. All invalidated cells will be regenerated.

Arguments

  • WorldBoundBox bounds - Bounding box, defining the area, where grass cells will be regenerated.
Last update: 2022-12-14
Build: ()