VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends
makVrv::DtWeatherLightning Class Reference

This class simulates and renders a lightning area. The area will randomly create lightning within a specified bounds. A generic mesh is used by a shader to draw lightning bolts. An intensity value can be set to increase or decrease the visibility of the effect.

Inheritance diagram for makVrv::DtWeatherLightning:
Inheritance graph
[legend]

Classes

struct  DrawData
 
struct  LightningBolt
 
struct  LightningFinger
 
struct  MeshGroup
 
struct  SortDistanceComparator
 
struct  SortJobData
 

Public Member Functions

virtual ~DtWeatherLightning ()
 
 DtWeatherLightning ()=delete
 
 DtWeatherLightning (const DtWeatherLightning &other)=delete
 
DtWeatherLightningoperator= (const DtWeatherLightning &other)=delete
 
virtual void init ()
 
virtual void releaseGLObjects (osg::State *state) const
 
virtual void simulationUpdate (float timeStep, double currentTime, DtJobSplitter *jobSplitter)
 
virtual bool cullUpdate (const osg::Vec3d &camPos, const osg::Matrixd &viewMatrixI, const Frustum_64 &frustum, DtJobSplitter *jobSplitter)
 
virtual void draw (DtWeatherLightning::DrawData &drawData)
 
virtual void setBounds (const DtVector &bounds, float cornerRadius)
 
virtual void setTransform (const osg::Vec3d &position, const osg::Matrixd &rotation)
 
virtual void setIntensity (const float intensity)
 
virtual void setBaseColor (const DtVector &color)
 
virtual void runSort (const osg::Vec3 &localCamPos)
 
virtual void setEnabled (bool enabled)
 
virtual bool enabled () const
 
virtual bool culled () const
 
virtual void computeBounds (osg::Vec4 &bounds, osg::Vec3d &position, osg::Matrixd &rotation) const
 
- Public Member Functions inherited from makVrv::DtVirtualBaseClass
 DtVirtualBaseClass ()
 
virtual ~DtVirtualBaseClass ()
 

Public Attributes

friend DtWeatherLightningCreator
 

Protected Member Functions

 DtWeatherLightning (makVrv::DtDe &de)
 
virtual void initBoltMeshGroup (LightningBolt *bolt)
 
virtual void computeBoltAliveTimeRange (float &minTime, float &maxTime) const
 
virtual void createBolt (const osg::Vec3 &start, const osg::Vec3 &end)
 
virtual void createFingerSegments (LightningBolt *bolt, LightningFinger *finger)
 
virtual bool positionInBounds2D (const float x, const float y, const osg::Vec3 &bounds)
 
virtual float computeRandomMinMax (float fMin, float fMax)
 
virtual bool updateRandomSeed (double currentTime)
 
virtual void setRandomSeedSyncTimeInterval (unsigned long intervalInMs)
 
virtual void computeSortDepth (const osg::Vec3 &reference)
 
void fillMeshGroupFlashPoint (LightningBolt *bolt)
 
virtual void fillMeshGroup (LightningBolt *bolt, LightningFinger *finger)
 
virtual bool bindMeshGroupData (MeshGroup *meshGroup, osg::RenderInfo &renderInfo) const
 
virtual bool bindDynamicMeshGroupData (MeshGroup *meshGroup, osg::RenderInfo &renderInfo) const
 
virtual bool bindVaoToMeshGroup (GLuint vao, MeshGroup *meshGroup, osg::RenderInfo &renderInfo) const
 
const osg::Vec3 crossProduct (const osg::Vec3 &v0, const osg::Vec3 &v1) const
 

Static Protected Member Functions

static void theSortJob (void *data)
 

Protected Attributes

DtDemyDe
 
bool myEnabled
 
bool myCulled
 
osg::Vec3d myPosition
 
osg::Matrixd myRotation
 
float myBoundsX
 
float myBoundsY
 
float myBoundsZ
 
float myBoundsCornerRadius
 
float myBoltWidth
 
float myIntensity
 
osg::Vec3 myBaseColor
 
std::vector< LightningBolt * > myMutableLightningBoltsPool
 
std::vector< LightningBolt * > myMutableLightningBoltsActive
 
SortJobData mySortJobData
 
DtJobSplitterJob mySortJob
 
DtRandomNumberGenerator myRandomNumberGen
 
unsigned int myRandomSeed
 
unsigned long mySeedSyncInterval
 
unsigned long myNextSyncTime
 
float myStrikeTimeMin
 
float myStrikeTimeMax
 
float myStrikeTimer
 
DtLightmyLight
 

Friends

class DtWeatherLightningFactory
 
struct SortDistanceComparator
 

Constructor & Destructor Documentation

virtual makVrv::DtWeatherLightning::~DtWeatherLightning ( )
virtual

DTOR.

makVrv::DtWeatherLightning::DtWeatherLightning ( )
delete

Default Constructor not implemented.

makVrv::DtWeatherLightning::DtWeatherLightning ( const DtWeatherLightning other)
delete

Copy Constructor not implemented - Copy not allowed.

