This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1
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

Interface for object grass handling. See also the UnigineScript analog.

To use this class, include the UnigineObjectGrass.h file.

Unigine::ObjectGrass Class

Members


static int type ()

ObjectGrass type.

Return value

ObjectGrass type identifier.

static Ptr< ObjectGrass > create (const NodePtr & node)

ObjectGrass constructor.

Arguments

  • const NodePtr & node - Node smart pointer.

static Ptr< ObjectGrass > create (const ObjectPtr & object)

ObjectGrass constructor.

Arguments

  • const ObjectPtr & object - Object smart pointer.

static Ptr< ObjectGrass > create ()

ObjectGrass constructor.

virtual void setFieldMask (int mask) =0

Sets a mask specifying the area of the Field node to be applied to the grass.

Arguments

  • int mask - Integer, each bit of which is a mask.

virtual int getFieldMask () const =0

Returns a mask specifying the area of the Field node to be applied to the grass.

Return value

Integer, each bit of which is a mask.

virtual void setThinning (int thinning) =0

Sets a flag to thin out grass with a distance (random grass polygons are not rendered across the grass Fade distance).

Arguments

  • int thinning - 1 to thin out the grass; 0 to render all grass polygons at the distance.

virtual int getThinning () const =0

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

Return value

1 if the grass is thinned out; 0 if all grass polygons are rendered at the distance.

virtual void setVariation (int variation) =0

Sets the random horizontal flip for grass polygons.

Arguments

  • int variation - Positive number to enable grass flipping, 0 to disable it.

virtual int getVariation () const =0

Returns a value indicating if the random horizontal flip for grass polygons is set.

Return value

Positive number if grass flipping is enabled; otherwise, 0.

virtual void setOrientation (int orientation) =0

Sets a flag to orient grass polygons along the normal of its parent (for example, a terrain).

Arguments

  • int orientation - 1 to orient the grass along the normals of the ground; 0 to render it always pointing upwards.

virtual int getOrientation () const =0

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

Return value

1 if the grass is oriented along the normals of the ground; 0 if it always points upwards.

virtual void setIntersection (int mode) =0

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

Arguments

  • int mode - Positive number to enable intersection; 0 to disable.

virtual int getIntersection () const =0

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

Return value

Positive number if intersection is enabled; otherwise, 0.

virtual void setNumTextures (int num_slots) =0

Sets the number of textures contained in the grass diffuse texture.

Arguments

  • int num_slots - The number of contained textures.

virtual int getNumTextures () const =0

Returns the number of textures contained in the grass diffuse texture.

Return value

The number of contained textures.

virtual void setShadowRadius (float radius) =0

Sets the distance to draw additional grass polygons outside the view frustum. This option allows to eliminate popping of shadows at the edges of the screen when the camera is turning.

Arguments

  • float radius - Distance in units. If a negative value is provided, 0 will be used instead.

virtual float getShadowRadius () const =0

Returns the current distance to draw additional grass polygons outside the view frustum. This option allows to eliminate popping of shadows at the edges of the screen when the camera is turning.

Return value

Distance in units.

virtual int getSpawnCount () const =0

Returns the number of cells to be generated.

Return value

Number of cells to be generated if the scene generation is not completed; otherwise, 0.

virtual void setSeed (int seed) =0

Sets the seed for pseudo-random positioning of grass.

Arguments

  • int seed - Number used to initialize a pseudo-random sequence. If a negative value is provided, 0 will be used instead.

virtual int getSeed () const =0

Returns the seed used for pseudo-random positioning of grass.

Return value

Number used to initialize a pseudo-random sequence.

virtual void setSizeX (float size) =0

Sets the width of the grass object along the X-coordinate.

Arguments

  • float size - X-coordinate width in units. If a negative value is provided, 0 will be used instead.

virtual float getSizeX () const =0

Returns the current width of the grass object along the X-coordinate.

Return value

X-coordinate width in units.

virtual void setSizeY (float size) =0

Sets the length of the grass object along the Y-coordinate.

Arguments

  • float size - Y-coordinate length in units. If a negative value is provided, 0 will be used instead.

virtual float getSizeY () const =0

Returns the current length of the grass object along the Y-coordinate.

Return value

Y-coordinate length in units.

virtual void setStep (float step) =0

Sets the step for cells used to render grass.

Arguments

  • float step - Step for grass cells.

virtual float getStep () const =0

Returns the current step for cells used to render grass.

Return value

Step for grass cells.

