# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NL3D::CWaterHeightMap Class Reference

#include <water_height_map.h>

Inheritance diagram for NL3D::CWaterHeightMap:

NL3D::UWaterHeightMap List of all members.

Public Methods

void animate (float deltaT)
 Animate this water pool. More...

void setSize (uint32 size)
 Set this quad dimension. More...

uint32 getSize (void) const
 return the size of the height map. More...

void setUserPos (sint x, sint y)
 Set the userPos (relative to the height map coordinates). More...

void getUserPos (sint &x, sint &y) const
 Retrieve the use pos NB: this may be different from the params of a former call to setUserPos (should have been taken in account). More...

void perturbate (sint x, sint y, sint radius, float intensity)
 create a perturbation in the height map. More...

virtual void perturbate (const NLMISC::CVector2f &pos, float strenght, float radius)
 Inherited from UWaterHeightMap. More...

void perturbatePoint (sint x, sint y, float intensity)
 create a point perturbation in the height map. More...

virtual void perturbatePoint (const NLMISC::CVector2f &pos, float strenght)
 Inherited from UWaterHeightMap. More...

virtual float getHeight (const NLMISC::CVector2f &pos)
 Inherited from UWaterHeightMap. More...

float * getPointer (void)
 get a pointer on the current buffer. More...

float * getPrevPointer (void)
 get a pointer on the previous buffer. More...

float getBufferRatio () const
 get the ratio between the previous and the current buffer. More...

void enableWaves (bool enabled=true)
 enable automatic waves generation. More...

bool areWavesEnabled () const
 test wheter automatic waves generation is enabled. More...

void setWaves (float intensity, float period, uint radius, bool border)
 Tells this height map the params to automatically generate waves. More...

float getWaveIntensity () const
 get the intensity of waves. More...

float getWavePeriod () const
 get the period of waves. More...

uint32 getWaveImpulsionRadius () const
 radius of impulsion for the waves. More...

bool getBorderWaves () const
 Test whether waves are enabled on the border. More...

void setDamping (float damping)
 damping. More...

float getDamping () const
void setFilterWeight (float filterWeight)
 filter weight. More...

float getFilterWeight () const
void setUnitSize (float unitSize)
 water unit size. More...

float getUnitSize () const
 get the size in meter of a heightmap texel. More...

void serial (NLMISC::IStream &f) throw (NLMISC::EStream)
 serial the pools data's. More...

void setName (const std::string &name)
 Set this pool name. More...

const std::string & getName () const
 Get this pool name. More...

 CWaterHeightMap ()
virtual ~CWaterHeightMap ()
void setPropagationTime (float time)
 Set the propagation time. This is the time needed to go from one unit to one other in the height map. More...

TAnimationTime getPropagationTime () const
 Get the propagation time. More...


Public Attributes

sint64 Date
 the last update date. More...


Private Types

typedef std::vector< float > TFloatVect
typedef std::vector< NLMISC::CVector2fTFloat2Vect

Private Methods

void animateWaves (float deltaT)
void updateUserPos ()
void animatePart (float startTime, float endTime)
void propagate (uint startLine, uint endLine)
 Perform water propagation on this quad. More...

void filter (uint startLine, uint endLine)
 apply a filter on the height field. More...

void swapBuffers (float deltaT)
 swap the height maps. It must be called once propagation and filtering have been performed. More...

void clearArea (uint8 currMap, sint x, sint y, sint width, sint height)
 clear an area of the water height map (has clipping, but no wrapping). More...

void clearZone (sint x, sint y, sint width, sint height)
void makeCpy (uint buffer, uint dX, uint dY, uint sX, uint sY, uint width, uint height)
 displace the height map, when a boundary has been reached. More...

void clearBorder (uint currMap)
 clear the borders. More...


Private Attributes

std::string _Name
bool _WavesEnabled
float _Damping
float _FilterWeight
float _UnitSize
float _WaveIntensity
float _WavePeriod
uint32 _WaveImpulsionRadius
bool _BorderWaves
float _EmitEllapsedTime
float _PropagateEllapsedTime
TAnimationTime _PropagationTime
uint _X
uint _Y
uint _NewX
uint _NewY
TFloatVect _Map [NumWaterMap]
uint8 _CurrMap
uint32 _Size