makVrv::DtWeatherLightning::DtWeatherLightning ( makVrv::DtDe de)
protected

CTOR.

Member Function Documentation

DtWeatherLightning& makVrv::DtWeatherLightning::operator= ( const DtWeatherLightning other)
delete

Assignment Operator not implemented - Assignment not allowed.

virtual void makVrv::DtWeatherLightning::init ( )
virtual

Called after creation to initialize effects.

virtual void makVrv::DtWeatherLightning::releaseGLObjects ( osg::State *  state) const
virtual

Release all gl objects used by items in this layer.

virtual void makVrv::DtWeatherLightning::simulationUpdate ( float  timeStep,
double  currentTime,
DtJobSplitter jobSplitter 
)
virtual

Run a simulation update for lightning.

Parameters
timeStepThe time step to simulate.
currentTimeThe current simulation time.
jobSplitterA job splitter to add simulation jobs to.
virtual bool makVrv::DtWeatherLightning::cullUpdate ( const osg::Vec3d &  camPos,
const osg::Matrixd &  viewMatrixI,
const Frustum_64 frustum,
DtJobSplitter jobSplitter 
)
virtual

Culls the area based on the current camera.

Parameters
camThe current camera being drawn.
frustumThe frustum used for culling.
jobSplitterA job splitter to add predraw jobs to. Returns true if visible.
virtual void makVrv::DtWeatherLightning::draw ( DtWeatherLightning::DrawData drawData)
virtual

Draw active lightning.

virtual void makVrv::DtWeatherLightning::setBounds ( const DtVector &  bounds,
float  cornerRadius 
)
virtual

Sets the bounds of the object.

Parameters
boundsThe (x,y,z) of the bounds.
cornerRadiusThe radius at each corner of the bounds.
virtual void makVrv::DtWeatherLightning::setTransform ( const osg::Vec3d &  position,
const osg::Matrixd &  rotation 
)
virtual

Sets the object transform.

Parameters
positionThe transform position in world space.
orientationThe yaw orientation in degrees (0 = north).
virtual void makVrv::DtWeatherLightning::setIntensity ( const float  intensity)
virtual

Sets the intensity.

Parameters
intensityThe intensity (affects visibility).
virtual void makVrv::DtWeatherLightning::setBaseColor ( const DtVector &  color)
virtual

Sets a base color for the lightning bolts.

Parameters
colorThe rgb color values (0.0 - 1.0 scale).
virtual void makVrv::DtWeatherLightning::runSort ( const osg::Vec3 &  localCamPos)
virtual

Sorts particles for the current view. Fills indice buffer.

Parameters
localCamPosThe local camera position.
virtual void makVrv::DtWeatherLightning::setEnabled ( bool  enabled)
virtual

Enables or disables the lightning.

Parameters
enabledSet to true to enable the lightning.
virtual bool makVrv::DtWeatherLightning::enabled ( ) const
virtual

Returns the enabled state.

virtual bool makVrv::DtWeatherLightning::culled ( ) const
virtual

Returns the culled state. This will indicate if the lightning was culled during the last scenegraph culling pass.

virtual void makVrv::DtWeatherLightning::computeBounds ( osg::Vec4 &  bounds,
osg::Vec3d &  position,
osg::Matrixd &  rotation 
) const
virtual

Computes the bounds of the area.

Parameters
boundsThe output (width, length, height, corner radius).
positionThe output world postition.
rotationThe output world rotation.
virtual void makVrv::DtWeatherLightning::initBoltMeshGroup ( LightningBolt bolt)
protectedvirtual

Initializes a mesh group for the given lightning bolt.

Parameters
boltThe lightning bolt object to initialize the mesh group for.
virtual void makVrv::DtWeatherLightning::computeBoltAliveTimeRange ( float &  minTime,
float &  maxTime 
) const
protectedvirtual

Computes the min and max lifetime range to chose from for a lightning bolt.

Parameters
minTime- the computed/returned minimum time
maxTime- the computed/returned maximum time
virtual void makVrv::DtWeatherLightning::createBolt ( const osg::Vec3 &  start,
const osg::Vec3 &  end 
)
protectedvirtual

Creates a lightning bolt between the given start and end points.

Parameters
startThe local starting position.
endThe local ending position.
virtual void makVrv::DtWeatherLightning::createFingerSegments ( LightningBolt bolt,
LightningFinger finger 
)
protectedvirtual

Creates a lightning bolt finger segments between the given start and end points.

bolt The lightning bolt that the finger belongs to. finger The lightning bolt finger to process.

virtual bool makVrv::DtWeatherLightning::positionInBounds2D ( const float  x,
const float  y,
const osg::Vec3 &  bounds 
)
protectedvirtual

Checks to see if the local 2D position is within the bounds. Uses the current bound corner radius.

Parameters
xThe local x position
yThe local y position.
boundsThe (x, y, corner radius) bounds.
virtual float makVrv::DtWeatherLightning::computeRandomMinMax ( float  fMin,
float  fMax 
)
protectedvirtual

Computes a random floating point value in the min max range.

