GroundCover Class Reference

#include <groundCover.h>

Inheritance diagram for GroundCover:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 GroundCover ()
 DECLARE_CONOBJECT (GroundCover)
bool onAdd ()
 Called when the object is added to the sim.
void onRemove ()
 Called when the object is removed from the sim.
void inspectPostApply ()
 Called after any property of the object is changed in the world editor.
U32 packUpdate (NetConnection *, U32 mask, BitStream *stream)
 Instructs this object to pack its state for transfer over the network.
void unpackUpdate (NetConnection *, BitStream *stream)
 Instructs this object to read state data previously packed with packUpdate.
bool prepRenderImage (SceneState *state, const U32 stateKey, const U32 startZone, const bool modifyBaseState)
 Called when the SceneGraph is ready for the registration of RenderImages.
void onTerrainUpdated (U32 flags, TerrainBlock *tblock, const Point2I &min, const Point2I &max)

Static Public Member Functions

static void consoleInit ()
 Register global constant variables and do other one-time initialization tasks in a subclass of ConsoleObject.
static void initPersistFields ()
 Register dynamic fields in a subclass of ConsoleObject.
static F32 setQualityScale (F32 scale)
 Sets the global ground cover LOD scalar which controls the percentage of the maximum designed cover to put down.
static F32 getQualityScale ()
 Returns the current quality scale... see above.

Public Attributes

ObjectRenderInst::RenderDelegate mRenderDelegate

Protected Types

typedef SceneObject Parent
typedef Vector< GroundCoverCell * > CellVector
 InitialUpdateMask = Parent::NextFreeMask
 TerrainBlockMask = InitialUpdateMask << 1
 NextFreeMask = TerrainBlockMask << 1
enum  MaskBits {
  InitialUpdateMask = Parent::NextFreeMask,
  TerrainBlockMask = InitialUpdateMask << 1,
  NextFreeMask = TerrainBlockMask << 1
}

Protected Member Functions

void _initShader ()
void _initShapes ()
void _deleteShapes ()
void _initialize (U32 cellCount, U32 cellPlacementCount)
 Called when GroundCover parameters are changed and things need to be reinitialized to continue.
void _updateCoverGrid (const FrustrumCuller &culler)
 Updates the cover grid by removing cells that have fallen outside of mRadius and adding new ones that have come into view.
void _freeCells ()
 Clears the cell grid, moves all the allocated cells to the free list, and deletes excess free cells.
void _deleteCells ()
 Clears the cell grid and deletes all the free cells.
void _recycleCell (GroundCoverCell *cell)
 Returns a cell to the free list.
GroundCoverCell * _generateCell (const Point2I &index, const Box3F &bounds, U32 placementCount, S32 randSeed)
 Generates a new cell using the recycle list when possible.
void _renderBillboards (ObjectRenderInst *ri, BaseMatInstance *overrideMat)

Static Protected Member Functions

static void _findTerrainCallback (SceneObject *obj, void *param)
 Used to gather a list of TerrainBlocks from findObjects.

Protected Attributes

S32 mRandomSeed
 This RNG seed is saved and sent to clients for generating the same cover.
F32 mRadius
 This is the outer generation radius from the current camera position.
F32 mZOffset
F32 mFadeRadius
 This is less than or equal to mRadius and defines when fading of cover elements begins.
F32 mShapeCullRadius
 This is the distance at which DTS elements are completely culled out.
F32 mReflectRadiusScale
 This is used to scale the various culling radii when rendering a reflection.
U32 mGridSize
 This is the number of cells per axis in the grid.
CellVector mAllocCellList
 This is the allocator for GridCell chunks.
CellVector mFreeCellList
CellVector mCellGrid
 This is the grid of active cells.
CellVector mScratchGrid
 This is a scratch grid used while updating the cell grid.
Point2I mGridIndex
 This is the index to the first grid cell.
S32 mMaxPlacement
 The maximum amount of cover elements to include in the grid at any one time.
S32 mLastPlacementCount
 Used to detect changes in cell placement count from the global quality scale so we can regen the cells.
FrustrumCuller mCuller
 Used for culling cells to update and render.
ShaderDatamBBShader
 The shader used to render the ground cover billboards.