Friends

class CWaterPoolManager

Member Typedef Documentation

typedef std::vector<NLMISC::CVector2f > NL3D::CWaterHeightMap::TFloat2Vect [private]
 

Definition at line 237 of file water_height_map.h.

typedef std::vector<float> NL3D::CWaterHeightMap::TFloatVect [private]
 

Definition at line 236 of file water_height_map.h.

Referenced by perturbate, and perturbatePoint.


Constructor & Destructor Documentation

NL3D::CWaterHeightMap::CWaterHeightMap  
 

Definition at line 42 of file water_height_map.cpp.

virtual NL3D::CWaterHeightMap::~CWaterHeightMap   [inline, virtual]
 

Definition at line 188 of file water_height_map.h.


Member Function Documentation

void NL3D::CWaterHeightMap::animate float    deltaT
 

Animate this water pool.

Usually called by CWaterModel before the display, if this height map date is not the same as the current date.

Definition at line 236 of file water_height_map.cpp.

References _PropagateEllapsedTime, _PropagationTime, animatePart, animateWaves, and swapBuffers.

void NL3D::CWaterHeightMap::animatePart float    startTime,
float    endTime
[private]
 

Definition at line 212 of file water_height_map.cpp.

References _PropagationTime, _Size, filter, and propagate.

Referenced by animate.

void NL3D::CWaterHeightMap::animateWaves float    deltaT [private]
 

Definition at line 442 of file water_height_map.cpp.

References _BorderWaves, _EmitEllapsedTime, _NewX, _NewY, _Size, _WaveImpulsionRadius, _WaveIntensity, _WavePeriod, and perturbate.

Referenced by animate.

bool NL3D::CWaterHeightMap::areWavesEnabled   const [inline]
 

test wheter automatic waves generation is enabled.

Definition at line 138 of file water_height_map.h.

References _WavesEnabled.

void NL3D::CWaterHeightMap::clearArea uint8    currMap,
sint    x,
sint    y,
sint    width,
sint    height
[private]
 

clear an area of the water height map (has clipping, but no wrapping).

Definition at line 533 of file water_height_map.cpp.

References _Map, _Size, height, nlassert, width, x, and y.

Referenced by clearZone, setPropagationTime, and setSize.

void NL3D::CWaterHeightMap::clearBorder uint    currMap [private]
 

clear the borders.

Definition at line 635 of file water_height_map.cpp.

References _Map, _Size, _X, and _Y.

Referenced by propagate.

void NL3D::CWaterHeightMap::clearZone sint    x,
sint    y,
sint    width,
sint    height
[private]
 

Definition at line 523 of file water_height_map.cpp.

References clearArea, height, NL3D::NumWaterMap, width, x, and y.

Referenced by updateUserPos.

void NL3D::CWaterHeightMap::enableWaves bool    enabled = true [inline]
 

enable automatic waves generation.

Definition at line 135 of file water_height_map.h.

References _WavesEnabled.

void NL3D::CWaterHeightMap::filter uint    startLine,
uint    endLine
[private]
 

apply a filter on the height field.

Definition at line 399 of file water_height_map.cpp.

References _CurrMap, _FilterWeight, _Map, _Size, _X, _Y, min, nlassert, NL3D::NumWaterMap, offset, x, and y.

Referenced by animatePart.

bool NL3D::CWaterHeightMap::getBorderWaves   const [inline]
 

Test whether waves are enabled on the border.

Definition at line 159 of file water_height_map.h.

References _BorderWaves.

float NL3D::CWaterHeightMap::getBufferRatio   const [inline]
 

get the ratio between the previous and the current buffer.

Definition at line 128 of file water_height_map.h.

References _PropagateEllapsedTime, and _PropagationTime.

Referenced by getHeight.

float NL3D::CWaterHeightMap::getDamping   const [inline]
 

Definition at line 163 of file water_height_map.h.

References _Damping.

float NL3D::CWaterHeightMap::getFilterWeight   const [inline]
 

Definition at line 167 of file water_height_map.h.

References _FilterWeight.

float NL3D::CWaterHeightMap::getHeight const NLMISC::CVector2f   pos [virtual]
 

