-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMeTimelineRainyEvent.h
executable file
·170 lines (126 loc) · 3.98 KB
/
MeTimelineRainyEvent.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#pragma once
#include <MeFoundation/MeTimelineShadeEvent.h>
class CHeightMapData;
/**
* @brief Rain Effect。
*/
class MEFOUNDATION_ENTRY MeTimelineRainyEvent : public MeTimelineShadeEvent
{
// Defines.
protected:
/// Rain's Vertex Definition.
struct MeRainVertex
{
Vector3 m_kPosition; // Pos
Vector2 m_kUV; // UV
};
/// RainSpray's Vertex Definition.
struct MeRainSprayVertex
{
Vector3 m_kPosition;
DWORD m_kColor;
Vector2 m_kUV;
};
/// RainSpray's visible structure.
struct RainSprayVisible
{
bool m_bVisible;
MeEngine::int64 m_kStartTime;
};
// Construction.
public:
/// Constructor.
MeTimelineRainyEvent()
: mdwTime( 0 )
{}
/// Copy constructor.
MeTimelineRainyEvent( const MeTimelineRainyEvent& kClass )
:mdwTime( 0 )
{}
// Overload operator.
public:
/// Assignment operator.
const MeTimelineRainyEvent& operator=( const MeTimelineRainyEvent& kClass ){ return *this; }
// Override.
public:
/// Destructor.
virtual ~MeTimelineRainyEvent(){}
/// Initialize.
virtual void InitializeEvent();
/// Destroy.
virtual void DestroyEvent();
/// Reset.
virtual void ResetEvent();
/// Render.
virtual void RenderEvent();
/// Update from nothing to appearence
virtual void UpdateBeginToFull( const MeEngine::int64& kTime );
/// Keeping update after appearence
virtual void UpdateInFull( const MeEngine::int64& kTime );
/// Update to disappear
virtual void UpdateFullToEnd( const MeEngine::int64& kTime );
// Methods.
public:
/// set resource file
static void SetRainTextureFilename( const std::string& strFilename ){ ms_strRainTextureFilename = strFilename; }
/// set rainy range
static void SetRainyRange( int nRange ){ ms_nRainyRange = nRange; }
/// set drop speed
static void SetRainySpeed( float fSpeed ){ ms_fRainSpeed = fSpeed; }
/// set drop height
static void SetRaindropHeight( float fHeight ){ ms_fRaindropHeight = fHeight; }
/// set center position
static void SetCurrentPosition( const Vector3& rkPos ){ ms_kPosition = rkPos; }
// Methods.
protected:
/// rain vertex
void GenerateRainVertex( int nStartPosition, float fRadius );
/// rain's Z
void UpdateRainVertexZ( unsigned int uiCount, const MeEngine::int64& kTimeValue );
/// set spray UV and vertex color
void UpdateRainSprayUVnColor( unsigned int uiCount, const MeEngine::int64& kTimeValue );
/// set position of spray
void UpdateRainSprayPosition( int nVertexIndex, int nSprayIndex, const MeEngine::int64& kTimeValue, CHeightMapData* pHeightData );
/// render spray
void RenderRainSpray();
/// render
void RenderRain();
/// random rainy drop
float GetRandomZOffsetValue();
// Static Members.
public:
/// rain drop count
static const int ms_ncRainDropCount = 1000;
/// rain vertex count
static const int ms_ncRainVecticesCount = ms_ncRainDropCount * 3;
/// spray vertex count
static const int ms_ncRainSprayVecticesCount = ms_ncRainDropCount * 3;
// Members.
protected:
/// array of rain drops
static MeRainVertex ms_kRainVertices[ms_ncRainVecticesCount];
/// offset of spray vertices
static Vector3 ms_kRainSprayVerticesOffset[ms_ncRainSprayVecticesCount];
/// spray vertices
static MeRainSprayVertex ms_kRainSprayVertices[ms_ncRainSprayVecticesCount];
/// are spray visible
static RainSprayVisible ms_bRainSprayVisible[ms_ncRainDropCount];
/// current render count of rainy drops
static int ms_nRenderCount;
/// tex of rain drop
static MeEngine::TexturePtr ms_nRainTextureId;
/// tex of spray
static MeEngine::TexturePtr ms_nRainSprayTextureId;
/// current pos
static Vector3 ms_kPosition;
/// res of tex of rain
static std::string ms_strRainTextureFilename;
/// res of tex of spray
static std::string ms_strRainSprayTextureFilename;
/// rang of rain
static int ms_nRainyRange;
/// speed of drop
static float ms_fRainSpeed;
/// heigh of a drop
static float ms_fRaindropHeight;
};