GFXStateBlockRef mStateBlock
GFXShaderConstBufferRef mConstBuffer
GFXShaderConstHandlemModelViewProjectConst
GFXShaderConstHandlemCamRightConst
GFXShaderConstHandlemCamUpConst
GFXShaderConstHandlemCamPosConst
GFXShaderConstHandlemFadeParamConst
GFXShaderConstHandlemWindDirConst
GFXShaderConstHandlemGustInfoConst
GFXShaderConstHandlemTurbInfoConst
GFXShaderConstHandlemTypeRectsConst
bool mDebugRenderCells
 Debug parameter for displaying the grid cells.
bool mDebugNoBillboards
 Debug parameter for turning off billboard rendering.
bool mDebugNoShapes
 Debug parameter for turning off shape rendering.
bool mDebugLockFrustum
 Debug parameter for locking the culling frustum which will freeze the cover generation.
StringTableEntry mTextureName
 The name of the texture atlas of the cover billboards.
GFXTexHandle mTexture
 The texture atlas of the cover billboards.
F32 mMaxBillboardTiltAngle
 This is the maximum amout of degrees the billboard will tilt down to match the camera.
F32 mProbability [MAX_COVERTYPES]
 The probability of one cover type verses another.
F32 mSizeMin [MAX_COVERTYPES]
 The minimum random size for each cover type.
F32 mSizeMax [MAX_COVERTYPES]
 The maximum random size of this cover type.
F32 mSizeExponent [MAX_COVERTYPES]
 An exponent used to bias between the minimum and maximum random sizes.
F32 mWindScale [MAX_COVERTYPES]
 The wind effect scale.
F32 mMaxSlope [MAX_COVERTYPES]
 The maximum slope angle in degrees for placement.
F32 mMinElevation [MAX_COVERTYPES]
 The minimum world space elevation for placement.
F32 mMaxElevation [MAX_COVERTYPES]
 The maximum world space elevation for placement.
S32 mLayer [MAX_COVERTYPES]
 The integer terrain data layer or -1 to not test placement against one.
bool mInvertLayer [MAX_COVERTYPES]
 Inverts the data layer test making the layer an exclusion mask.
S32 mMinClumpCount [MAX_COVERTYPES]
 The minimum amount of elements in a clump.
S32 mMaxClumpCount [MAX_COVERTYPES]
 The maximum amount of elements in a clump.
F32 mClumpCountExponent [MAX_COVERTYPES]
 An exponent used to bias between the minimum and maximum clump counts for a particular clump.
F32 mClumpRadius [MAX_COVERTYPES]
 The maximum clump radius.
RectF mBillboardRects [MAX_COVERTYPES]
 The billboard atlas texture uvs.
F32 mBillboardAspectScales [MAX_COVERTYPES]
 This is a cached array of billboard aspect scales used to avoid some calculations when generating cells.
StringTableEntry mShapeFilenames [MAX_COVERTYPES]
 The cover shape filenames.
TSShapeInstancemShapeInstances [MAX_COVERTYPES]
 The cover shape instances.
F32 mNormalizedProbability [MAX_COVERTYPES]
 This is the same as mProbability, but normalized for use during the cover placement process.
GFXPrimitiveBufferHandle mPrimBuffer
 A shared primitive buffer setup for drawing the maximum amount of billboards you could possibly have in a single cell.
F32 mWindGustLength
 The length in meters between peaks in the wind gust.
F32 mWindGustFrequency
 Controls how often the wind gust peaks per second.
F32 mWindGustStrength
 The maximum distance in meters that the peak wind gust will displace an element.
Point2F mWindDirection
 The direction of the wind.
F32 mWindTurbulenceFrequency
 Controls the overall rapidity of the wind turbulence.
F32 mWindTurbulenceStrength
 The maximum distance in meters that the turbulence can displace a ground cover element.

Static Protected Attributes

static U32 smStatRenderedCells
 Stat for number of rendered cells.
static U32 smStatRenderedBillboards
 Stat for number of rendered billboards.
static U32 smStatRenderedBatches
 Stat for number of rendered billboard batches.
static U32 smStatRenderedShapes
 Stat for number of rendered shapes.
static U32 smLastState
 Used to detect when to reset the stats.
static F32 smQualityScale
 The global ground cover LOD scalar which controls the percentage of the maximum amount of cover to put down.

Friends

class GroundCoverCell

Member Typedef Documentation

typedef SceneObject GroundCover::Parent [protected]

Reimplemented from SceneObject.

