1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef CL_PRECIPITATION_H
22 #define CL_PRECIPITATION_H
24 #include "precipitation_clip_grid.h"
25 #include "nel/misc/vector_2f.h"
26 #include "nel/3d/u_particle_system_instance.h"
37 class UGlobalRetriever
;
44 ///////////////////////////////////////////////////////////
45 // class to describe precipitations //
46 // Several instances of the same shared FX are displayed //
47 ///////////////////////////////////////////////////////////
48 struct CPrecipitationDesc
50 std::string FxName
; // name of the FX used for precipitations
51 uint GridSize
; // Size of the grid used to display FXs.
52 bool UseBBoxSize
; // The size of each block of the grid is taken from the x & y coordinates of the bbox.
53 // When set to false, 'Size' is used instead
54 float Size
; // Size of the blocks, it is used only if UseBBoxSize is set to false.
55 bool ReleasableModel
; // Models are allocated only if particles are needed. This avoid useless models traversal during the render when thare are no precipitations.
61 ReleasableModel
= true;
66 ///////////////////////////////////
67 // class to manage Precipitations //
68 ///////////////////////////////////
75 // Init the precipitations, and load associated fx
76 void init(const CPrecipitationDesc
&desc
);
77 // Release datas. Should call this if the scene is still present.
79 // Update precipitations depending on the camera position & orientation
80 void update(const NLMISC::CMatrix
&camMat
, NLPACS::UGlobalRetriever
*retriever
);
81 /** Set strenght for rain. Should go from 0 to 1 (clamped).
84 void setStrenght(float strenght
);
85 /// After strenght has been set to 0, it may need some time before there are no more particle in the fx. This allow to now if the fx i still running
86 bool isRunning() const;
88 // For clip grid : Draw the clip grid associated with taht precipitation
89 void drawClipGrid(NL3D::UDriver
&drv
) const;
91 // get description of precipitation
92 const CPrecipitationDesc
&getDesc() const { return _Desc
; }
94 /////////////////////////////////////////////////////////
95 /////////////////////////////////////////////////////////
97 typedef std::map
<NLMISC::CVector2f
, CPrecipitationClipGrid
> TClipGridMap
;
99 CPrecipitationClipGrid
*_ClipGrid
;
100 std::vector
<NL3D::UParticleSystemInstance
> _Blocks
;
107 bool _Touched
; // when set to true, force the next grid update
108 CPrecipitationDesc _Desc
;
109 // the precipitation clip girds, sorted by size
110 static TClipGridMap _PrecipitationClipGripMap
;
112 // helper to view the vector as a 2D tab
113 NL3D::UParticleSystemInstance
getBlock(uint x
, uint y
)
115 nlassert(x
< _Desc
.GridSize
&& y
< _Desc
.GridSize
);
116 return _Blocks
[x
+ y
* _Desc
.GridSize
];
120 // deallocate the FXs
121 void deallocateFXs();
123 bool areFXsAllocated() const { return !_Blocks
.empty(); }
124 // Force the setup of strenght with no check for previous value
125 void forceSetStrenght(float strenght
);