#include <water_pool_manager.h>
Nevrax France
Definition at line 48 of file water_pool_manager.h.
Public Member Functions | |
CWaterHeightMap * | createWaterPool (const CWaterHeightMapBuild ¶ms=CWaterHeightMapBuild()) |
create a water pool with the given id and the given parameters. If the pool existed before, its parameter are reset | |
uint | getNumPools () const |
Get the number of pools. | |
CWaterHeightMap & | getPoolByID (uint32 ID) |
Get a water pool by its ID. If the ID doesn't exist, a new pool is created with default parameters. | |
uint | getPoolID (uint i) const |
get the id of the i-th pool (O(n) lookup) | |
bool | hasPool (uint32 ID) const |
test wether a pool of the given ID exists | |
void | releaseBlendTextures () |
void | removePool (uint32 ID) |
remove the pool of the given ID | |
void | reset () |
delete all heightmaps | |
void | serial (NLMISC::IStream &f) throw (NLMISC::EStream) |
serial the pools data's | |
void | setBlendFactor (IDriver *drv, float factor) |
~CWaterPoolManager () | |
Private Types | |
typedef std::map< uint32, CWaterHeightMap * > | TPoolMap |
typedef std::vector< CWaterShape * > | TWaterShapeVect |
Private Member Functions | |
CWaterPoolManager () | |
bool | isWaterShapeObserver (const CWaterShape *shape) const |
void | registerWaterShape (CWaterShape *shape) |
register a water height map. The water height map will be notified when a setBlend is applied | |
void | unRegisterWaterShape (CWaterShape *shape) |
Private Attributes | |
TPoolMap | _PoolMap |
TWaterShapeVect | _WaterShapes |
Friends | |
class | CWaterShape |
CWaterPoolManager & | GetWaterPoolManager () |
|
Definition at line 113 of file water_pool_manager.h. |
|
Definition at line 120 of file water_pool_manager.h. |
|
Definition at line 92 of file water_pool_manager.h. References reset().
00092 { reset(); } |
|
Definition at line 112 of file water_pool_manager.h.
00112 {} // private ctor needed to use the singleton pattern
|
|
create a water pool with the given id and the given parameters. If the pool existed before, its parameter are reset
Definition at line 93 of file water_pool_manager.cpp. References _PoolMap, NL3D::CWaterHeightMap::enableWaves(), params, NL3D::CWaterHeightMap::setDamping(), NL3D::CWaterHeightMap::setFilterWeight(), NL3D::CWaterHeightMap::setName(), NL3D::CWaterHeightMap::setSize(), NL3D::CWaterHeightMap::setUnitSize(), and NL3D::CWaterHeightMap::setWaves(). Referenced by getPoolByID().
00094 { 00095 CWaterHeightMap *whm = _PoolMap.count(params.ID) == 0 ? new CWaterHeightMap : _PoolMap[params.ID]; 00096 whm->setDamping(params.Damping); 00097 whm->setFilterWeight(params.FilterWeight); 00098 whm->setSize(params.Size); 00099 whm->setUnitSize(params.UnitSize); 00100 whm->setWaves(params.WaveIntensity, params.WavePeriod, params.WaveRadius, params.BorderWaves); 00101 whm->enableWaves(params.WavesEnabled); 00102 whm->setName(params.Name); 00103 _PoolMap[params.ID] = whm; // in case it was just created 00104 return whm; 00105 } |
|
Get the number of pools.
Definition at line 197 of file water_pool_manager.cpp. References _PoolMap, and uint. Referenced by getPoolID().
00198 { 00199 return _PoolMap.size(); 00200 } |
|
Get a water pool by its ID. If the ID doesn't exist, a new pool is created with default parameters.
Definition at line 109 of file water_pool_manager.cpp. References _PoolMap, createWaterPool(), and uint32. Referenced by NL3D::CWaveMakerShape::clip(), NL3D::CWaterModel::getAttenuatedHeight(), NL3D::CWaterModel::getHeight(), NL3D::UWaterHeightMapManager::getWaterHeightMapFromID(), NL3D::CWaveMakerModel::traverseAnimDetail(), and NL3D::CWaterModel::traverseRender().
00110 { 00111 if(_PoolMap.count(ID)) 00112 { 00113 return *_PoolMap[ID]; 00114 } 00115 else 00116 { 00117 return *createWaterPool(); 00118 } 00119 } |
|
get the id of the i-th pool (O(n) lookup)
Definition at line 204 of file water_pool_manager.cpp. References _PoolMap, getNumPools(), nlassert, and uint.
00205 { 00206 nlassert(i < getNumPools()); 00207 TPoolMap::const_iterator it = _PoolMap.begin(); 00208 while (i--) ++it; 00209 return it->first; 00210 } |
|
test wether a pool of the given ID exists
Definition at line 86 of file water_pool_manager.cpp. References _PoolMap, and uint32. Referenced by removePool().
00087 { 00088 return _PoolMap.count(ID) != 0; 00089 } |
|
Definition at line 190 of file water_pool_manager.cpp. References _WaterShapes. Referenced by NL3D::CWaterShape::envMapUpdate().
00191 { 00192 return std::find(_WaterShapes.begin(), _WaterShapes.end(), shape) != _WaterShapes.end(); 00193 } |
|
register a water height map. The water height map will be notified when a setBlend is applied
Definition at line 135 of file water_pool_manager.cpp. References _WaterShapes, and nlassert. Referenced by NL3D::CWaterShape::envMapUpdate().
00136 { 00137 nlassert(std::find(_WaterShapes.begin(), _WaterShapes.end(), shape) == _WaterShapes.end()); // Shape registered twice! 00138 _WaterShapes.push_back(shape); 00139 } |
|
release blend textures from memory
Definition at line 171 of file water_pool_manager.cpp. References _WaterShapes, NL3D::CTextureBlend::release(), NL3D::ITexture::setReleasable(), and uint. Referenced by NL3D::UWaterHeightMapManager::releaseBlendTextures().
00172 { 00173 for (TWaterShapeVect::iterator it = _WaterShapes.begin(); it != _WaterShapes.end(); ++it) 00174 { 00175 CTextureBlend *tb; 00176 for (uint k = 0; k < 2; ++k) 00177 { 00178 tb = dynamic_cast<CTextureBlend *>((*it)->getEnvMap(k)); 00179 if (tb) 00180 { 00181 tb->setReleasable(true); 00182 tb->release(); 00183 } 00184 } 00185 } 00186 } |
|
remove the pool of the given ID
Definition at line 214 of file water_pool_manager.cpp. References _PoolMap, hasPool(), nlassert, and uint32.
|
|
delete all heightmaps
Definition at line 123 of file water_pool_manager.cpp. References _PoolMap. Referenced by NL3D::UDriver::purgeMemory(), and ~CWaterPoolManager().
|
|
serial the pools data's
Definition at line 223 of file water_pool_manager.cpp.
00224 { 00225 f.xmlPush("WaterPoolManager"); 00226 (void)f.serialVersion(0); 00227 uint32 size; 00228 TPoolMap::iterator it; 00229 if (!f.isReading()) 00230 { 00231 size = _PoolMap.size(); 00232 it = _PoolMap.begin(); 00233 } 00234 else 00235 { 00236 reset(); 00237 } 00238 f.xmlSerial(size, "NUM_POOLS"); 00239 while (size --) 00240 { 00241 f.xmlPush("PoolDesc"); 00242 if (f.isReading()) 00243 { 00244 CWaterHeightMap *whm; 00245 uint32 id; 00246 f.xmlSerial(id, "POOL_ID"); 00247 f.serialPtr(whm); 00248 _PoolMap[id] = whm; 00249 } 00250 else 00251 { 00252 uint32 id = it->first; 00253 f.xmlSerial(id, "POOL_ID"); 00254 f.serialPtr(it->second); 00255 ++it; 00256 } 00257 f.xmlPop(); 00258 } 00259 f.xmlPop(); 00260 } |
|
Set a blend factor for all pool (more precisely, all models based on a water shape) that have a blend texture for their envmap (to have cycle between night and day for example) NB : once this is called, textures are not released from memory because subsequent blends are expected to happend when transition has finished, one should call releaseBlendTexture to eventually release textures from system memory
Definition at line 152 of file water_pool_manager.cpp. References _WaterShapes, nlassert, NL3D::CTextureBlend::setBlendFactor(), NL3D::ITexture::setReleasable(), NL3D::IDriver::setupTexture(), uint, and uint16. Referenced by NL3D::UWaterHeightMapManager::setBlendFactor().
00153 { 00154 nlassert(factor >= 0 && factor <= 1); 00155 for (TWaterShapeVect::iterator it = _WaterShapes.begin(); it != _WaterShapes.end(); ++it) 00156 { 00157 CTextureBlend *tb; 00158 for (uint k = 0; k < 2; ++k) 00159 { 00160 tb = dynamic_cast<CTextureBlend *>((*it)->getEnvMap(k)); 00161 if (tb && tb->setBlendFactor((uint16) (256.f * factor))) 00162 { 00163 tb->setReleasable(false); 00164 drv->setupTexture(*tb); 00165 } 00166 } 00167 } 00168 } |
|
Definition at line 143 of file water_pool_manager.cpp. References _WaterShapes. Referenced by NL3D::CWaterShape::envMapUpdate(), and NL3D::CWaterShape::~CWaterShape().
00144 { 00145 TWaterShapeVect::iterator it = std::find(_WaterShapes.begin(), _WaterShapes.end(), shape); 00146 // nlassert(it != _WaterShapes.end()); // shape not registered! 00147 if (it != _WaterShapes.end()) 00148 _WaterShapes.erase(it); 00149 } |
|
Definition at line 110 of file water_pool_manager.h. |
|
Definition at line 78 of file water_pool_manager.cpp.
00079 { 00080 static CWaterPoolManager singleton; 00081 return singleton; 00082 } |
|
Definition at line 114 of file water_pool_manager.h. Referenced by createWaterPool(), getNumPools(), getPoolByID(), getPoolID(), hasPool(), removePool(), and reset(). |
|
Definition at line 121 of file water_pool_manager.h. Referenced by isWaterShapeObserver(), registerWaterShape(), releaseBlendTextures(), setBlendFactor(), and unRegisterWaterShape(). |