typedef Vector<GroundCoverCell*> GroundCover::CellVector [protected]


Member Enumeration Documentation

enum GroundCover::MaskBits [protected]

Enumerator:
InitialUpdateMask 
TerrainBlockMask 
NextFreeMask 


Constructor & Destructor Documentation

GroundCover::GroundCover (  ) 


Member Function Documentation

GroundCover::DECLARE_CONOBJECT ( GroundCover   ) 

static void GroundCover::consoleInit (  )  [static]

Register global constant variables and do other one-time initialization tasks in a subclass of ConsoleObject.

See also:
console

Reimplemented from ConsoleObject.

static void GroundCover::initPersistFields (  )  [static]

Register dynamic fields in a subclass of ConsoleObject.

See also:
addField(), addFieldV(), addDeprecatedField(), addGroup(), endGroup()

Reimplemented from SceneObject.

bool GroundCover::onAdd (  )  [virtual]

Called when the object is added to the sim.

Reimplemented from SceneObject.

void GroundCover::onRemove (  )  [virtual]

Called when the object is removed from the sim.

Reimplemented from SceneObject.

void GroundCover::inspectPostApply (  )  [virtual]

Called after any property of the object is changed in the world editor.

See also:
inspectPreApply

Reimplemented from SceneObject.

U32 GroundCover::packUpdate ( NetConnection ,
U32  mask,
BitStream stream 
) [virtual]

Instructs this object to pack its state for transfer over the network.

Parameters:
conn Net connection being used
mask Mask indicating fields to transmit.
stream Bitstream to pack data to
Returns:
Any bits which were not dealt with. The value is stored by the networking system. Don't set bits you weren't passed.

Reimplemented from NetObject.

void GroundCover::unpackUpdate ( NetConnection ,
BitStream stream 
) [virtual]

Instructs this object to read state data previously packed with packUpdate.

Parameters:
conn Net connection being used
stream stream to read from

Reimplemented from NetObject.

bool GroundCover::prepRenderImage ( SceneState state,
const U32  stateKey,
const U32  startZone,
const bool  modifyBaseState 
) [virtual]

Called when the SceneGraph is ready for the registration of RenderImages.

See also:
SceneState
Parameters:
state SceneState
stateKey State key of the current SceneState
startZone Base zone index
modifyBaseZoneState If true, the object needs to modify the zone state.

Reimplemented from SceneObject.

void GroundCover::onTerrainUpdated ( U32  flags,
TerrainBlock tblock,
const Point2I min,
const Point2I max 
)

static F32 GroundCover::setQualityScale ( F32  scale  )  [inline, static]

Sets the global ground cover LOD scalar which controls the percentage of the maximum designed cover to put down.

It scales both rendering cost and placement CPU performance. Returns the actual value set.

static F32 GroundCover::getQualityScale (  )  [inline, static]

Returns the current quality scale... see above.

void GroundCover::_initShader (  )  [protected]

void GroundCover::_initShapes (  )  [protected]

void GroundCover::_deleteShapes (  )  [protected]

void GroundCover::_initialize ( U32  cellCount,
U32  cellPlacementCount 
) [protected]

Called when GroundCover parameters are changed and things need to be reinitialized to continue.

void GroundCover::_updateCoverGrid ( const FrustrumCuller culler  )  [protected]

Updates the cover grid by removing cells that have fallen outside of mRadius and adding new ones that have come into view.

void GroundCover::_freeCells (  )  [protected]

Clears the cell grid, moves all the allocated cells to the free list, and deletes excess free cells.

void GroundCover::_deleteCells (  )  [protected]

Clears the cell grid and deletes all the free cells.

void GroundCover::_recycleCell ( GroundCoverCell *  cell  )  [protected]

Returns a cell to the free list.

GroundCoverCell* GroundCover::_generateCell ( const Point2I index,
const Box3F bounds,
U32  placementCount,
S32  randSeed 
) [protected]

Generates a new cell using the recycle list when possible.

void GroundCover::_renderBillboards ( ObjectRenderInst ri,
BaseMatInstance overrideMat 
) [protected]

static void GroundCover::_findTerrainCallback ( SceneObject obj,
void param 
) [static, protected]

Used to gather a list of TerrainBlocks from findObjects.


Friends And Related Function Documentation

friend class GroundCoverCell [friend]


Member Data Documentation