Inherited from UWaterHeightMap.

Get the height of water at the given location.

Implements NL3D::UWaterHeightMap.

Definition at line 726 of file water_height_map.cpp.

References _Size, _UnitSize, _X, _Y, NL3D::BilinFilter, getBufferRatio, getPointer, getPrevPointer, offset, NLMISC::CVector2f::x, and NLMISC::CVector2f::y.

const std::string& NL3D::CWaterHeightMap::getName void    const [inline]
 

Get this pool name.

Definition at line 183 of file water_height_map.h.

References _Name.

float* NL3D::CWaterHeightMap::getPointer void    [inline]
 

get a pointer on the current buffer.

Definition at line 122 of file water_height_map.h.

References _CurrMap, and _Map.

Referenced by getHeight.

float* NL3D::CWaterHeightMap::getPrevPointer void    [inline]
 

get a pointer on the previous buffer.

Definition at line 125 of file water_height_map.h.

References _CurrMap, _Map, and NL3D::NumWaterMap.

Referenced by getHeight.

TAnimationTime NL3D::CWaterHeightMap::getPropagationTime   const [inline]
 

Get the propagation time.

Definition at line 194 of file water_height_map.h.

References _PropagationTime, and NL3D::TAnimationTime.

uint32 NL3D::CWaterHeightMap::getSize void    const [inline]
 

return the size of the height map.

Definition at line 82 of file water_height_map.h.

References _Size.

float NL3D::CWaterHeightMap::getUnitSize   const [inline, virtual]
 

get the size in meter of a heightmap texel.

Implements NL3D::UWaterHeightMap.

Definition at line 171 of file water_height_map.h.

References _UnitSize.

void NL3D::CWaterHeightMap::getUserPos sint   x,
sint   y
const
 

Retrieve the use pos NB: this may be different from the params of a former call to setUserPos (should have been taken in account).

Definition at line 347 of file water_height_map.cpp.

References _X, _Y, x, and y.

uint32 NL3D::CWaterHeightMap::getWaveImpulsionRadius   const [inline]
 

radius of impulsion for the waves.

Definition at line 156 of file water_height_map.h.

References _WaveImpulsionRadius.

float NL3D::CWaterHeightMap::getWaveIntensity   const [inline]
 

get the intensity of waves.

Definition at line 150 of file water_height_map.h.

References _WaveIntensity.

float NL3D::CWaterHeightMap::getWavePeriod   const [inline]
 

get the period of waves.

Definition at line 153 of file water_height_map.h.

References _WavePeriod.

void NL3D::CWaterHeightMap::makeCpy uint    buffer,
uint    dX,
uint    dY,
uint    sX,
uint    sY,
uint    width,
uint    height
[private]
 

displace the height map, when a boundary has been reached.

Definition at line 283 of file water_height_map.cpp.

References _Map, _Size, height, nlassert, src, stride, and width.

Referenced by updateUserPos.

void NL3D::CWaterHeightMap::perturbate const NLMISC::CVector2f   pos,
float    strenght,
float    radius
[virtual]
 

Inherited from UWaterHeightMap.

This version takes a location in world space

Implements NL3D::UWaterHeightMap.

Definition at line 601 of file water_height_map.cpp.

References _UnitSize, perturbate, NLMISC::CVector2f::x, and NLMISC::CVector2f::y.

void NL3D::CWaterHeightMap::perturbate sint    x,
sint    y,
sint    radius,
float    intensity
 

create a perturbation in the height map.

Definition at line 575 of file water_height_map.cpp.

References _CurrMap, _Map, _Size, _X, _Y, nlassert, NL3D::NumWaterMap, TFloatVect, v, x, and y.

Referenced by animateWaves, and perturbate.

void NL3D::CWaterHeightMap::perturbatePoint const NLMISC::CVector2f   pos,
float    strenght
[virtual]
 

Inherited from UWaterHeightMap.

This version takes a location in world space

Implements NL3D::UWaterHeightMap.

Definition at line 627 of file water_height_map.cpp.

References _UnitSize, perturbatePoint, NLMISC::CVector2f::x, and NLMISC::CVector2f::y.

