Precipitation Class Reference

#include <precipitation.h>

Inheritance diagram for Precipitation:

Inheritance graph
[legend]
List of all members.

Public Types

 DataMask = Parent::NextFreeMask << 0
 PercentageMask = Parent::NextFreeMask << 1
 StormMask = Parent::NextFreeMask << 2
 TransformMask = Parent::NextFreeMask << 3
 TurbulenceMask = Parent::NextFreeMask << 4
 NextFreeMask = Parent::NextFreeMask << 5
enum  {
  DataMask = Parent::NextFreeMask << 0,
  PercentageMask = Parent::NextFreeMask << 1,
  StormMask = Parent::NextFreeMask << 2,
  TransformMask = Parent::NextFreeMask << 3,
  TurbulenceMask = Parent::NextFreeMask << 4,
  NextFreeMask = Parent::NextFreeMask << 5
}

Public Member Functions

 Precipitation ()
 ~Precipitation ()
void inspectPostApply ()
 Called after any property of the object is changed in the world editor.
bool onNewDataBlock (GameBaseData *dptr)
 Called when a new datablock is set.
 DECLARE_CONOBJECT (Precipitation)
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.
void setPercentage (F32 pct)
void modifyStorm (F32 pct, U32 ms)
void setTurbulence (F32 max, F32 speed, U32 ms)
 This is used to smoothly change the turbulence over a desired time period.

Static Public Member Functions

static void initPersistFields ()
 Register dynamic fields in a subclass of ConsoleObject.

Protected Types

typedef GameBase Parent

Protected Member Functions

void processTick (const Move *)
 Processes a move event and updates object state once every 32 milliseconds.
void interpolateTick (F32 delta)
 Interpolates between tick events.
VectorF getWindVelocity ()
void fillDropList ()
 Adds/removes drops from the list to have the right # of drops.
void killDropList ()
 Deletes the entire drop list.
void initRenderObjects ()
 Re-inits the texture coord lookup tables.
void initMaterials ()
 Re-inits the textures and shaders.
void spawnDrop (Raindrop *drop)
 Fills drop info with random velocity, x/y positions, and mass.
void spawnNewDrop (Raindrop *drop)
 Same as spawnDrop except also does z position.
void findDropCutoff (Raindrop *drop, const Box3F &box, const VectorF &windVel)
 Casts a ray to see if/when a drop will collide.
void wrapDrop (Raindrop *drop, const Box3F &box, const U32 currTime, const VectorF &windVel)
 Wraps a drop within the specified box.
void createSplash (Raindrop *drop)
 Adds a drop to the splash list.
void destroySplash (Raindrop *drop)
 Removes a drop from the splash list.
bool onAdd ()
 Called when the object is added to the sim.
void onRemove ()
 Called when the object is removed from the sim.
bool prepRenderImage (SceneState *, const U32, const U32, const bool)
 Called when the SceneGraph is ready for the registration of RenderImages.
void renderObject (ObjectRenderInst *ri, BaseMatInstance *)
void setTransform (const MatrixF &mat)
 Sets the Object -> World transform.

Protected Attributes

PrecipitationDatamDataBlock
RaindropmDropHead
 Drop linked list head.
RaindropmSplashHead
 Splash linked list head.
Point2FmTexCoords
 texture coords for rain texture
Point2FmSplashCoords
 texture coordinates for splash texture
SFXSourcemAmbientSound
 Ambient sound.
ShaderDatamDropShader
 The shader used for raindrops.
GFXTexHandle mDropHandle
 Texture handle for raindrop.
ShaderDatamSplashShader
 The shader used for splashes.
GFXTexHandle mSplashHandle
 Texture handle for splash.
U32 mLastRenderFrame
 Used to skip processTick when we haven't been visible.
U32 mDropHitMask
 Stores the current drop hit mask.
bool mFollowCam
 Does the system follow the camera or stay where it's placed.
F32 mDropSize
 Droplet billboard size.
F32 mSplashSize
 Splash billboard size.
bool mUseTrueBillboards
 True to use true billboards, false for axis-aligned billboards.
S32 mSplashMS
 How long in milliseconds a splash will last.
bool mAnimateSplashes
 Animate the splashes using the frames in the texture.
S32 mDropAnimateMS
 If greater than zero, will animate the drops from the frames in the texture.