This RNG seed is saved and sent to clients for generating the same cover.

This is the outer generation radius from the current camera position.

This is less than or equal to mRadius and defines when fading of cover elements begins.

This is the distance at which DTS elements are completely culled out.

This is used to scale the various culling radii when rendering a reflection.

.. typically for water.

This is the number of cells per axis in the grid.

This is the allocator for GridCell chunks.

This is the grid of active cells.

This is a scratch grid used while updating the cell grid.

This is the index to the first grid cell.

The maximum amount of cover elements to include in the grid at any one time.

The actual amount may be less than this based on randomization.

Used to detect changes in cell placement count from the global quality scale so we can regen the cells.

Used for culling cells to update and render.

The shader used to render the ground cover billboards.

Debug parameter for displaying the grid cells.

Debug parameter for turning off billboard rendering.

Debug parameter for turning off shape rendering.

Debug parameter for locking the culling frustum which will freeze the cover generation.

Stat for number of rendered cells.

Stat for number of rendered billboards.

Stat for number of rendered billboard batches.

Stat for number of rendered shapes.

U32 GroundCover::smLastState [static, protected]

Used to detect when to reset the stats.

F32 GroundCover::smQualityScale [static, protected]

The global ground cover LOD scalar which controls the percentage of the maximum amount of cover to put down.

It scales both rendering cost and placement CPU performance.

The name of the texture atlas of the cover billboards.

The texture atlas of the cover billboards.

This is the maximum amout of degrees the billboard will tilt down to match the camera.

F32 GroundCover::mProbability[MAX_COVERTYPES] [protected]

The probability of one cover type verses another.

F32 GroundCover::mSizeMin[MAX_COVERTYPES] [protected]

The minimum random size for each cover type.

F32 GroundCover::mSizeMax[MAX_COVERTYPES] [protected]

The maximum random size of this cover type.

F32 GroundCover::mSizeExponent[MAX_COVERTYPES] [protected]

An exponent used to bias between the minimum and maximum random sizes.

F32 GroundCover::mWindScale[MAX_COVERTYPES] [protected]

The wind effect scale.

F32 GroundCover::mMaxSlope[MAX_COVERTYPES] [protected]

The maximum slope angle in degrees for placement.

F32 GroundCover::mMinElevation[MAX_COVERTYPES] [protected]

The minimum world space elevation for placement.

F32 GroundCover::mMaxElevation[MAX_COVERTYPES] [protected]

The maximum world space elevation for placement.

S32 GroundCover::mLayer[MAX_COVERTYPES] [protected]

The integer terrain data layer or -1 to not test placement against one.

bool GroundCover::mInvertLayer[MAX_COVERTYPES] [protected]

Inverts the data layer test making the layer an exclusion mask.

S32 GroundCover::mMinClumpCount[MAX_COVERTYPES] [protected]

The minimum amount of elements in a clump.

S32 GroundCover::mMaxClumpCount[MAX_COVERTYPES] [protected]

The maximum amount of elements in a clump.

F32 GroundCover::mClumpCountExponent[MAX_COVERTYPES] [protected]

An exponent used to bias between the minimum and maximum clump counts for a particular clump.

F32 GroundCover::mClumpRadius[MAX_COVERTYPES] [protected]

The maximum clump radius.

RectF GroundCover::mBillboardRects[MAX_COVERTYPES] [protected]

The billboard atlas texture uvs.

F32 GroundCover::mBillboardAspectScales[MAX_COVERTYPES] [protected]

This is a cached array of billboard aspect scales used to avoid some calculations when generating cells.

StringTableEntry GroundCover::mShapeFilenames[MAX_COVERTYPES] [protected]

The cover shape filenames.

TSShapeInstance* GroundCover::mShapeInstances[MAX_COVERTYPES] [protected]

The cover shape instances.

F32 GroundCover::mNormalizedProbability[MAX_COVERTYPES] [protected]

This is the same as mProbability, but normalized for use during the cover placement process.

A shared primitive buffer setup for drawing the maximum amount of billboards you could possibly have in a single cell.

The length in meters between peaks in the wind gust.

Controls how often the wind gust peaks per second.

The maximum distance in meters that the peak wind gust will displace an element.

The direction of the wind.

Controls the overall rapidity of the wind turbulence.

The maximum distance in meters that the turbulence can displace a ground cover element.