void NL3D::CWaterHeightMap::perturbatePoint sint    x,
sint    y,
float    intensity
 

create a point perturbation in the height map.

Definition at line 609 of file water_height_map.cpp.

References _CurrMap, _Map, _Size, _X, _Y, NL3D::NumWaterMap, TFloatVect, x, and y.

Referenced by perturbatePoint.

void NL3D::CWaterHeightMap::propagate uint    startLine,
uint    endLine
[private]
 

Perform water propagation on this quad.

You should call swapBuffers after this, or after calling filter.

Parameters:
damping  The attenuation factor used for propagation.

Definition at line 356 of file water_height_map.cpp.

References _CurrMap, _Damping, _Map, _Size, _X, _Y, clearBorder, min, nlassert, NL3D::NumWaterMap, offset, x, and y.

Referenced by animatePart.

void NL3D::CWaterHeightMap::serial NLMISC::IStream   f throw (NLMISC::EStream)
 

serial the pools data's.

Definition at line 679 of file water_height_map.cpp.

void NL3D::CWaterHeightMap::setDamping float    damping [inline]
 

damping.

Definition at line 162 of file water_height_map.h.

References _Damping, and nlassert.

void NL3D::CWaterHeightMap::setFilterWeight float    filterWeight [inline]
 

filter weight.

Definition at line 166 of file water_height_map.h.

References _FilterWeight.

void NL3D::CWaterHeightMap::setName const std::string &    name [inline]
 

Set this pool name.

Definition at line 180 of file water_height_map.h.

References _Name.

void NL3D::CWaterHeightMap::setPropagationTime float    time
 

Set the propagation time. This is the time needed to go from one unit to one other in the height map.

Definition at line 66 of file water_height_map.cpp.

References _PropagateEllapsedTime, _PropagationTime, _Size, clearArea, and NL3D::NumWaterMap.

void NL3D::CWaterHeightMap::setSize uint32    size
 

Set this quad dimension.

It is given as a power of 2 This also reset the eightField values

Definition at line 269 of file water_height_map.cpp.

References _Map, _Size, clearArea, nlassert, and NL3D::NumWaterMap.

void NL3D::CWaterHeightMap::setUnitSize float    unitSize [inline]
 

water unit size.

Definition at line 170 of file water_height_map.h.

References _UnitSize.

void NL3D::CWaterHeightMap::setUserPos sint    x,
sint    y
 

Set the userPos (relative to the height map coordinates).

This is needed because a height map can't be used with large surface (such as a sea). As a consequence, the height map is only valid below the user (e.g from user.x - 0.5 * size to user.x + 0.5 *size). When setPos is called, and if a move has occured, new area of the height field are set to 0 The pos set will be taken in account when buffers have been swapped (e.g when the propagation time as ellapsed)

Definition at line 339 of file water_height_map.cpp.

References _NewX, _NewY, x, and y.

void NL3D::CWaterHeightMap::setWaves float    intensity,
float    period,
uint    radius,
bool    border
 

Tells this height map the params to automatically generate waves.

They are generated as perturbation on the border of the field