S32 mNumDrops
 Number of drops in the scene.
F32 mPercentage
 Server-side set var (NOT exposed to console) which controls how many drops are present [0,1].
F32 mMinSpeed
 Minimum downward speed of drops.
F32 mMaxSpeed
 Maximum downward speed of drops.
F32 mMinMass
 Minimum mass of drops.
F32 mMaxMass
 Maximum mass of drops.
F32 mBoxWidth
 How far away in the x and y directions drops will render.
F32 mBoxHeight
 How high drops will render.
F32 mMaxTurbulence
 Coefficient to sin/cos for adding turbulence.
F32 mTurbulenceSpeed
 How fast the turbulence wraps in a circle.
bool mUseTurbulence
 Whether to use turbulence or not (MAY EFFECT PERFORMANCE).
bool mUseLighting
 This enables shading of the drops and splashes by the sun color.
ColorF mGlowIntensity
 Set it to 0 to disable the glow or use it to control the intensity of each channel.
bool mReflect
 This enables the precipitation to be rendered during reflection passes.
bool mUseWind
 This enables the wind from the sky SceneObject to effect the velocitiy of the drops.
bool mRotateWithCamVel
 Rotate the drops relative to the camera velocity This is useful for "streak" type drops.
bool mDoCollision
 Whether or not to do collision.
bool mDropHitPlayers
 Should drops collide with players.
bool mDropHitVehicles
 Should drops collide with vehicles.
F32 mFadeDistance
 The distance at which fading of the particles begins.
F32 mFadeDistanceEnd
 The distance at which fading of the particles ends.
U32 mMaxVBDrops
 The maximum drops allowed in one render batch.