virtual void setSubdivision (int subdivision) =0

Subdivide grass rendering cells into smaller sub-cells. It 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.

Arguments

  • int subdivision - Divisor for cells. The value is clamped to a range [1;32].

virtual int getSubdivision () const =0

Returns 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.

Return value

Divisor for cells.

virtual void setDensity (float density) =0

Sets the density factor for the grass per square unit.

Arguments

  • float density - Density factor. If a negative value is provided, 0 will be used instead.

virtual float getDensity () const =0

Returns the current density factor for the grass per square unit.

Return value

Density factor.

virtual void setThreshold (float threshold) =0

Sets the threshold for density, starting from which the grass will be rendered.

Arguments

  • float threshold - Threshold value in range from 0 to 1.

virtual float getThreshold () const =0

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

Return value

Threshold value.

virtual void setAngle (float angle) =0

Sets the angle cosine defining the slope steepness appropriate for grass growing.

Arguments

  • float angle - Slope angle cosine in range from 0 to 1.

virtual float getAngle () const =0

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

Return value

Slope angle cosine.

virtual void setProbability (const vec4 & probability) =0

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

Arguments

  • const vec4 & probability - Per-column probability. Any values can be set, since they are normalized.

virtual vec4 getProbability () const =0

Returns 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.

Return value

Per-column probability.

virtual void setMinHeight (const vec4 & mean, const vec4 & spread) =0

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

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

virtual vec4 getMinHeightMean () const =0

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.

virtual vec4 getMinHeightSpread () const =0

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.

virtual void setMaxHeight (const vec4 & mean, const vec4 & spread) =0

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

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

virtual vec4 getMaxHeightMean () const =0

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.

virtual vec4 getMaxHeightSpread () const =0

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.

virtual void setAspect (const vec4 & mean, const vec4 & spread) =0

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

Arguments

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

virtual vec4 getAspectMean () const =0

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.

virtual vec4 getAspectSpread () const =0

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.

virtual void setOffset (const vec4 & mean, const vec4 & spread) =0

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

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

virtual vec4 getOffsetMean () const =0

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.

virtual vec4 getOffsetSpread () const =0

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.

virtual int setMaskImage (const ImagePtr & image) =0

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

Arguments

  • const ImagePtr & image - Pointer to the image.

Return value

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

virtual int getMaskImage (ImagePtr & image) const =0

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

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

Return value

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

virtual void setMaskImageName (const char * name) =0

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

Arguments

  • const char * name - Name (path) of the mask texture.

virtual const char * getMaskImageName () const =0

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

Return value

Name (path) of the mask texture.

virtual void setMaskFlipX (int flip) =0

Flip the mask by X axis.

Arguments

  • int flip - Positive value to flip the mask; otherwise, 0.

virtual int getMaskFlipX () const =0

Returns a flag indicating if a mask is flipped by X axis.

Return value

Positive value if the mask is flipped; otherwise, 0.

virtual void setMaskFlipY (int flip) =0

Flip the mask by Y axis.

Arguments

  • int flip - Positive value to flip the mask; otherwise, 0.

virtual int getMaskFlipY () const =0

Returns a flag indicating if a mask is flipped by Y axis.

Return value

Positive value if the mask is flipped; otherwise, 0.

virtual void setMaskMinValue (int value) =0

Sets the minimum value of the mask application range.

Arguments

  • int value - Minimum mask value, [0;255].

virtual int getMaskMinValue () const =0

Returns the minimum value of the mask application range.

Return value

Minimum mask value.

virtual void setMaskMaxValue (int value) =0

Sets the maximum value of the mask application range.

Arguments

  • int value - Maximum mask value, [0;255].

virtual int getMaskMaxValue () const =0

Returns the maximum value of the mask application range.

Return value

Maximum mask value.

virtual void setMaskMeshName (const char * name) =0

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

Arguments

  • const char * name - Path to the *.mesh file.

virtual const char * getMaskMeshName () const =0

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

Return value

Path to the *.mesh file.

virtual void setMaskInverse (int inverse) =0

Specifies if the grass should be rendered inside or outside the mask mesh contour.

Arguments

  • int inverse - 0 to render the grass inside the mesh contour; 1 to render it outside.

virtual int getMaskInverse () const =0

Returns a flag indicating if the grass is rendered inside or outside the mask mesh contour.

Return value

0 if the grass is rendered inside the mesh contour; 1 if outside.
Last update: 2017-07-03
Build: ()