Colobot
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Pages
src
graphics
engine
particle.h
Go to the documentation of this file.
1
// * This file is part of the COLOBOT source code
2
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
3
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
4
// *
5
// * This program is free software: you can redistribute it and/or modify
6
// * it under the terms of the GNU General Public License as published by
7
// * the Free Software Foundation, either version 3 of the License, or
8
// * (at your option) any later version.
9
// *
10
// * This program is distributed in the hope that it will be useful,
11
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// * GNU General Public License for more details.
14
// *
15
// * You should have received a copy of the GNU General Public License
16
// * along with this program. If not, see http://www.gnu.org/licenses/.
17
23
#pragma once
24
25
26
#include "
graphics/engine/engine.h
"
27
28
#include "
sound/sound.h
"
29
30
31
class
CRobotMain
;
32
class
CObject
;
33
class
CSoundInterface
;
34
35
36
// Graphics module namespace
37
namespace
Gfx {
38
39
const
short
MAXPARTICULE = 500;
40
const
short
MAXPARTITYPE = 5;
41
const
short
MAXTRACK = 100;
42
const
short
MAXTRACKLEN = 10;
43
const
short
MAXPARTIFOG = 100;
44
const
short
MAXWHEELTRACE = 1000;
45
46
const
short
SH_WORLD = 0;
// particle in the world in the interface
47
const
short
SH_FRONT = 1;
// particle in the world on the interface
48
const
short
SH_INTERFACE = 2;
// particle in the interface
49
const
short
SH_MAX = 3;
50
51
// type == 0 -> triangles
52
// type == 1 -> effect00 (black background)
53
// type == 2 -> effect01 (black background)
54
// type == 3 -> effect02 (black background)
55
// type == 4 -> text (white background)
56
57
58
enum
ParticleType
59
{
60
PARTIEXPLOT = 1,
61
PARTIEXPLOO
= 2,
62
PARTIMOTOR
= 3,
63
PARTIGLINT
= 4,
64
PARTIBLITZ
= 5,
65
PARTICRASH
= 6,
66
PARTIGAS
= 7,
67
PARTIFIRE
= 9,
68
PARTIFIREZ
= 10,
69
PARTIBLUE
= 11,
70
PARTISELY
= 12,
71
PARTISELR
= 13,
72
PARTIGUN1
= 18,
73
PARTIGUN2
= 19,
74
PARTIGUN3
= 20,
75
PARTIGUN4
= 21,
76
PARTIFRAG
= 22,
77
PARTIQUEUE
= 23,
78
PARTIORGANIC1
= 24,
79
PARTIORGANIC2
= 25,
80
PARTISMOKE1
= 26,
81
PARTISMOKE2
= 27,
82
PARTISMOKE3
= 28,
83
PARTISMOKE4
= 29,
84
PARTIBLOOD
= 30,
85
PARTIBLOODM
= 31,
86
PARTIVAPOR
= 32,
87
PARTIVIRUS1
= 33,
88
PARTIVIRUS2
= 34,
89
PARTIVIRUS3
= 35,
90
PARTIVIRUS4
= 36,
91
PARTIVIRUS5
= 37,
92
PARTIVIRUS6
= 38,
93
PARTIVIRUS7
= 39,
94
PARTIVIRUS8
= 40,
95
PARTIVIRUS9
= 41,
96
PARTIVIRUS10
= 42,
97
PARTIRAY1
= 43,
98
PARTIRAY2
= 44,
99
PARTIRAY3
= 45,
100
PARTIRAY4
= 46,
101
PARTIFLAME
= 47,
102
PARTIBUBBLE
= 48,
103
PARTIFLIC
= 49,
104
PARTIEJECT
= 50,
105
PARTISCRAPS
= 51,
106
PARTITOTO
= 52,
107
PARTIERROR
= 53,
108
PARTIWARNING
= 54,
109
PARTIINFO
= 54,
110
PARTIQUARTZ
= 55,
111
PARTISPHERE0
= 56,
112
PARTISPHERE1
= 57,
113
PARTISPHERE2
= 58,
114
PARTISPHERE3
= 59,
115
PARTISPHERE4
= 60,
116
PARTISPHERE5
= 61,
117
PARTISPHERE6
= 62,
118
PARTISPHERE7
= 63,
119
PARTISPHERE8
= 64,
120
PARTISPHERE9
= 65,
121
PARTIGUNDEL
= 66,
122
PARTIPART
= 67,
123
PARTITRACK1
= 68,
124
PARTITRACK2
= 69,
125
PARTITRACK3
= 70,
126
PARTITRACK4
= 71,
127
PARTITRACK5
= 72,
128
PARTITRACK6
= 73,
129
PARTITRACK7
= 74,
130
PARTITRACK8
= 75,
131
PARTITRACK9
= 76,
132
PARTITRACK10
= 77,
133
PARTITRACK11
= 78,
134
PARTITRACK12
= 79,
135
PARTITRACK13
= 80,
136
PARTITRACK14
= 81,
137
PARTITRACK15
= 82,
138
PARTITRACK16
= 83,
139
PARTITRACK17
= 84,
140
PARTITRACK18
= 85,
141
PARTITRACK19
= 86,
142
PARTITRACK20
= 87,
143
PARTIGLINTb
= 88,
144
PARTIGLINTr
= 89,
145
PARTILENS1
= 90,
146
PARTILENS2
= 91,
147
PARTILENS3
= 92,
148
PARTILENS4
= 93,
149
PARTICONTROL
= 94,
150
PARTISHOW
= 95,
151
PARTICHOC
= 96,
152
PARTIGFLAT
= 97,
153
PARTIRECOVER
= 98,
154
PARTIROOT
= 100,
155
PARTIPLOUF0
= 101,
156
PARTIPLOUF1
= 102,
157
PARTIPLOUF2
= 103,
158
PARTIPLOUF3
= 104,
159
PARTIPLOUF4
= 105,
160
PARTIDROP
= 106,
161
PARTIFOG0
= 107,
162
PARTIFOG1
= 108,
163
PARTIFOG2
= 109,
164
PARTIFOG3
= 110,
165
PARTIFOG4
= 111,
166
PARTIFOG5
= 112,
167
PARTIFOG6
= 113,
168
PARTIFOG7
= 114,
169
PARTIFOG8
= 115,
170
PARTIFOG9
= 116,
171
PARTILIMIT1
= 117,
172
PARTILIMIT2
= 118,
173
PARTILIMIT3
= 119,
174
PARTILIMIT4
= 120,
175
PARTIWATER
= 121,
176
PARTIEXPLOG1
= 122,
177
PARTIEXPLOG2
= 123,
178
PARTIBASE
= 124,
179
PARTITRACE0
= 140,
180
PARTITRACE1
= 141,
181
PARTITRACE2
= 142,
182
PARTITRACE3
= 143,
183
PARTITRACE4
= 144,
184
PARTITRACE5
= 145,
185
PARTITRACE6
= 146,
186
PARTITRACE7
= 147,
187
PARTITRACE8
= 148,
188
PARTITRACE9
= 149,
189
PARTITRACE10
= 150,
190
PARTITRACE11
= 151,
191
PARTITRACE12
= 152,
192
PARTITRACE13
= 153,
193
PARTITRACE14
= 154,
194
PARTITRACE15
= 155,
195
PARTITRACE16
= 156,
196
PARTITRACE17
= 157,
197
PARTITRACE18
= 158,
198
PARTITRACE19
= 159,
199
};
200
201
enum
ParticlePhase
202
{
203
PARPHSTART = 0,
204
PARPHEND = 1,
205
};
206
207
struct
Particle
208
{
209
char
used;
// TRUE -> particle used
210
char
ray;
// TRUE -> ray with goal
211
unsigned
short
uniqueStamp;
// unique mark
212
short
sheet;
// sheet (0..n)
213
ParticleType
type;
// type PARTI*
214
ParticlePhase phase;
// phase PARPH*
215
float
mass;
// mass of the particle (in rebounding)
216
float
weight;
// weight of the particle (for noise)
217
float
duration;
// length of life
218
Math::Vector
pos;
// absolute position (relative if object links)
219
Math::Vector
goal;
// goal position (if ray)
220
Math::Vector
speed;
// speed of displacement
221
float
windSensitivity;
222
short
bounce;
// number of rebounds
223
Math::Point
dim;
// dimensions of the rectangle
224
float
zoom;
// zoom (0..1)
225
float
angle;
// angle of rotation
226
float
intensity;
// intensity
227
Math::Point
texSup;
// coordinated upper texture
228
Math::Point
texInf;
// coordinated lower texture
229
float
time;
// age of the particle (0..n)
230
float
phaseTime;
// age at the beginning of phase
231
float
testTime;
// time since last test
232
CObject
* objLink;
// father object (for example reactor)
233
CObject
* objFather;
// father object (for example reactor)
234
short
objRank;
// rank of the object, or -1
235
short
trackRank;
// rank of the drag
236
};
237
238
struct
Track
239
{
240
char
used;
// TRUE -> drag used
241
char
drawParticle;
242
float
step;
// duration of not
243
float
last;
// increase last not memorized
244
float
intensity;
// intensity at starting (0..1)
245
float
width;
// tail width
246
int
posUsed;
// number of positions in "pos"
247
int
head;
// head to write index
248
Math::Vector
pos[MAXTRACKLEN];
249
float
len[MAXTRACKLEN];
250
};
251
252
struct
WheelTrace
253
{
254
ParticleType
type;
// type PARTI*
255
Math::Vector
pos[4];
// rectangle positions
256
float
startTime;
// beginning of life
257
};
258
259
266
class
CParticle
267
{
268
public
:
269
CParticle
(
CEngine
* engine);
270
~
CParticle
();
271
273
void
SetDevice
(
CDevice
* device);
274
276
void
FlushParticle
();
277
279
void
FlushParticle
(
int
sheet);
280
282
int
CreateParticle
(
Math::Vector
pos,
Math::Vector
speed,
Math::Point
dim,
283
ParticleType
type,
float
duration = 1.0f,
float
mass = 0.0f,
284
float
windSensitivity = 1.0f,
int
sheet = 0);
285
287
int
CreateFrag
(
Math::Vector
pos,
Math::Vector
speed,
EngineTriangle
* triangle,
288
ParticleType
type,
float
duration = 1.0f,
float
mass = 0.0f,
289
float
windSensitivity = 1.0f,
int
sheet = 0);
290
292
int
CreatePart
(
Math::Vector
pos,
Math::Vector
speed,
ParticleType
type,
293
float
duration = 1.0f,
float
mass = 0.0f,
float
weight = 0.0f,
294
float
windSensitivity = 1.0f,
int
sheet = 0);
295
297
int
CreateRay
(
Math::Vector
pos,
Math::Vector
goal,
ParticleType
type,
Math::Point
dim,
298
float
duration = 1.0f,
int
sheet = 0);
299
301
int
CreateTrack
(
Math::Vector
pos,
Math::Vector
speed,
Math::Point
dim,
ParticleType
type,
302
float
duration = 1.0f,
float
mass = 0.0f,
float
length = 10.0f,
float
width = 1.0f);
303
305
void
CreateWheelTrace
(
const
Math::Vector
&p1,
const
Math::Vector
&p2,
const
Math::Vector
&p3,
306
const
Math::Vector
&p4,
ParticleType
type);
307
309
void
DeleteParticle
(
ParticleType
type);
311
void
DeleteParticle
(
int
channel);
313
void
SetObjectLink
(
int
channel,
CObject
*
object
);
315
void
SetObjectFather
(
int
channel,
CObject
*
object
);
316
void
SetPosition(
int
channel,
Math::Vector
pos);
317
void
SetDimension(
int
channel,
Math::Point
dim);
318
void
SetZoom(
int
channel,
float
zoom);
319
void
SetAngle(
int
channel,
float
angle);
320
void
SetIntensity(
int
channel,
float
intensity);
321
void
SetParam(
int
channel,
Math::Vector
pos,
Math::Point
dim,
float
zoom,
float
angle,
float
intensity);
322
void
SetPhase(
int
channel, ParticlePhase phase,
float
duration);
323
325
bool
GetPosition
(
int
channel,
Math::Vector
&pos);
326
328
Color
GetFogColor
(
Math::Vector
pos);
329
331
void
SetFrameUpdate
(
int
sheet,
bool
update);
333
void
FrameParticle
(
float
rTime);
335
void
DrawParticle
(
int
sheet);
336
338
bool
WriteWheelTrace
(
const
char
*filename,
int
width,
int
height,
Math::Vector
dl,
Math::Vector
ur);
339
340
protected
:
342
void
DeleteRank
(
int
rank);
344
bool
CheckChannel
(
int
&channel);
346
void
DrawParticleTriangle
(
int
i);
348
void
DrawParticleNorm
(
int
i);
350
void
DrawParticleFlat
(
int
i);
352
void
DrawParticleFog
(
int
i);
354
void
DrawParticleRay
(
int
i);
356
void
DrawParticleSphere
(
int
i);
358
void
DrawParticleCylinder
(
int
i);
360
void
DrawParticleWheel
(
int
i);
362
CObject
*
SearchObjectGun
(
Math::Vector
old,
Math::Vector
pos,
ParticleType
type,
CObject
*father);
364
CObject
*
SearchObjectRay
(
Math::Vector
pos,
Math::Vector
goal,
ParticleType
type,
CObject
*father);
366
void
Play
(
Sound
sound,
Math::Vector
pos,
float
amplitude);
368
bool
TrackMove
(
int
i,
Math::Vector
pos,
float
progress);
370
void
TrackDraw
(
int
i,
ParticleType
type);
371
372
protected
:
373
CEngine
* m_engine;
374
CDevice
* m_device;
375
CTerrain
* m_terrain;
376
CWater
* m_water;
377
CRobotMain
* m_main;
378
CSoundInterface
* m_sound;
379
380
Particle
m_particle[MAXPARTICULE*MAXPARTITYPE];
381
EngineTriangle
m_triangle[MAXPARTICULE];
// triangle if PartiType == 0
382
Track
m_track[MAXTRACK];
383
int
m_wheelTraceTotal;
384
int
m_wheelTraceIndex;
385
WheelTrace
m_wheelTrace[MAXWHEELTRACE];
386
int
m_totalInterface[MAXPARTITYPE][SH_MAX];
387
bool
m_frameUpdate[SH_MAX];
388
int
m_fogTotal;
389
int
m_fog[MAXPARTIFOG];
390
int
m_uniqueStamp;
391
int
m_exploGunCounter;
392
float
m_lastTimeGunDel;
393
float
m_absTime;
394
};
395
396
397
}
// namespace Gfx
398
Generated on Sat Jul 5 2014 09:25:03 for Colobot by
1.8.1.2