Parameters
minThe minimum value.
maxThe maximum value.
virtual bool makVrv::DtWeatherLightning::updateRandomSeed ( double  currentTime)
protectedvirtual

Update the random seed for myRandomNumberGen. Syncs the seed with NTP. Returns true if seed updated. Default sync is every 20 seconds.

Parameters
Thecurrent time, should be NTP.
virtual void makVrv::DtWeatherLightning::setRandomSeedSyncTimeInterval ( unsigned long  intervalInMs)
protectedvirtual

Update time between NTP syncs for the random seed. Default sync is every 20 seconds. This may need changed if lightning strikes are occuring more than every 20 seconds.

Parameters
Intervalin milliseconds, default 20000.
virtual void makVrv::DtWeatherLightning::computeSortDepth ( const osg::Vec3 &  reference)
protectedvirtual

Computes the sort depth for all cells.

Parameters
referenceThe reference position to compute sort depth from.
void makVrv::DtWeatherLightning::fillMeshGroupFlashPoint ( LightningBolt bolt)
protected

Fills the gpu buffer with 4 vertices for the flash point. The flash point is the lightning point of origin.

Parameters
boltThe lightning bolt data to use.
virtual void makVrv::DtWeatherLightning::fillMeshGroup ( LightningBolt bolt,
LightningFinger finger 
)
protectedvirtual

Fills the gpu buffer with sorted lightning bolt data. Recursively calls for child bolt fingers.

Parameters
boltThe lightning bolt data to use.
fingerThe lightning finger data to use.
virtual bool makVrv::DtWeatherLightning::bindMeshGroupData ( MeshGroup meshGroup,
osg::RenderInfo &  renderInfo 
) const
protectedvirtual

Binds the mesh group data to the vbo's.

Parameters
meshGroupThe mesh group object to bind.
renderInfoThe current rendering info.
virtual bool makVrv::DtWeatherLightning::bindDynamicMeshGroupData ( MeshGroup meshGroup,
osg::RenderInfo &  renderInfo 
) const
protectedvirtual

Binds the dynamic mesh group data to the vbo's.

Parameters
meshGroupThe mesh group object to bind.
renderInfoThe current rendering info.
virtual bool makVrv::DtWeatherLightning::bindVaoToMeshGroup ( GLuint  vao,
MeshGroup meshGroup,
osg::RenderInfo &  renderInfo 
) const
protectedvirtual

Binds the given voa to vbo's for a mesh group.

Parameters
vaoThe GL VAO handle.
meshGroupThe mesh group to bind.
renderInfoThe current rendering info.
const osg::Vec3 makVrv::DtWeatherLightning::crossProduct ( const osg::Vec3 &  v0,
const osg::Vec3 &  v1 
) const
protected

Returns the cross product of the given 2 vectors.

Parameters
v0The first vector.
v1The second vector.
static void makVrv::DtWeatherLightning::theSortJob ( void *  data)
staticprotected

sort job function used as a callback for job splitting

Friends And Related Function Documentation

friend class DtWeatherLightningFactory
friend
friend struct SortDistanceComparator
friend

Member Data Documentation

friend makVrv::DtWeatherLightning::DtWeatherLightningCreator
DtDe& makVrv::DtWeatherLightning::myDe
protected
bool makVrv::DtWeatherLightning::myEnabled
protected
bool makVrv::DtWeatherLightning::myCulled
protected
osg::Vec3d makVrv::DtWeatherLightning::myPosition
protected
osg::Matrixd makVrv::DtWeatherLightning::myRotation
protected
float makVrv::DtWeatherLightning::myBoundsX
protected
float makVrv::DtWeatherLightning::myBoundsY
protected
float makVrv::DtWeatherLightning::myBoundsZ
protected
float makVrv::DtWeatherLightning::myBoundsCornerRadius
protected
float makVrv::DtWeatherLightning::myBoltWidth
protected
float makVrv::DtWeatherLightning::myIntensity
protected
osg::Vec3 makVrv::DtWeatherLightning::myBaseColor
protected
std::vector<LightningBolt*> makVrv::DtWeatherLightning::myMutableLightningBoltsPool
mutableprotected
std::vector<LightningBolt*> makVrv::DtWeatherLightning::myMutableLightningBoltsActive
mutableprotected
SortJobData makVrv::DtWeatherLightning::mySortJobData
protected
DtJobSplitterJob makVrv::DtWeatherLightning::mySortJob
protected
DtRandomNumberGenerator makVrv::DtWeatherLightning::myRandomNumberGen
protected
unsigned int makVrv::DtWeatherLightning::myRandomSeed
protected
unsigned long makVrv::DtWeatherLightning::mySeedSyncInterval
protected
unsigned long makVrv::DtWeatherLightning::myNextSyncTime
protected
float makVrv::DtWeatherLightning::myStrikeTimeMin
protected
float makVrv::DtWeatherLightning::myStrikeTimeMax
protected
float makVrv::DtWeatherLightning::myStrikeTimer
protected
DtLight* makVrv::DtWeatherLightning::myLight
protected

The documentation for this class was generated from the following file:

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)