GFXStateBlockRef mDefaultSB
GFXStateBlockRef mDistantSB
GFXShaderConstBufferRef mDropShaderConsts
GFXShaderConstHandlemDropShaderModelViewSC
GFXShaderConstHandlemDropShaderFadeStartEndSC
GFXShaderConstHandlemDropShaderCameraPosSC
GFXShaderConstHandlemDropShaderAmbientSC
GFXShaderConstBufferRef mSplashShaderConsts
GFXShaderConstHandlemSplashShaderModelViewSC
GFXShaderConstHandlemSplashShaderFadeStartEndSC
GFXShaderConstHandlemSplashShaderCameraPosSC
GFXShaderConstHandlemSplashShaderAmbientSC
struct {
   bool   valid
   U32   startTime
   U32   totalTime
   F32   startPct
   F32   endPct
mStormData
struct {
   bool   valid
   U32   startTime
   U32   totalTime
   F32   startMax
   F32   startSpeed
   F32   endMax
   F32   endSpeed
mTurbulenceData
GFXPrimitiveBufferHandle mRainIB
GFXVertexBufferHandle< GFXVertexPT > mRainVB
ObjectRenderInst::RenderDelegate mRenderDelegate

Member Typedef Documentation

typedef GameBase Precipitation::Parent [protected]

Reimplemented from GameBase.


Member Enumeration Documentation

anonymous enum

Enumerator:
DataMask 
PercentageMask 
StormMask 
TransformMask 
TurbulenceMask 
NextFreeMask 


Constructor & Destructor Documentation

Precipitation::Precipitation (  ) 

Precipitation::~Precipitation (  ) 


Member Function Documentation

void Precipitation::processTick ( const Move  )  [protected, virtual]

Processes a move event and updates object state once every 32 milliseconds.

This takes place both on the client and server, every 32 milliseconds (1 tick).

See also:
ProcessList
Parameters:
move Move event corresponding to this tick, or NULL.

Reimplemented from GameBase.

void Precipitation::interpolateTick ( F32  delta  )  [protected, virtual]

Interpolates between tick events.

This takes place on the CLIENT ONLY.

Parameters:
delta Time since last call to interpolate

Reimplemented from GameBase.

VectorF Precipitation::getWindVelocity (  )  [protected]

void Precipitation::fillDropList (  )  [protected]

Adds/removes drops from the list to have the right # of drops.

void Precipitation::killDropList (  )  [protected]

Deletes the entire drop list.

void Precipitation::initRenderObjects (  )  [protected]

Re-inits the texture coord lookup tables.

void Precipitation::initMaterials (  )  [protected]

Re-inits the textures and shaders.

void Precipitation::spawnDrop ( Raindrop drop  )  [protected]

Fills drop info with random velocity, x/y positions, and mass.

void Precipitation::spawnNewDrop ( Raindrop drop  )  [protected]

Same as spawnDrop except also does z position.

void Precipitation::findDropCutoff ( Raindrop drop,
const Box3F box,
const VectorF windVel 
) [protected]

Casts a ray to see if/when a drop will collide.

void Precipitation::wrapDrop ( Raindrop drop,
const Box3F box,
const U32  currTime,
const VectorF windVel 
) [protected]

Wraps a drop within the specified box.

void Precipitation::createSplash ( Raindrop drop  )  [protected]

Adds a drop to the splash list.

void Precipitation::destroySplash ( Raindrop drop  )  [protected]

Removes a drop from the splash list.

bool Precipitation::onAdd (  )  [protected, virtual]

Called when the object is added to the sim.

Reimplemented from GameBase.

void Precipitation::onRemove (  )  [protected, virtual]

Called when the object is removed from the sim.

Reimplemented from GameBase.

bool Precipitation::prepRenderImage ( SceneState ,
const   U32,
const   U32,
const   bool 
) [protected, 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 Precipitation::renderObject ( ObjectRenderInst ri,
BaseMatInstance  
) [protected]

void Precipitation::setTransform ( const MatrixF mat  )  [protected, virtual]

Sets the Object -> World transform.

Parameters:
mat New transform matrix

Reimplemented from SceneObject.

void Precipitation::inspectPostApply (  )  [virtual]

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

See also:
inspectPreApply

Reimplemented from GameBase.

bool Precipitation::onNewDataBlock ( GameBaseData dptr  )  [virtual]

Called when a new datablock is set.

This allows subclasses to appropriately handle new datablocks.

See also:
setDataBlock()
Parameters:
dptr New datablock

Reimplemented from GameBase.

Precipitation::DECLARE_CONOBJECT ( Precipitation   ) 

static void Precipitation::initPersistFields (  )  [static]

Register dynamic fields in a subclass of ConsoleObject.

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

Reimplemented from GameBase.

U32 Precipitation::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 GameBase.

void Precipitation::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 GameBase.

void Precipitation::setPercentage ( F32  pct  ) 

void Precipitation::modifyStorm ( F32  pct,
U32  ms 
)

void Precipitation::setTurbulence ( F32  max,
F32  speed,
U32  ms 
)

This is used to smoothly change the turbulence over a desired time period.

Setting ms to zero will cause the change to be instantaneous. Setting max zero will disable turbulence.


Member Data Documentation

Reimplemented from GameBase.

Drop linked list head.

Splash linked list head.

texture coords for rain texture

texture coordinates for splash texture

Ambient sound.

The shader used for raindrops.

Texture handle for raindrop.

The shader used for splashes.

Texture handle for splash.

Used to skip processTick when we haven't been visible.

Stores the current drop hit mask.

Does the system follow the camera or stay where it's placed.

Droplet billboard size.

Splash billboard size.

True to use true billboards, false for axis-aligned billboards.

How long in milliseconds a splash will last.

Animate the splashes using the frames in the texture.

If greater than zero, will animate the drops from the frames in the texture.

Number of drops in the scene.

Server-side set var (NOT exposed to console) which controls how many drops are present [0,1].

Minimum downward speed of drops.

Maximum downward speed of drops.

Minimum mass of drops.

Maximum mass of drops.

How far away in the x and y directions drops will render.

How high drops will render.

Coefficient to sin/cos for adding turbulence.

How fast the turbulence wraps in a circle.

Whether to use turbulence or not (MAY EFFECT PERFORMANCE).

This enables shading of the drops and splashes by the sun color.

Set it to 0 to disable the glow or use it to control the intensity of each channel.

This enables the precipitation to be rendered during reflection passes.

This is expensive.

This enables the wind from the sky SceneObject to effect the velocitiy of the drops.

Rotate the drops relative to the camera velocity This is useful for "streak" type drops.

Whether or not to do collision.

Should drops collide with players.

Should drops collide with vehicles.

The distance at which fading of the particles begins.

The distance at which fading of the particles ends.

The maximum drops allowed in one render batch.

struct { ... } Precipitation::mStormData [protected]

struct { ... } Precipitation::mTurbulenceData [protected]