Parameters:
intensity  The intensity of the waves. 0 disable waves \period the time ellapsed between each waves \radius the radius od the impulsion of the waves to be created \border true if waves should only be generated on the border of height map, (actually, where waves can't be seen because of distance, this avoid to see the impulsion)

Definition at line 667 of file water_height_map.cpp.

References _BorderWaves, _WaveImpulsionRadius, _WaveIntensity, _WavePeriod, and border.

void NL3D::CWaterHeightMap::swapBuffers float    deltaT [private]
 

swap the height maps. It must be called once propagation and filtering have been performed.

Definition at line 514 of file water_height_map.cpp.

References _CurrMap, NL3D::NumWaterMap, and updateUserPos.

Referenced by animate.

void NL3D::CWaterHeightMap::updateUserPos   [private]
 

Definition at line 78 of file water_height_map.cpp.

References _NewX, _NewY, _Size, _X, _Y, clearZone, makeCpy, min, nlassert, NL3D::NumWaterMap, x, and y.

Referenced by swapBuffers.


Friends And Related Function Documentation

friend class CWaterPoolManager [friend]
 

Definition at line 218 of file water_height_map.h.


Member Data Documentation

bool NL3D::CWaterHeightMap::_BorderWaves [private]
 

Definition at line 228 of file water_height_map.h.

Referenced by animateWaves, getBorderWaves, and setWaves.

uint8 NL3D::CWaterHeightMap::_CurrMap [private]
 

Definition at line 241 of file water_height_map.h.

Referenced by filter, getPointer, getPrevPointer, perturbate, perturbatePoint, propagate, and swapBuffers.

float NL3D::CWaterHeightMap::_Damping [private]
 

Definition at line 222 of file water_height_map.h.

Referenced by getDamping, propagate, and setDamping.

float NL3D::CWaterHeightMap::_EmitEllapsedTime [private]
 

Definition at line 229 of file water_height_map.h.

Referenced by animateWaves.

float NL3D::CWaterHeightMap::_FilterWeight [private]
 

Definition at line 223 of file water_height_map.h.

Referenced by filter, getFilterWeight, and setFilterWeight.

TFloatVect NL3D::CWaterHeightMap::_Map[NumWaterMap] [private]
 

Definition at line 239 of file water_height_map.h.

Referenced by clearArea, clearBorder, filter, getPointer, getPrevPointer, makeCpy, perturbate, perturbatePoint, propagate, and setSize.

std::string NL3D::CWaterHeightMap::_Name [private]
 

Definition at line 220 of file water_height_map.h.

Referenced by getName, and setName.

uint NL3D::CWaterHeightMap::_NewX [private]
 

Definition at line 235 of file water_height_map.h.

Referenced by animateWaves, setUserPos, and updateUserPos.

uint NL3D::CWaterHeightMap::_NewY [private]
 

Definition at line 235 of file water_height_map.h.

Referenced by animateWaves, setUserPos, and updateUserPos.

float NL3D::CWaterHeightMap::_PropagateEllapsedTime [private]
 

Definition at line 230 of file water_height_map.h.

Referenced by animate, getBufferRatio, and setPropagationTime.

TAnimationTime NL3D::CWaterHeightMap::_PropagationTime [private]
 

Definition at line 231 of file water_height_map.h.

Referenced by animate, animatePart, getBufferRatio, getPropagationTime, and setPropagationTime.

uint32 NL3D::CWaterHeightMap::_Size [private]
 

Definition at line 242 of file water_height_map.h.

Referenced by animatePart, animateWaves, clearArea, clearBorder, filter, getHeight, getSize, makeCpy, perturbate, perturbatePoint, propagate, setPropagationTime, setSize, and updateUserPos.

float NL3D::CWaterHeightMap::_UnitSize [private]
 

Definition at line 224 of file water_height_map.h.

Referenced by getHeight, getUnitSize, perturbate, perturbatePoint, and setUnitSize.

uint32 NL3D::CWaterHeightMap::_WaveImpulsionRadius [private]
 

Definition at line 227 of file water_height_map.h.

Referenced by animateWaves, getWaveImpulsionRadius, and setWaves.

float NL3D::CWaterHeightMap::_WaveIntensity [private]
 

Definition at line 225 of file water_height_map.h.

Referenced by animateWaves, getWaveIntensity, and setWaves.

float NL3D::CWaterHeightMap::_WavePeriod [private]
 

Definition at line 226 of file water_height_map.h.

Referenced by animateWaves, getWavePeriod, and setWaves.

bool NL3D::CWaterHeightMap::_WavesEnabled [private]
 

Definition at line 221 of file water_height_map.h.

Referenced by areWavesEnabled, and enableWaves.

uint NL3D::CWaterHeightMap::_X [private]
 

Definition at line 234 of file water_height_map.h.

Referenced by clearBorder, filter, getHeight, getUserPos, perturbate, perturbatePoint, propagate, and updateUserPos.

uint NL3D::CWaterHeightMap::_Y [private]
 

Definition at line 234 of file water_height_map.h.

Referenced by clearBorder, filter, getHeight, getUserPos, perturbate, perturbatePoint, propagate, and updateUserPos.

sint64 NL3D::CWaterHeightMap::Date
 

the last update date.

Definition at line 174 of file water_height_map.h.


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