OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
tr_ghost.h
1/*
2===========================================================================
3Copyright (C) 2023-2024 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23#pragma once
24
25#include "tr_local.h"
26#include "../qcommon/vector.h"
27#include "../qcommon/container.h"
28#include "../qcommon/str.h"
29
30using outcode = unsigned int;
31
32class Particle
33{
34private:
35 float m_startTime;
36 float m_dieTime;
37
38 Vector m_velocity;
39 Vector m_acceleration;
40 Vector m_perp;
41
42 qboolean m_wavy;
43 float m_wavyDist;
44 float m_wavyOffset;
45
46 int m_srcColor;
47 int m_dstColor;
48 int m_deltaR;
49 int m_deltaG;
50 int m_deltaB;
51 int m_srcR;
52 int m_srcG;
53 int m_srcB;
54 int m_dstR;
55 int m_dstG;
56 int m_dstB;
57 float m_colorRate;
58
59 Vector m_realposition;
60
61 float m_life;
62 float m_maxspeed;
63
64 qboolean m_swarm;
65 int m_swarmfrequency;
66 int m_swarmdelta;
67
68 Vector m_parentOrigin;
69
70public:
71 Vector m_position;
72 int m_color;
73
74public:
75 Particle(
76 Vector pos,
77 Vector vel,
78 Vector acc,
79 int srcColor,
80 int dstColor,
81 float colorRate,
82 qboolean wavy,
83 float wavyDist,
84 float currentTime,
85 float dieTime,
86 float maxspeed,
87 Vector parentOrg,
88 qboolean swarm,
89 int freq,
90 int delta
91 );
92
93 void Update(float currentTime);
94 float GetDieTime();
95};
96
97class ParticleEmitter
98{
99private:
100 float m_time;
101 float m_lasttime;
102
103 Vector m_position;
104
105 int m_srcColor;
106 int m_dstColor;
107 float m_minColorRate;
108 float m_maxColorRate;
109
110 float m_minRate;
111 float m_maxRate;
112
113 float m_minLife;
114 float m_maxLife;
115
116 float m_angle;
117 float m_angleVar;
118
119 float m_minSpeed;
120 float m_maxSpeed;
121 float m_accAngle;
122 float m_accAngleVar;
123 float m_minAccSpeed;
124 float m_maxAccSpeed;
125
126 float m_minWavyDist;
127 float m_maxWavyDist;
128 qboolean m_wavy;
129
130 qboolean m_gravityWell;
131 float m_gravityWellStrength;
132
133 qboolean m_particles;
134 Vector m_gravityEffectVector;
135
136 qboolean m_ballLightning;
137 int m_minBallLightningRadius;
138 int m_maxBallLightningRadius;
139 float m_lightningVar;
140 int m_lightningSubdivisions;
141
142 qboolean m_swarm;
143 int m_swarmfrequency;
144 int m_swarmdelta;
145
146 int m_maxspeed;
147
148public:
149 Container<Particle *> particleList;
150
151public:
152 ParticleEmitter(
153 Vector position,
154 float minSpeed,
155 float maxSpeed,
156 float angle,
157 float angleVar,
158 float minAccSpeed,
159 float maxAccSpeed,
160 float accAngle,
161 float accAngleVar,
162 float minRate,
163 float maxRate,
164 int srcColor,
165 int dstColor,
166 float minColorRate,
167 float maxColorRate,
168 qboolean wavy,
169 float minWavyDist,
170 float maxWavyDist,
171 float minLife,
172 float maxLife,
173 qboolean particles,
174 qboolean gravityWell,
175 float gravityWellStrength,
176 qboolean ballLightning,
177 int minBallLightningRadius,
178 int maxBallLightningRadius,
179 float lightningVar,
180 int lightningSubdivisions,
181 qboolean swarm,
182 int swarmfreq,
183 int swarmdelta
184 );
185 ParticleEmitter();
186 ~ParticleEmitter();
187
188 void Emit(float currentTime);
189 void UpdateValues();
190
191 Vector GetPosition();
192 Vector GetVelocity();
193 Vector GetVelocityDirection();
194 Vector GetVelocityDirectionMin();
195 Vector GetVelocityDirectionMax();
196 Vector GetAcceleration();
197 Vector GetAccelerationDirection();
198 Vector GetAccelerationDirectionMin();
199 Vector GetAccelerationDirectionMax();
200
201 int GetSrcColor();
202 int GetDstColor();
203
204 float GetGravityWellStrength();
205 float GetRate();
206 float GetColorRate();
207
208 float GetWavyDistance();
209 float GetDieTime(float currentTime);
210 int GetBallLightningRadius();
211 float GetLightningVar();
212 int GetLightningSubdivisions();
213
214 qboolean IsWavy();
215 qboolean IsGravityWell();
216 qboolean IsParticles();
217 qboolean IsBallLightning();
218 qboolean IsSwarm();
219
220 void SetMinSpeed(float value);
221 void SetMaxSpeed(float value);
222
223 void SetAngle(float value);
224 void SetAngleVar(float value);
225
226 void SetMinAccSpeed(float value);
227 void SetMaxAccSpeed(float value);
228 void SetAccAngle(float value);
229 void SetAccAngleVar(float value);
230
231 void SetMinRate(float value);
232 void SetMaxRate(float value);
233
234 void SetSrcColor(int value);
235 void SetDstColor(int value);
236 void SetMinColorRate(float value);
237 void SetMaxColorRate(float value);
238
239 void SetWavy(int value);
240
241 void SetParticles(int value);
242 void SetGravityWell(int value);
243
244 void SetMinWavyDist(float value);
245 void SetMaxWavyDist(float value);
246
247 void SetMinLife(float value);
248 void SetMaxLife(float value);
249
250 void SetGravityWellStrength(float value);
251 void SetGravityEffectVector(Vector value);
252
253 void SetBallLightning(int value);
254 void SetMinBallLightningRadius(int value);
255 void SetMaxBallLightningRadius(int value);
256 void SetLightningVar(float value);
257 void SetLightningSubdivisions(int value);
258
259 float RandomizeRange(float minRange, float maxRange);
260 float RandomizeAngle(float minAngle, float maxAngle);
261
262 Vector CalculateDirection(float value);
263
264 void Load(char **buf_p);
265};
266
267class GhostTexture
268{
269public:
270 Container<ParticleEmitter *> m_emitterList;
271
272 int m_width;
273 int m_height;
274
275 image_t *m_image;
276 unsigned int *m_texture;
277 str m_name;
278
279 qboolean m_isburn;
280 qboolean m_isfade;
281 int m_faderate;
282 int m_burnrate;
283
284public:
285 GhostTexture();
286
287 void Update();
288 void SetTexel(int x, int y, unsigned int color);
289 void Burn();
290 void GenerateLightning(Vector p1, Vector p2, int color, float angleVar, int numSubdivisions, int maxSubdivisions);
291 Vector RotateVector(Vector v, float angle);
292 void ClipAndDrawLine(Vector p0, Vector p1, int color);
293 outcode ComputeOutCode(int x, int y, int xmin, int xmax, int ymin, int ymax);
294};
295
297{
298public:
299 Container<GhostTexture *> m_textureList;
300};
Definition container.h:85
Definition tr_ghost.h:297
Definition vector.h:61
Definition str.h:77