1 /*
2 * Decals.cpp
3 * Copyright (C) 2007 by Bryan Duff <duff0097@gmail.com>
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 2 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, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 * USA
19 */
20 #include "Decals.h"
21
22 extern double multiplier;
23 //Functions
24 extern Model gunmodels[10];
25
MakeDecal(int atype,XYZ location,float size,XYZ normal,int poly,Model * model,XYZ move,float rotation)26 int Decals::MakeDecal(int atype, XYZ location, float size, XYZ normal, int poly,
27 Model * model, XYZ move, float rotation)
28 {
29 int major = 0;
30 float normalv[3];
31 XYZ right;
32 XYZ up;
33 XYZ nothing;
34 XYZ axis[3];
35 XYZ temp;
36
37 nothing = 0;
38
39 axis[0].x = 1;
40 axis[1].y = 1;
41 axis[2].z = 1;
42
43 normalv[0] = abs(normal.x);
44 normalv[1] = abs(normal.y);
45 normalv[2] = abs(normal.z);
46
47
48 if(normalv[1] > normalv[major])
49 major = 1;
50 if(normalv[2] > normalv[major])
51 major = 2;
52
53 if(normalv[0] == 1 || normalv[1] == 1 || normalv[2] == 1) {
54 if((major == 0 && normal.x > 0) || major == 1) {
55 right = 0;
56 right.z = -1;
57 } else if(major == 0) {
58 right = 0;
59 right.z = 1;
60 } else {
61 right = 0;
62 right.x = normal.z;
63 }
64 } else
65 CrossProduct(axis[major], normal, &right);
66
67 CrossProduct(normal, right, &up);
68 Normalise(&up);
69 Normalise(&right);
70
71 float count;
72 float count2;
73 float countinc = 1 / size;
74 if(countinc < .01)
75 countinc = .01;
76 if(countinc > .2)
77 countinc = .2;
78 float normaloffset = .02;
79 int good;
80
81 numpoints[howmanydecals] = 0;
82 points[howmanydecals * 8 + numpoints[howmanydecals]] =
83 location + (nothing - right - up) * (size / 3) /*+ normal/100 */ ;
84 texcoordsx[howmanydecals * 8 + numpoints[howmanydecals]] = 0;
85 texcoordsy[howmanydecals * 8 + numpoints[howmanydecals]] = 0;
86 if((move.x == 0 && move.z == 0 && rotation == 0) ||
87 LineFacetd(points[howmanydecals * 8 + numpoints[howmanydecals]] +
88 normal / 25,
89 points[howmanydecals * 8 + numpoints[howmanydecals]] -
90 normal / 25, model->vertex[model->Triangles[poly].vertex[0]],
91 model->vertex[model->Triangles[poly].vertex[1]],
92 model->vertex[model->Triangles[poly].vertex[2]], normal, &temp)
93 )
94 numpoints[howmanydecals]++;
95 else {
96 good = -1;
97 count = 1 - countinc;
98 while(good == -1 && count > -1) {
99 texcoordsx[howmanydecals * 8 + numpoints[howmanydecals]] = 0;
100 texcoordsy[howmanydecals * 8 + numpoints[howmanydecals]] = .5 - count / 2;
101 points[howmanydecals * 8 + numpoints[howmanydecals]] =
102 location + (nothing - right - up * count) * (size / 3);
103 count -= countinc;
104 good =
105 model->
106 LineCheck2(points[howmanydecals * 8 + numpoints[howmanydecals]] +
107 normal / 25,
108 points[howmanydecals * 8 + numpoints[howmanydecals]] -
109 normal / 25, &temp, move, rotation);
110 }
111 if(good != -1)
112 numpoints[howmanydecals]++;
113 good = -1;
114 count = 1 - countinc;
115 while(good == -1 && count > -1) {
116 texcoordsx[howmanydecals * 8 + numpoints[howmanydecals]] = .5 - count / 2;
117 texcoordsy[howmanydecals * 8 + numpoints[howmanydecals]] = 0;
118 points[howmanydecals * 8 + numpoints[howmanydecals]] =
119 location + (nothing - right * count - up) * (size / 3);
120 count -= countinc;
121 good =
122 model->
123 LineCheck2(points[howmanydecals * 8 + numpoints[howmanydecals]] +
124 normal / 25,
125 points[howmanydecals * 8 + numpoints[howmanydecals]] -
126 normal / 25, &temp, move, rotation);
127 }
128 if(good != -1)
129 numpoints[howmanydecals]++;
130 if(good == -1) {
131 good = -1;
132 count2 = 1 - countinc;
133 while(good == -1 && count2 > -1) {
134 count = 1 - countinc;
135 while(good == -1 && count > -1) {
136 texcoordsx[howmanydecals * 8 + numpoints[howmanydecals]] =
137 .5 - count2 / 2;
138 texcoordsy[howmanydecals * 8 + numpoints[howmanydecals]] =
139 .5 - count / 2;
140 points[howmanydecals * 8 + numpoints[howmanydecals]] =
141 location + (nothing - right * count2 - up * count) * (size / 3);
142 count -= countinc;
143 good =
144 model->
145 LineCheck2(points[howmanydecals * 8 + numpoints[howmanydecals]] +
146 normal / 25,
147 points[howmanydecals * 8 + numpoints[howmanydecals]] -
148 normal / 25, &temp, move, rotation);
149 }
150 count2 -= countinc;
151 }
152 if(good != -1)
153 numpoints[howmanydecals]++;
154 }
155 }
156
157 points[howmanydecals * 8 + numpoints[howmanydecals]] =
158 location + (nothing + right - up) * (size / 3) /*+ normal/100 */ ;
159 texcoordsx[howmanydecals * 8 + numpoints[howmanydecals]] = 1;
160 texcoordsy[howmanydecals * 8 + numpoints[howmanydecals]] = 0;
161 if((move.x == 0 && move.y == 0 && move.z == 0 && rotation == 0) ||
162 LineFacetd(points[howmanydecals * 8 + numpoints[howmanydecals]] +
163 normal / 25,
164 points[howmanydecals * 8 + numpoints[howmanydecals]] -
165 normal / 25, model->vertex[model->Triangles[poly].vertex[0]],
166 model->vertex[model->Triangles[poly].vertex[1]],
167 model->vertex[model->Triangles[poly].vertex[2]], normal, &temp)
168 )
169 numpoints[howmanydecals]++;
170 else {
171 good = -1;
172 count = 1 - countinc;
173 while(good == -1 && count > -1) {
174 texcoordsx[howmanydecals * 8 + numpoints[howmanydecals]] = .5 + count / 2;
175 texcoordsy[howmanydecals * 8 + numpoints[howmanydecals]] = 0;
176 points[howmanydecals * 8 + numpoints[howmanydecals]] =
177 location + (nothing + right * count - up) * (size / 3);
178 count -= countinc;
179 good =
180 model->
181 LineCheck2(points[howmanydecals * 8 + numpoints[howmanydecals]] +
182 normal / 25,
183 points[howmanydecals * 8 + numpoints[howmanydecals]] -
184 normal / 25, &temp, move, rotation);
185 }
186 if(good != -1)
187 numpoints[howmanydecals]++;
188 good = -1;
189 count = 1 - countinc;
190 while(good == -1 && count > -1) {
191 texcoordsx[howmanydecals * 8 + numpoints[howmanydecals]] = 1;
192 texcoordsy[howmanydecals * 8 + numpoints[howmanydecals]] = .5 - count / 2;
193 points[howmanydecals * 8 + numpoints[howmanydecals]] =
194 location + (nothing + right - up * count) * (size / 3);
195 count -= countinc;
196 good =
197 model->
198 LineCheck2(points[howmanydecals * 8 + numpoints[howmanydecals]] +
199 normal / 25,
200 points[howmanydecals * 8 + numpoints[howmanydecals]] -
201 normal / 25, &temp, move, rotation);
202 }
203 if(good != -1)
204 numpoints[howmanydecals]++;
205 if(good == -1) {
206 good = -1;
207 count2 = 1 - countinc;
208 while(good == -1 && count2 > -1) {
209 count = 1 - countinc;
210 while(good == -1 && count > -1) {
211 texcoordsx[howmanydecals * 8 + numpoints[howmanydecals]] =
212 .5 + count2 / 2;
213 texcoordsy[howmanydecals * 8 + numpoints[howmanydecals]] =
214 .5 - count / 2;
215 points[howmanydecals * 8 + numpoints[howmanydecals]] =
216 location + (nothing + right * count2 - up * count) * (size / 3);
217 count -= countinc;
218 good =
219 model->
220 LineCheck2(points[howmanydecals * 8 + numpoints[howmanydecals]] +
221 normal / 25,
222 points[howmanydecals * 8 + numpoints[howmanydecals]] -
223 normal / 25, &temp, move, rotation);
224 }
225 count2 -= countinc;
226 }
227 if(good != -1)
228 numpoints[howmanydecals]++;
229 }
230 }
231
232 points[howmanydecals * 8 + numpoints[howmanydecals]] =
233 location + (nothing + right + up) * (size / 3) /*+ normal/100 */ ;
234 texcoordsx[howmanydecals * 8 + numpoints[howmanydecals]] = 1;
235 texcoordsy[howmanydecals * 8 + numpoints[howmanydecals]] = 1;
236 if((move.x == 0 && move.y == 0 && move.z == 0 && rotation == 0) ||
237 LineFacetd(points[howmanydecals * 8 + numpoints[howmanydecals]] +
238 normal / 25,
239 points[howmanydecals * 8 + numpoints[howmanydecals]] -
240 normal / 25, model->vertex[model->Triangles[poly].vertex[0]],
241 model->vertex[model->Triangles[poly].vertex[1]],
242 model->vertex[model->Triangles[poly].vertex[2]], normal, &temp)
243 )
244 numpoints[howmanydecals]++;
245 else {
246 good = -1;
247 count = 1 - countinc;
248 while(good == -1 && count > -1) {
249 texcoordsx[howmanydecals * 8 + numpoints[howmanydecals]] = 1;
250 texcoordsy[howmanydecals * 8 + numpoints[howmanydecals]] = .5 + count / 2;
251 points[howmanydecals * 8 + numpoints[howmanydecals]] =
252 location + (nothing + right + up * count) * (size / 3);
253 count -= countinc;
254 good =
255 model->
256 LineCheck2(points[howmanydecals * 8 + numpoints[howmanydecals]] +
257 normal / 25,
258 points[howmanydecals * 8 + numpoints[howmanydecals]] -
259 normal / 25, &temp, move, rotation);
260 }
261 if(good != -1)
262 numpoints[howmanydecals]++;
263 good = -1;
264 count = 1 - countinc;
265 while(good == -1 && count > -1) {
266 texcoordsx[howmanydecals * 8 + numpoints[howmanydecals]] = .5 + count / 2;
267 texcoordsy[howmanydecals * 8 + numpoints[howmanydecals]] = 1;
268 points[howmanydecals * 8 + numpoints[howmanydecals]] =
269 location + (nothing + right * count + up) * (size / 3);
270 count -= countinc;
271 good =
272 model->
273 LineCheck2(points[howmanydecals * 8 + numpoints[howmanydecals]] +
274 normal / 25,
275 points[howmanydecals * 8 + numpoints[howmanydecals]] -
276 normal / 25, &temp, move, rotation);
277 }
278 if(good != -1)
279 numpoints[howmanydecals]++;
280 if(good == -1) {
281 good = -1;
282 count2 = 1 - countinc;
283 while(good == -1 && count2 > -1) {
284 count = 1 - countinc;
285 while(good == -1 && count > -1) {
286 texcoordsx[howmanydecals * 8 + numpoints[howmanydecals]] =
287 .5 + count2 / 2;
288 texcoordsy[howmanydecals * 8 + numpoints[howmanydecals]] =
289 .5 + count / 2;
290 points[howmanydecals * 8 + numpoints[howmanydecals]] =
291 location + (nothing + right * count2 + up * count) * (size / 3);
292 count -= countinc;
293 good =
294 model->
295 LineCheck2(points[howmanydecals * 8 + numpoints[howmanydecals]] +
296 normal / 25,
297 points[howmanydecals * 8 + numpoints[howmanydecals]] -
298 normal / 25, &temp, move, rotation);
299 }
300 count2 -= countinc;
301 }
302 if(good != -1)
303 numpoints[howmanydecals]++;
304 }
305 }
306
307 points[howmanydecals * 8 + numpoints[howmanydecals]] =
308 location + (nothing - right + up) * (size / 3) /*+ normal/100 */ ;
309 texcoordsx[howmanydecals * 8 + numpoints[howmanydecals]] = 0;
310 texcoordsy[howmanydecals * 8 + numpoints[howmanydecals]] = 1;
311 if((move.x == 0 && move.y == 0 && move.z == 0 && rotation == 0) ||
312 LineFacetd(points[howmanydecals * 8 + numpoints[howmanydecals]] +
313 normal / 25,
314 points[howmanydecals * 8 + numpoints[howmanydecals]] -
315 normal / 25, model->vertex[model->Triangles[poly].vertex[0]],
316 model->vertex[model->Triangles[poly].vertex[1]],
317 model->vertex[model->Triangles[poly].vertex[2]], normal, &temp)
318 )
319 numpoints[howmanydecals]++;
320 else {
321 good = -1;
322 count = 1 - countinc;
323 while(good == -1 && count > -1) {
324 texcoordsx[howmanydecals * 8 + numpoints[howmanydecals]] = .5 - count / 2;
325 texcoordsy[howmanydecals * 8 + numpoints[howmanydecals]] = 1;
326 points[howmanydecals * 8 + numpoints[howmanydecals]] =
327 location + (nothing - right * count + up) * (size / 3);
328 count -= countinc;
329 good =
330 model->
331 LineCheck2(points[howmanydecals * 8 + numpoints[howmanydecals]] +
332 normal / 25,
333 points[howmanydecals * 8 + numpoints[howmanydecals]] -
334 normal / 25, &temp, move, rotation);
335 }
336 if(good != -1)
337 numpoints[howmanydecals]++;
338 good = -1;
339 count = 1 - countinc;
340 while(good == -1 && count > -1) {
341 texcoordsx[howmanydecals * 8 + numpoints[howmanydecals]] = 0;
342 texcoordsy[howmanydecals * 8 + numpoints[howmanydecals]] = .5 + count / 2;
343 points[howmanydecals * 8 + numpoints[howmanydecals]] =
344 location + (nothing - right + up * count) * (size / 3);
345 count -= countinc;
346 good =
347 model->
348 LineCheck2(points[howmanydecals * 8 + numpoints[howmanydecals]] +
349 normal / 25,
350 points[howmanydecals * 8 + numpoints[howmanydecals]] -
351 normal / 25, &temp, move, rotation);
352 }
353 if(good != -1)
354 numpoints[howmanydecals]++;
355 if(good == -1) {
356 good = -1;
357 count2 = 1 - countinc;
358 while(good == -1 && count2 > -1) {
359 count = 1 - countinc;
360 while(good == -1 && count > -1) {
361 texcoordsx[howmanydecals * 8 + numpoints[howmanydecals]] =
362 .5 - count2 / 2;
363 texcoordsy[howmanydecals * 8 + numpoints[howmanydecals]] =
364 .5 + count / 2;
365 points[howmanydecals * 8 + numpoints[howmanydecals]] =
366 location + (nothing - right * count2 + up * count) * (size / 3);
367 count -= countinc;
368 good =
369 model->
370 LineCheck2(points[howmanydecals * 8 + numpoints[howmanydecals]] +
371 normal / 25,
372 points[howmanydecals * 8 + numpoints[howmanydecals]] -
373 normal / 25, &temp, move, rotation);
374 }
375 count2 -= countinc;
376 }
377 if(good != -1)
378 numpoints[howmanydecals]++;
379 }
380 }
381 for(int i = 0; i < numpoints[howmanydecals]; i++) {
382 points[howmanydecals * 8 + i] += normal * normaloffset;
383 }
384
385 type[howmanydecals] = atype;
386 alivetime[howmanydecals] = 0;
387 if(howmanydecals < maxdecals) {
388 howmanydecals++;
389 }
390
391 return 0;
392 }
393
DeleteDecal(int which)394 int Decals::DeleteDecal(int which)
395 {
396 if(which >= 0) {
397 numpoints[which] = numpoints[howmanydecals - 1];
398 alivetime[which] = alivetime[howmanydecals - 1];
399 type[which] = type[howmanydecals - 1];
400 for(int i = 0; i < numpoints[which]; i++) {
401 points[which * 8 + i] = points[howmanydecals * 8 - 8 + i];
402 texcoordsx[which * 8 + i] = texcoordsx[howmanydecals * 8 - 8 + i];
403 texcoordsy[which * 8 + i] = texcoordsy[howmanydecals * 8 - 8 + i];
404 }
405 if(howmanydecals > 0) {
406 howmanydecals--;
407 }
408 }
409
410 return 0;
411 }
412
LoadBulletHoleTexture(char * fileName)413 void Decals::LoadBulletHoleTexture(char *fileName)
414 {
415 TGAImageRec *tempTexture;
416 GLuint type;
417
418 //Load Image
419 tempTexture = LoadTGA(fileName);
420 //Is it valid?
421 if(tempTexture) {
422 //Alpha channel?
423 if(tempTexture->bpp == 24)
424 type = GL_RGB;
425 else
426 type = GL_RGBA;
427
428 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
429
430 glGenTextures(1, &bulletholetextureptr);
431 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
432
433 glBindTexture(GL_TEXTURE_2D, bulletholetextureptr);
434 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
435 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
436
437 gluBuild2DMipmaps(GL_TEXTURE_2D, type, tempTexture->sizeX,
438 tempTexture->sizeY, type, GL_UNSIGNED_BYTE,
439 tempTexture->data);
440 free(tempTexture->data);
441 free(tempTexture);
442 }
443 }
444
LoadBloodTexture(char * fileName,int which)445 void Decals::LoadBloodTexture(char *fileName, int which)
446 {
447 TGAImageRec *tempTexture;
448 GLuint type;
449
450 //Load Image
451 tempTexture = LoadTGA(fileName);
452 //Is it valid?
453 if(tempTexture) {
454 //Alpha channel?
455 if(tempTexture->bpp == 24)
456 type = GL_RGB;
457 else
458 type = GL_RGBA;
459
460 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
461
462 glGenTextures(1, &bloodtextureptr[which]);
463 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
464
465 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[which]);
466 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
467 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
468
469 gluBuild2DMipmaps(GL_TEXTURE_2D, type, tempTexture->sizeX,
470 tempTexture->sizeY, type, GL_UNSIGNED_BYTE,
471 tempTexture->data);
472 free(tempTexture->data);
473 free(tempTexture);
474 }
475 }
476
LoadCraterTexture(char * fileName)477 void Decals::LoadCraterTexture(char *fileName)
478 {
479 TGAImageRec *tempTexture;
480 GLuint type;
481
482 //Load Image
483 tempTexture = LoadTGA(fileName);
484 //Is it valid?
485 if(tempTexture) {
486 //Alpha channel?
487 if(tempTexture->bpp == 24)
488 type = GL_RGB;
489 else
490 type = GL_RGBA;
491
492 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
493
494 glGenTextures(1, &cratertextureptr);
495 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
496
497 glBindTexture(GL_TEXTURE_2D, cratertextureptr);
498 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
499 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
500
501 gluBuild2DMipmaps(GL_TEXTURE_2D, type, tempTexture->sizeX,
502 tempTexture->sizeY, type, GL_UNSIGNED_BYTE,
503 tempTexture->data);
504 free(tempTexture->data);
505 free(tempTexture);
506 }
507 }
508
DoStuff()509 void Decals::DoStuff()
510 {
511 for(int i = 0; i < howmanydecals; i++) {
512 alivetime[i] += multiplier;
513 if(alivetime[i] > 10 && (type[i] == bullethole || type[i] == crater))
514 DeleteDecal(i);
515 if(alivetime[i] > 20 && (type[i] == bloodpool))
516 DeleteDecal(i);
517 }
518 }
519
draw()520 void Decals::draw()
521 {
522 glAlphaFunc(GL_GREATER, 0.01);
523
524 float bloodpoolspeed = 1;
525
526 glDepthFunc(GL_LEQUAL);
527 glEnable(GL_BLEND);
528 glEnable(GL_CULL_FACE);
529 glEnable(GL_TEXTURE_2D);
530 glEnable(GL_LIGHTING);
531 glDepthMask(0);
532 glAlphaFunc(GL_GREATER, 0.01);
533 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
534 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
535 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
536 glEnable(GL_POLYGON_OFFSET_FILL);
537 for(int i = 0; i < howmanydecals; i++) {
538 if(type[i] == bullethole)
539 glBindTexture(GL_TEXTURE_2D, bulletholetextureptr);
540 if(type[i] == crater)
541 glBindTexture(GL_TEXTURE_2D, cratertextureptr);
542 if(type[i] != bloodpool)
543 glColor4f(1, 1, 1, 10 - alivetime[i]);
544
545 if(type[i] == bloodpool && alivetime[i] < bloodpoolspeed * .2)
546 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[0]);
547 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * .2
548 && alivetime[i] < bloodpoolspeed * .4)
549 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[1]);
550 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * .4
551 && alivetime[i] < bloodpoolspeed * .6)
552 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[2]);
553 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * .6
554 && alivetime[i] < bloodpoolspeed * .8)
555 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[3]);
556 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * .8
557 && alivetime[i] < bloodpoolspeed * 1)
558 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[4]);
559 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * 1
560 && alivetime[i] < bloodpoolspeed * 1.2)
561 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[5]);
562 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * 1.2
563 && alivetime[i] < bloodpoolspeed * 1.4)
564 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[6]);
565 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * 1.4
566 && alivetime[i] < bloodpoolspeed * 1.6)
567 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[7]);
568 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * 1.6
569 && alivetime[i] < bloodpoolspeed * 1.8)
570 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[8]);
571 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * 1.8
572 && alivetime[i] < bloodpoolspeed * 2.0)
573 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[9]);
574 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * 2.0)
575 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[10]);
576 if(type[i] == bloodpool && alivetime[i] < bloodpoolspeed * 2.0)
577 glColor4f(1, 1, 1,
578 1.5 - (alivetime[i] * 5 / bloodpoolspeed -
579 (int)(alivetime[i] * 5 / bloodpoolspeed)));
580 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * 2.0)
581 glColor4f(1, 1, 1, 20 - alivetime[i]);
582
583 glPushMatrix();
584 glBegin(GL_TRIANGLE_FAN);
585 for(int j = 0; j < numpoints[i]; j++) {
586 glTexCoord2f(texcoordsx[i * 8 + j], texcoordsy[i * 8 + j]);
587 glVertex3f(points[i * 8 + j].x, points[i * 8 + j].y, points[i * 8 + j].z);
588 }
589 glEnd();
590 glPopMatrix();
591
592 if(type[i] == bloodpool && alivetime[i] < bloodpoolspeed * 2.0) {
593 if(type[i] == bloodpool && alivetime[i] < bloodpoolspeed * .2)
594 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[1]);
595 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * .2
596 && alivetime[i] < bloodpoolspeed * .4)
597 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[2]);
598 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * .4
599 && alivetime[i] < bloodpoolspeed * .6)
600 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[3]);
601 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * .6
602 && alivetime[i] < bloodpoolspeed * .8)
603 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[4]);
604 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * .8
605 && alivetime[i] < bloodpoolspeed * 1)
606 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[5]);
607 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * 1
608 && alivetime[i] < bloodpoolspeed * 1.2)
609 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[6]);
610 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * 1.2
611 && alivetime[i] < bloodpoolspeed * 1.4)
612 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[7]);
613 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * 1.4
614 && alivetime[i] < bloodpoolspeed * 1.6)
615 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[8]);
616 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * 1.6
617 && alivetime[i] < bloodpoolspeed * 1.8)
618 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[9]);
619 if(type[i] == bloodpool && alivetime[i] >= bloodpoolspeed * 1.8
620 && alivetime[i] < bloodpoolspeed * 2.0)
621 glBindTexture(GL_TEXTURE_2D, bloodtextureptr[10]);
622 if(type[i] == bloodpool)
623 glColor4f(1, 1, 1,
624 alivetime[i] * 5 / bloodpoolspeed -
625 (int)(alivetime[i] * 5 / bloodpoolspeed));
626
627 glPushMatrix();
628 glBegin(GL_TRIANGLE_FAN);
629 for(int j = 0; j < numpoints[i]; j++) {
630 glTexCoord2f(texcoordsx[i * 8 + j], texcoordsy[i * 8 + j]);
631 glVertex3f(points[i * 8 + j].x, points[i * 8 + j].y,
632 points[i * 8 + j].z);
633 }
634 glEnd();
635 glPopMatrix();
636 }
637 }
638 glDepthMask(1);
639 glDisable(GL_TEXTURE_2D);
640 glColor4f(1, 1, 1, 1);
641 glEnable(GL_CULL_FACE);
642 glDisable(GL_POLYGON_OFFSET_FILL);
643 glDepthFunc(GL_LEQUAL);
644 }
645