| VRS - The Virtual Rendering System |
| version 3.3 |
#include <vrs/environment/greenspace.h>

Public Member Functions | |
| GreenSpace (VRS::SO< VRS::Iterator< VRS::SO< VRS::Facet > > > surface, VRS::SO< VRS::Iterator< VRS::SO< VRS::Image > > > textures=NULL, double grassLength=1.0, double grassDensity=1.0, double angle=100.0, unsigned int fans=1, unsigned int lamellas=1, double aspectRatio=1.0, double topPadding=0.0, double alphaTestValue=0.5, double displayDistance=100.0) | |
| 'surface' must not be NULL. | |
| VRS::SO< VRS::Iterator < VRS::SO< VRS::Facet > > > | getSurface () const |
| all 'set'-methods (except the one for the alphaTestValue) will cause a re-creation of the tussock-geometry at the next scenegraph evaluation. | |
| void | setSurface (VRS::SO< VRS::Iterator< VRS::SO< VRS::Facet > > > surface) |
| VRS::SO< VRS::Iterator < VRS::SO< VRS::Image > > > | getTextures () const |
| 'textures' can be null, but the grass will be untextured in that case. | |
| void | setTextures (VRS::SO< VRS::Iterator< VRS::SO< VRS::Image > > > textures) |
| double | getGrassDensity () const |
| 'density' cannot be negative (negative values are clamped to zero). | |
| void | setGrassDensity (double density) |
| double | getGrassLength () const |
| 'length' cannot be negative (negative values are clamped to zero). | |
| void | setGrassLength (double density) |
| double | getAngle () const |
| 'angle' must be in [0, 180] (other values are clamped) | |
| void | setAngle (double angle) |
| void | setFans (unsigned int fans) |
| get/set the number of fans per tussock. | |
| unsigned int | getFans () const |
| void | setLamellas (unsigned int lamellas) |
| get/set the number of lamellas (quads) per tussock-fan (may not be 0) a value of 3 is a good tradeoff between performance and visual quality | |
| unsigned int | getLamellas () const |
| void | setAspectRatio (double aspectRatio) |
| get/set the tussock-quads' aspect ratio. must be greater than 0.0 | |
| double | getAspectRatio () const |
| void | setTopPadding (double aspectRatio) |
| get/set the textures' top padding. values outside [0;1] are clamped | |
| double | getTopPadding () const |
| void | setAlphaTestValue (double alphaTestValue) |
| get/set the alphatest value | |
| double | getAlphaTestValue () const |
| void | setDisplayDistance (double distance) |
| get/set the display distance | |
| double | getDisplayDistance () const |
| virtual VRS::Bounds | boundingBox () const |
| see shape.h | |
| bool | needsUpdate () const |
| void | setBoundingBox (const VRS::Bounds &bounds) |
| VRS_TYPEINFO (GreenSpace, VRS::Shape) | |
| VRS_SERIALIZABLE (GreenSpace) | |
Static Public Member Functions | |
| static VRS::SO< VRS::Image > | getGrassTexture (unsigned int texWidth, unsigned int texHeight, double surfaceWidth, double surfaceLength, VRS::SO< GreenSpace > greenSpace, VRS::SO< VRS::DistantLight > sun=new VRS::DistantLight(VRS::Vector(0.0, 1.0, 0.0), VRS::Color::white, 1.0), VRS::SO< VRS::BackgroundGL > background=new VRS::BackgroundGL()) |
| this method can be used to create a texture-representation of a grass-covered surface. | |
The geometry is specified by a list of Facets. The facets are tesselated and the resulting triangles are treated indepedently for grass-creation. Grass is made of a number of tussocks, each composed of a number of entwined quad-fans. The tussocks are aligned to their respective surface-normal.
| EnvironmentRenderer::GreenSpace::GreenSpace | ( | VRS::SO< VRS::Iterator< VRS::SO< VRS::Facet > > > | surface, | |
| VRS::SO< VRS::Iterator< VRS::SO< VRS::Image > > > | textures = NULL, |
|||
| double | grassLength = 1.0, |
|||
| double | grassDensity = 1.0, |
|||
| double | angle = 100.0, |
|||
| unsigned int | fans = 1, |
|||
| unsigned int | lamellas = 1, |
|||
| double | aspectRatio = 1.0, |
|||
| double | topPadding = 0.0, |
|||
| double | alphaTestValue = 0.5, |
|||
| double | displayDistance = 100.0 | |||
| ) |
'surface' must not be NULL.
'textures' contains grass-images used as textures. All images need to be of equal size. Each tussock is randomly assigned one of the images. To increase the probability for a certain texture, include it multiple times. It will not consume additional texture-memory. in the case 'textures' is NULL, the generated grass is rendered untextured. NULL-pointer entries are ignored. 'density' must be a value greater than or equal to 0.0. the number of tussocks is calculated by 'surfaceArea * density' and rounded to the next integer. 'length' specifies the grass length in world-coordinates. for a grass length of 0.0 only soil is rendered. to simulate natural disorder, length is scaled by a random value in [0.75, 1.25] for each tussock. the grasslength affects the visual density of the grass. long grass will look denser than short grass, even though the number of polygons is not altered. 'fans' each tussock consists of a number of quad-fans, which are regularly entwined around the tussock's position. the number of fans must be at least 1, but it is recommended to use at least 2 fans to ensure a dense view at 360°. 'lamellas' each quad-fan consists of one or more quads, denoted by 'lamellas'. a fan consisting of one lamella will be represented as a single quad, perpendicular to the subjacent ground polygon (the fan will look like this: |) which will 'disappear' when looking at it from above. with more than one lamella, the quads are regularly distributed across the fan (2 lamellas: \/, 3 lamellas: \|/, 4 lamellas: _\/_, 5 lamellas: _\|/_, etc) 'angle' denotes, how strong a quad-fan is opened. values are clamped to [0, 180]. anyway, values should be smaller than 180, as grass-polygons will be coplanar to the ground for that value and greater than 0, as they become coplanar to each other and do not provide a sufficient view, from above (along the tussock's normal, respectively). As 'length', 'angle' is scaled by a random value in [0.75, 1.25]. 'aspectRatio' denotes the width-to-height-ratio of the grass-poylgons. a value of 1.0 produces quadratic polygons. other values will produce polygons with a width of 'aspectRatio' * 'length'. the 'aspectRatio' should be the same as the textures' ratio to avoid warped images 'topPadding' specifying a padding-region will avoid (or reduce) the 'leaking' of texels at a texture's lower edge into the neighbouring texture in the textureatlas. example: if the texture's upper 10% are completely transparent, set 'topPadding' to 0.1 if the padding value is not 0.0, all used textures must contain the padding- region. if they don't, the images' top will be truncated. as values are considered in texture-space, values outside [0;1] are clamped. 'alphaTestValue' this value is needed, as different textures may require different values for the alphatest (capillary grass structure requires smaller values than coarse grass). values are clamped to [0;1]. 'displayDistance' this parameter controls the the max. distance where grass is displayed. to improve rendering performance you can reduce this value.
| VRS::SO< VRS::Iterator< VRS::SO< VRS::Facet > > > EnvironmentRenderer::GreenSpace::getSurface | ( | ) | const [inline] |
all 'set'-methods (except the one for the alphaTestValue) will cause a re-creation of the tussock-geometry at the next scenegraph evaluation.
'surface' can be NULL, however, this will not generate any geometry. empty facets are ignored.
| void EnvironmentRenderer::GreenSpace::setSurface | ( | VRS::SO< VRS::Iterator< VRS::SO< VRS::Facet > > > | surface | ) |
| VRS::SO< VRS::Iterator< VRS::SO< VRS::Image > > > EnvironmentRenderer::GreenSpace::getTextures | ( | ) | const [inline] |
'textures' can be null, but the grass will be untextured in that case.
existing textures are removed. null-pointers will be ignored. setTextures() will create a new textureatlas used by the grass-geometry. it can not be assumed that the previously calculated texture-coordinates are still valid, so we need to re-create the grass-geometry.
| void EnvironmentRenderer::GreenSpace::setTextures | ( | VRS::SO< VRS::Iterator< VRS::SO< VRS::Image > > > | textures | ) |
| double EnvironmentRenderer::GreenSpace::getGrassDensity | ( | ) | const [inline] |
'density' cannot be negative (negative values are clamped to zero).
| void EnvironmentRenderer::GreenSpace::setGrassDensity | ( | double | density | ) |
| double EnvironmentRenderer::GreenSpace::getGrassLength | ( | ) | const [inline] |
'length' cannot be negative (negative values are clamped to zero).
| void EnvironmentRenderer::GreenSpace::setGrassLength | ( | double | density | ) |
| double EnvironmentRenderer::GreenSpace::getAngle | ( | ) | const [inline] |
'angle' must be in [0, 180] (other values are clamped)
| void EnvironmentRenderer::GreenSpace::setAngle | ( | double | angle | ) |
| void EnvironmentRenderer::GreenSpace::setFans | ( | unsigned int | fans | ) |
get/set the number of fans per tussock.
must be 1 at least, but a value greater than 2 is recommended to increase visual quality.
| unsigned int EnvironmentRenderer::GreenSpace::getFans | ( | ) | const [inline] |
| void EnvironmentRenderer::GreenSpace::setLamellas | ( | unsigned int | lamellas | ) |
get/set the number of lamellas (quads) per tussock-fan (may not be 0) a value of 3 is a good tradeoff between performance and visual quality
| unsigned int EnvironmentRenderer::GreenSpace::getLamellas | ( | ) | const [inline] |
| void EnvironmentRenderer::GreenSpace::setAspectRatio | ( | double | aspectRatio | ) |
get/set the tussock-quads' aspect ratio. must be greater than 0.0
| double EnvironmentRenderer::GreenSpace::getAspectRatio | ( | ) | const [inline] |
| void EnvironmentRenderer::GreenSpace::setTopPadding | ( | double | aspectRatio | ) |
get/set the textures' top padding. values outside [0;1] are clamped
| double EnvironmentRenderer::GreenSpace::getTopPadding | ( | ) | const [inline] |
| void EnvironmentRenderer::GreenSpace::setAlphaTestValue | ( | double | alphaTestValue | ) |
get/set the alphatest value
| double EnvironmentRenderer::GreenSpace::getAlphaTestValue | ( | ) | const [inline] |
| void EnvironmentRenderer::GreenSpace::setDisplayDistance | ( | double | distance | ) |
get/set the display distance
| double EnvironmentRenderer::GreenSpace::getDisplayDistance | ( | ) | const [inline] |
| static VRS::SO<VRS::Image> EnvironmentRenderer::GreenSpace::getGrassTexture | ( | unsigned int | texWidth, | |
| unsigned int | texHeight, | |||
| double | surfaceWidth, | |||
| double | surfaceLength, | |||
| VRS::SO< GreenSpace > | greenSpace, | |||
| VRS::SO< VRS::DistantLight > | sun = new VRS::DistantLight(VRS::Vector(0.0, 1.0, 0.0), VRS::Color::white, 1.0), |
|||
| VRS::SO< VRS::BackgroundGL > | background = new VRS::BackgroundGL() | |||
| ) | [static] |
this method can be used to create a texture-representation of a grass-covered surface.
the texture can be used e.g. to replace the grass-geometry of far away GreenSpaces to enhance performance. used as ground-texture below a GreenSpace, it can be used to fill 'holes' and make the grass look denser than it actually is. the texture is created by setting up a rectengular patch filled with tussocks. size of the patch is given by 'surfaceWidth' and 'surfaceLength'. the surface is transformed to fill the viewport and it is rendered, using an orthograpic projection. the tussocks are planted to create a seamlessly tileable image. 'sun' can be used to light the grass properly, 'background' can e.g. specify a soil-texture or a uniformly colored ground. if PBuffers are supported, the returned image has an alpha-channel and hence can be transparent. otherwise the image does not have an alpha-channel.
| VRS::Bounds EnvironmentRenderer::GreenSpace::boundingBox | ( | ) | const [inline, virtual] |
| bool EnvironmentRenderer::GreenSpace::needsUpdate | ( | ) | const |
| void EnvironmentRenderer::GreenSpace::setBoundingBox | ( | const VRS::Bounds & | bounds | ) | [inline] |
| EnvironmentRenderer::GreenSpace::VRS_TYPEINFO | ( | GreenSpace | , | |
| VRS::Shape | ||||
| ) |
| EnvironmentRenderer::GreenSpace::VRS_SERIALIZABLE | ( | GreenSpace | ) |