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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
/*
* PARSEC - Explosion Drawing Code
*
* $Author: uberlinuxguy $ - $Date: 2004/09/15 12:25:25 $
*
* Orginally written by:
* Copyright (c) Markus Hadwiger <msh@parsec.org> 1995-1999
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// C library
#include <math.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// compilation flags/debug support
#include "config.h"
#include "debug.h"
// general definitions
#include "general.h"
#include "objstruc.h"
// global externals
#include "globals.h"
// subsystem headers
#include "net_defs.h"
#include "vid_defs.h"
// drawing subsystem
#include "d_bmap.h"
#include "d_iter.h"
// mathematics header
#include "utl_math.h"
// model header
#include "utl_model.h"
// local module header
#include "g_explod.h"
// proprietary module headers
#include "con_aux.h"
#include "h_supp.h"
#include "obj_ctrl.h"
#include "part_api.h"
#include "part_def.h"
#include "part_sys.h"
#include "g_shkwav.h"
// constants ------------------------------------------------------------------
//
#define EXPLOSION_REFERENCE_Z 900.0
#define EXPLOSION_REFERENCE_Z_m 420.0
#define EXPLOSION_REFERENCE_Z_h 1380.0
#define EXPLOSION_REFERENCE_Z_v 1600.0
// draw explosion using custom draw particles ---------------------------------
//
PRIVATE
void DrawParticleBaseExplosion( const ShipObject *shippo )
{
if ( shippo->ExplosionCount == MAX_EXPLOSION_COUNT ) {
static int dfac_1 = RAND() % 7 + 3;
static int dfac_2 = RAND() % 7 + 3;
static int dfac_3 = RAND() % 7 + 3;
static int dfac_4 = RAND() % 7 + 3;
static int dfac_5 = RAND() % 7 + 3;
// alter basic attributes
float ref_z = 600;//400;//spreadfire_ref_z * 2;
int bitmap = iter_texrgba | iter_specularadd;
int color = 0;//SPREADFIRE_PARTICLE_COLOR;
int sizebound = PRT_NO_SIZEBOUND;
int lifetime = 1000; //shippo->SpreadLifeTime;
// fetch pdef
pdef_s *pdef = PDEF_explode1();
if ( pdef == NULL )
return;
// create pextinfo
pextinfo_s extinfo;
PRT_InitParticleExtInfo( &extinfo, pdef, NULL, NULL );
Vector3 dirvec;
fixed_t speed = 0;
DirVctMUL( shippo->ObjPosition, FIXED_TO_GEOMV( speed ), &dirvec );
Vertex3 object_space;
object_space.X = GEOMV_0;
object_space.Y = GEOMV_0;
object_space.Z = GEOMV_0;
Vertex3 world_space;
MtxVctMUL( shippo->ObjPosition, &object_space, &world_space );
dword owner = GetObjectOwner( shippo );
particle_s particle;
PRT_InitParticle( particle, bitmap, color, sizebound,
ref_z, &world_space, &dirvec,
lifetime, owner, &extinfo );
PRT_CreateCustomDrawParticle( particle, shippo );
//--
ref_z = 100;
object_space.X = INT_TO_GEOMV( 0 + dfac_1 );
object_space.Y = INT_TO_GEOMV( 30 - dfac_1 );
MtxVctMUL( shippo->ObjPosition, &object_space, &world_space );
PRT_InitParticle( particle, bitmap, color, sizebound,
ref_z, &world_space, &dirvec,
lifetime, owner, &extinfo );
PRT_CreateCustomDrawParticle( particle, shippo );
//--
ref_z = 80;
object_space.X = INT_TO_GEOMV( -20 + dfac_2 );
object_space.Y = INT_TO_GEOMV( 10 - dfac_2 );
MtxVctMUL( shippo->ObjPosition, &object_space, &world_space );
PRT_InitParticle( particle, bitmap, color, sizebound,
ref_z, &world_space, &dirvec,
lifetime, owner, &extinfo );
PRT_CreateCustomDrawParticle( particle, shippo );
//--
ref_z = 120;
object_space.X = INT_TO_GEOMV( 20 - dfac_3 );
object_space.Y = INT_TO_GEOMV( 0 + dfac_3 );
MtxVctMUL( shippo->ObjPosition, &object_space, &world_space );
PRT_InitParticle( particle, bitmap, color, sizebound,
ref_z, &world_space, &dirvec,
lifetime, owner, &extinfo );
PRT_CreateCustomDrawParticle( particle, shippo );
//--
ref_z = 30;
object_space.X = INT_TO_GEOMV( 30 - dfac_4 );
object_space.Y = INT_TO_GEOMV( -20 + dfac_4 );
MtxVctMUL( shippo->ObjPosition, &object_space, &world_space );
PRT_InitParticle( particle, bitmap, color, sizebound,
ref_z, &world_space, &dirvec,
lifetime, owner, &extinfo );
PRT_CreateCustomDrawParticle( particle, shippo );
//--
ref_z = 140;
object_space.X = INT_TO_GEOMV( 0 + dfac_5 );
object_space.Y = INT_TO_GEOMV( -30 + dfac_5 );
MtxVctMUL( shippo->ObjPosition, &object_space, &world_space );
PRT_InitParticle( particle, bitmap, color, sizebound,
ref_z, &world_space, &dirvec,
lifetime, owner, &extinfo );
PRT_CreateCustomDrawParticle( particle, shippo );
//--
} else {
// move particles along with the ship
if ( !AUX_DISABLE_DYING_SHIP_MOVEMENT ) {
Vector3 dirvec;
fixed_t speed = shippo->CurSpeed * CurScreenRefFrames;
DirVctMUL( shippo->ObjPosition, FIXED_TO_GEOMV( speed ), &dirvec );
PRT_TranslateCustomParticles( dirvec, shippo );
}
}
PRT_DrawCustomParticles( shippo );
}
// draw legacy explosion using bitmaps ----------------------------------------
//
PRIVATE
void DrawBitmapExplosion( const ShipObject *shippo )
{
float refz = EXPLOSION_REFERENCE_Z_h * Screen_Height / 760.0f; // FIXME
dword frameno = BM_EXPLANIMBASE + ( BM_NUMEXPLFRAMES-1 - shippo->ExplosionCount / EXPL_REF_SPEED );
Vertex3 shipt;
FetchTVector( shippo->CurrentXmatrx, &shipt );
SPoint shiploc;
PROJECT_TO_SCREEN( shipt, shiploc );
float scalefac = refz / GEOMV_TO_FLOAT( shipt.Z );
dword scalewidth = (dword) ( BitmapInfo[ frameno ].width * scalefac );
dword scaleheight = (dword) ( BitmapInfo[ frameno ].height * scalefac );
scalewidth &= ~1;
scaleheight &= ~1;
D_PutSTCBitmap( BitmapInfo[ frameno ].bitmappointer,
BitmapInfo[ frameno ].width,
BitmapInfo[ frameno ].height,
scalewidth, scaleheight,
shiploc.X - scalewidth/2,
shiploc.Y - scaleheight/2 );
// draw secondary explosion bitmaps
if ( !AUX_USE_SIMPLE_EXPLOSION ) {
static int dfac_1 = 1;
static int dfac_2 = 1;
static int dfac_3 = 1;
static int dfac_4 = 1;
static int dfac_5 = 1;
if ( shippo->ExplosionCount == MAX_EXPLOSION_COUNT ) {
dfac_1 = RAND() % 7 + 3;
dfac_2 = RAND() % 7 + 3;
dfac_3 = RAND() % 7 + 3;
dfac_4 = RAND() % 7 + 3;
dfac_5 = RAND() % 7 + 3;
}
dword _scalewidth = scalewidth / 2;
dword _scaleheight = scaleheight / 2;
if ( scalewidth > 0 && scaleheight > 0 )
D_PutSTCBitmap( BitmapInfo[ frameno ].bitmappointer,
BitmapInfo[ frameno ].width,
BitmapInfo[ frameno ].height,
_scalewidth, _scaleheight,
shiploc.X - _scalewidth/2 - _scalewidth/dfac_1,
shiploc.Y - _scaleheight/2 - _scaleheight/dfac_2 );
if ( scalewidth > 0 && scaleheight > 0 )
D_PutSTCBitmap( BitmapInfo[ frameno ].bitmappointer,
BitmapInfo[ frameno ].width,
BitmapInfo[ frameno ].height,
_scalewidth, _scaleheight,
shiploc.X - _scalewidth/2 + _scalewidth/dfac_3,
shiploc.Y - _scaleheight/2 + _scaleheight/dfac_4 );
_scalewidth = scalewidth / 3;
_scaleheight = scaleheight / 3;
if ( scalewidth > 0 && scaleheight > 0 )
D_PutSTCBitmap( BitmapInfo[ frameno ].bitmappointer,
BitmapInfo[ frameno ].width,
BitmapInfo[ frameno ].height,
_scalewidth, _scaleheight,
shiploc.X - _scalewidth/2 + _scalewidth/dfac_2,
shiploc.Y - _scaleheight/2 - _scaleheight/dfac_5 );
_scalewidth = scalewidth / 4;
_scaleheight = scaleheight / 4;
if ( scalewidth > 0 && scaleheight > 0 )
D_PutSTCBitmap( BitmapInfo[ frameno ].bitmappointer,
BitmapInfo[ frameno ].width,
BitmapInfo[ frameno ].height,
_scalewidth, _scaleheight,
shiploc.X - _scalewidth/2 + _scalewidth/dfac_3,
shiploc.Y - _scaleheight/2 + _scaleheight/dfac_1 );
_scalewidth = scalewidth / 5;
_scaleheight = scaleheight / 5;
if ( scalewidth > 0 && scaleheight > 0 )
D_PutSTCBitmap( BitmapInfo[ frameno ].bitmappointer,
BitmapInfo[ frameno ].width,
BitmapInfo[ frameno ].height,
_scalewidth, _scaleheight,
shiploc.X - _scalewidth/2 + _scalewidth/dfac_5,
shiploc.Y - _scaleheight/2 + _scaleheight/dfac_4 );
}
}
// draw single frame of explosion animation -----------------------------------
//
void DrawExpAnim( const ShipObject *shippo )
{
ASSERT( shippo != NULL );
// create shock wave if enabled (on first frame)
if ( AUX_EXPLOSION_DRAW_SHOCKWAVE ) {
ExplosionShockWave( shippo );
}
// draw explosion
if ( AUX_PARTICLE_BASE_EXPLOSION ) {
// anim frames are particles
DrawParticleBaseExplosion( shippo );
} else {
// anim frames are bitmaps
DrawBitmapExplosion( shippo );
}
}
|