00001
00002 #include "ReVolt.h"
00003 #ifndef _PSX
00004 #include "newcoll.h"
00005 #include "Timing.h"
00006 #include "geom.h"
00007 #include "object.h"
00008 #include "Field.h"
00009 #endif
00010 #include "Spark.h"
00011 #ifdef _PC
00012 #include "draw.h"
00013 #endif
00014 #include "Camera.h"
00015 #ifndef _PSX
00016 #include "Visibox.h"
00017 #endif
00018 #ifdef _N64
00019 #include "gamegfx.h"
00020 #endif
00021
00022 SPARK Sparks[MAX_SPARKS];
00023 int NActiveSparks = 0;
00024
00025 TRAIL SparkTrail[MAX_TRAILS];
00026 int NActiveTrails = 0;
00027
00028 void InitSparks();
00029 SPARK *GetFreeSpark();
00030 void FreeSpark(SPARK *spark);
00031 void ProcessSparks();
00032 bool CreateSpark(SPARK_TYPE type, VEC *pos, VEC *vel, REAL velVar, VISIMASK mask);
00033 void DrawSparks();
00034 void SparkCameraCollide(SPARK *spark, VEC *oldPos);
00035 void SparkWorldCollide(SPARK *spark, VEC *oldPos);
00036 void SparkObjectCollide(SPARK *spark);
00037 void SparkConvexCollide(SPARK *spark, NEWBODY *body);
00038 void SparkSphereCollide(SPARK *spark, NEWBODY *body);
00039 REAL SparkProbability(REAL vel);
00040
00041 static SPARK_DATA SparkData[SPARK_NTYPES] = {
00042 {
00043 #ifdef _PC
00044 {1.0f, 1.0f,
00045 240.0f / 256.0f, 0 / 256.0f,
00046 16 / 256.0f, 16 / 256.0f,
00047 TPAGE_FX1, 0,
00048 0xffffffff},
00049 SPARK_WORLD_COLLIDE | SPARK_FIELD_AFFECT | SPARK_CAMERA_COLLIDE | SPARK_SEMI | SPARK_OBJECT_COLLIDE,
00050 #endif
00051 #ifdef _N64
00052 8.0f, 8.0f,
00053 GFX_SPR_PARTS_2,
00054 GFX_S_PT2_YSPRK_U, GFX_S_PT2_YSPRK_V,
00055 16, 16,
00056 0xFFFF00FF,
00057 FME_FLARE,
00058 SPARK_CREATE_TRAIL | SPARK_FIELD_AFFECT | SPARK_SEMI,
00059 #endif
00060 Real(0.1),
00061 Real(0.02),
00062 Real(0.1),
00063 Real(0.5),
00064 500,
00065 50,
00066 ZERO, ZERO,
00067 ZERO,
00068 ZERO, ZERO,
00069 TRAIL_SPARK,
00070 },
00071 {
00072 #ifdef _PC
00073 {1.0f, 1.0f,
00074 240.0f / 256.0f, 0 / 256.0f,
00075 16 / 256.0f, 16 / 256.0f,
00076 TPAGE_FX1, 0,
00077 0xffffffff},
00078 SPARK_SEMI,
00079 #endif
00080 #ifdef _N64
00081 5.0f, 5.0f,
00082 GFX_SPR_PARTS_2,
00083 GFX_S_PT2_SPARK_U, GFX_S_PT2_SPARK_V,
00084 16, 16,
00085 0xFFFF00FF,
00086 SPARK_SEMI,
00087 #endif
00088 Real(0.1),
00089 Real(0.02),
00090 Real(0.1),
00091 Real(0.5),
00092 300,
00093 20,
00094 ZERO, ZERO,
00095 ZERO,
00096 ZERO, ZERO,
00097 TRAIL_NONE,
00098 },
00099 {
00100 #ifdef _PC
00101 {5.0f, 5.0f,
00102 224.0f / 256.0f, 0.0f,
00103 16.0f / 256.0f, 16.0f / 256.0f,
00104 TPAGE_FX1, 0,
00105 0xffffff},
00106 SPARK_WORLD_COLLIDE | SPARK_OBJECT_COLLIDE | SPARK_FIELD_AFFECT | SPARK_CAMERA_COLLIDE | SPARK_SEMI,
00107 #endif
00108 #ifdef _N64
00109 5.0f, 5.0f,
00110 GFX_SPR_PARTS_2,
00111 GFX_S_PT2_SNOW_U, GFX_S_PT2_SNOW_V,
00112 16, 16,
00113 0xFFFFFFFF,
00114 FME_FLARE,
00115 SPARK_CREATE_TRAIL | SPARK_FIELD_AFFECT | SPARK_SEMI,
00116 #endif
00117 Real(0.03),
00118 Real(0.1),
00119 Real(0.6),
00120 Real(0.2),
00121 10000,
00122 5000,
00123 ZERO, ZERO,
00124 ZERO,
00125 ZERO, ZERO,
00126 TRAIL_NONE,
00127 },
00128 {
00129 #ifdef _PC
00130 {10.0f, 10.0f,
00131 208.0f / 256.0f, 0.0f,
00132 16.0f / 256.0f, 16.0f / 256.0f,
00133 TPAGE_FX1, 0,
00134 0xFF33FF},
00135 SPARK_WORLD_COLLIDE | SPARK_OBJECT_COLLIDE | SPARK_CREATE_TRAIL | SPARK_FIELD_AFFECT | SPARK_CAMERA_COLLIDE | SPARK_SEMI,
00136 #endif
00137 #ifdef _N64
00138 10.0f, 10.0f,
00139 GFX_SPR_PARTS_1,
00140 GFX_S_PT1_POPC_U, GFX_S_PT1_POPC_V,
00141 16, 16,
00142 0x808080FF,
00143 SPARK_CREATE_TRAIL | SPARK_FIELD_AFFECT | SPARK_SEMI,
00144 0,
00145 #endif
00146 Real(0.3),
00147 Real(0.01),
00148 Real(0.7),
00149 Real(0.8),
00150 10000,
00151 0,
00152 ZERO, ZERO,
00153 ZERO,
00154 ZERO, ZERO,
00155 TRAIL_NONE,
00156 },
00157 {
00158 #ifdef _PC
00159 {3.5f, 3.5f,
00160 192.0f / 256.0f, 0 / 256.0f,
00161 16 / 256.0f, 16 / 256.0f,
00162 TPAGE_FX1, 0,
00163 0xff808080},
00164 SPARK_WORLD_COLLIDE | SPARK_OBJECT_COLLIDE | SPARK_CREATE_TRAIL | SPARK_FIELD_AFFECT | SPARK_CAMERA_COLLIDE,
00165 #endif
00166 #ifdef _N64
00167 2.0f, 2.0f,
00168 GFX_SPR_PARTS_1,
00169 GFX_S_PT1_GRAV_U, GFX_S_PT1_GRAV_V,
00170 16, 16,
00171 0x808080FF,
00172 0,
00173 SPARK_CREATE_TRAIL | SPARK_FIELD_AFFECT,
00174 #endif
00175 Real(0.1),
00176 Real(0.02),
00177 Real(0.7),
00178 Real(0.5),
00179 500,
00180 100,
00181 ZERO, ZERO,
00182 ZERO,
00183 ZERO, ZERO,
00184 TRAIL_NONE,
00185 },
00186 {
00187 #ifdef _PC
00188 {2.0f, 2.0f,
00189 240.0f / 256.0f, 0 / 256.0f,
00190 16 / 256.0f, 16 / 256.0f,
00191 TPAGE_FX1, 0,
00192 0xffffffff},
00193 SPARK_WORLD_COLLIDE | SPARK_OBJECT_COLLIDE | SPARK_CREATE_TRAIL | SPARK_FIELD_AFFECT | SPARK_CAMERA_COLLIDE | SPARK_SEMI,
00194 #endif
00195 #ifdef _N64
00196 2.0f, 2.0f,
00197 GFX_SPR_PARTS_2,
00198 GFX_S_PT2_SPARK_U, GFX_S_PT2_SPARK_V,
00199 16, 16,
00200 0xFFFF00FF,
00201 0,
00202 SPARK_CREATE_TRAIL | SPARK_FIELD_AFFECT | SPARK_SEMI,
00203 #endif
00204 Real(0.1),
00205 Real(0.02),
00206 Real(0.7),
00207 Real(0.5),
00208 500000,
00209 100000,
00210 ZERO, ZERO,
00211 ZERO,
00212 ZERO, ZERO,
00213 TRAIL_NONE,
00214 },
00215 {
00216 #ifdef _PC
00217 {2.0f, 2.0f,
00218 240.0f / 256.0f, 0 / 256.0f,
00219 16 / 256.0f, 16 / 256.0f,
00220 TPAGE_FX1, 0,
00221 0xffffffff},
00222 SPARK_WORLD_COLLIDE | SPARK_OBJECT_COLLIDE | SPARK_CREATE_TRAIL | SPARK_FIELD_AFFECT | SPARK_CAMERA_COLLIDE | SPARK_SEMI,
00223 #endif
00224 #ifdef _N64
00225 2.0f, 2.0f,
00226 GFX_SPR_PARTS_1,
00227 GFX_S_PT1_MUD_U, GFX_S_PT1_MUD_V,
00228 16, 16,
00229 0x808080FF,
00230 0,
00231 SPARK_CREATE_TRAIL | SPARK_FIELD_AFFECT | SPARK_SEMI,
00232 #endif
00233 Real(0.1),
00234 Real(0.02),
00235 Real(1.0),
00236 Real(0.5),
00237 500,
00238 100,
00239 ZERO, ZERO,
00240 ZERO,
00241 ZERO, ZERO,
00242 TRAIL_NONE,
00243 },
00244 {
00245 #ifdef _PC
00246 {0.8f, 0.8f,
00247 224.0f / 256.0f, 16.0f / 256.0f,
00248 16.0f / 256.0f, 16.0f / 256.0f,
00249 TPAGE_FX1, 0,
00250 0xffc0c0ff},
00251 SPARK_OBJECT_COLLIDE | SPARK_SEMI | SPARK_FIELD_AFFECT,
00252 #endif
00253 #ifdef _N64
00254 1.0f, 1.0f,
00255 GFX_SPR_PARTS_2,
00256 GFX_S_PT2_EBALL_U, GFX_S_PT2_EBALL_V,
00257 16, 16,
00258 0x2020FFFF,
00259 FME_FLARE,
00260 SPARK_CREATE_TRAIL | SPARK_SEMI,
00261 #endif
00262 Real(0.1),
00263 Real(0.02),
00264 Real(0.1),
00265 Real(0.5),
00266 150,
00267 0,
00268 ZERO, ZERO,
00269 ZERO,
00270 ZERO, ZERO,
00271 TRAIL_NONE,
00272 },
00273 {
00274 #ifdef _PC
00275 {10.0f, 10.0f,
00276 192.0f / 256.0f, 16 / 256.0f,
00277 16.0f / 256.0f, 16.0f / 256.0f,
00278 TPAGE_FX1, 0,
00279 0xff4433dd},
00280 SPARK_WORLD_COLLIDE | SPARK_OBJECT_COLLIDE | SPARK_CREATE_TRAIL | SPARK_FIELD_AFFECT | SPARK_CAMERA_COLLIDE | SPARK_SEMI,
00281 #endif
00282 #ifdef _N64
00283 10.0f, 10.0f,
00284 GFX_SPR_PARTS_1,
00285 GFX_S_PT1_WATER_U, GFX_S_PT1_WATER_V,
00286 16, 16,
00287 0x808080FF,
00288 0,
00289 SPARK_CREATE_TRAIL | SPARK_FIELD_AFFECT | SPARK_SEMI,
00290 #endif
00291 Real(0.03),
00292 Real(0.001),
00293 Real(0.8),
00294 Real(0.2),
00295 2000,
00296 1000,
00297 ZERO, ZERO,
00298 ZERO,
00299 ZERO, ZERO,
00300 TRAIL_NONE,
00301 },
00302 {
00303 #ifdef _PC
00304 {5.0f, 5.0f,
00305 208.0f / 256.0f, 16.0f,
00306 16.0f / 256.0f, 16.0f / 256.0f,
00307 TPAGE_FX1, 0,
00308 0xffffffff},
00309 SPARK_WORLD_COLLIDE | SPARK_OBJECT_COLLIDE | SPARK_CREATE_TRAIL | SPARK_FIELD_AFFECT | SPARK_CAMERA_COLLIDE | SPARK_SEMI,
00310 #endif
00311 #ifdef _N64
00312 5.0f, 5.0f,
00313 GFX_SPR_PARTS_1,
00314 GFX_S_PT1_MUD_U, GFX_S_PT1_MUD_V,
00315 16, 16,
00316 0x808080FF,
00317 0,
00318 SPARK_CREATE_TRAIL | SPARK_FIELD_AFFECT | SPARK_SEMI,
00319 #endif
00320 Real(0.03),
00321 Real(0.001),
00322 Real(0.1),
00323 Real(0.2),
00324 1000,
00325 500,
00326 ZERO, ZERO,
00327 ZERO,
00328 ZERO, ZERO,
00329 TRAIL_NONE,
00330 },
00331 {
00332 #ifdef _PC
00333 {6.0f, 6.0f,
00334 0.0f, 0.0f,
00335 64.0f / 256.0f, 64.0f / 256.0f,
00336 TPAGE_FX1, 0,
00337 0x404040},
00338 SPARK_OBJECT_COLLIDE | SPARK_WORLD_COLLIDE | SPARK_SPINS | SPARK_GROWS | SPARK_SEMI,
00339 #endif
00340 #ifdef _N64
00341 24.0f, 24.0f,
00342 GFX_SPR_SMOKE,
00343 0, 0,
00344 GFX_SPR_SMOKE_W, GFX_SPR_SMOKE_H,
00345 0xA0A0A080,
00346 0,
00347 SPARK_SPINS | SPARK_GROWS | SPARK_SEMI,
00348 #endif
00349 Real(0.03),
00350 Real(0.002),
00351 Real(0.0),
00352 Real(0.0),
00353 500,
00354 100,
00355 Real(0.0), Real(6.0),
00356 Real(2.0),
00357 Real(0.0), Real(36.0),
00358 TRAIL_NONE,
00359 },
00360 {
00361 #ifdef _PC
00362 {64.0f, 64.0f,
00363 0.0f, 0.0f,
00364 64.0f / 256.0f, 64.0f / 256.0f,
00365 TPAGE_FX1, 0,
00366 0x606060},
00367 SPARK_OBJECT_COLLIDE | SPARK_WORLD_COLLIDE | SPARK_SPINS | SPARK_GROWS | SPARK_SEMI,
00368 #endif
00369 #ifdef _N64
00370 64.0f, 64.0f,
00371 GFX_SPR_SMOKE,
00372 0, 0,
00373 GFX_SPR_SMOKE_W, GFX_SPR_SMOKE_H,
00374 0xA0A0A0FF,
00375 0,
00376 SPARK_SPINS | SPARK_GROWS | SPARK_SEMI,
00377 #endif
00378 Real(0.03),
00379 Real(0.02),
00380 Real(0.001),
00381 Real(0.0),
00382 2600,
00383 0,
00384 Real(0.0), Real(6.0),
00385 Real(0.0),
00386 Real(40.0), Real(20.0),
00387 TRAIL_NONE,
00388 },
00389 {
00390 #ifdef _PC
00391 {4.0f, 4.0f,
00392 0.0f, 0.0f,
00393 64.0f / 256.0f, 64.0f / 256.0f,
00394 TPAGE_FX1, 0,
00395 0x404040},
00396 SPARK_OBJECT_COLLIDE | SPARK_SPINS | SPARK_GROWS | SPARK_SEMI,
00397 #endif
00398 #ifdef _N64
00399 4.0f, 4.0f,
00400 GFX_SPR_SMOKE,
00401 0, 0,
00402 GFX_SPR_SMOKE_W, GFX_SPR_SMOKE_H,
00403 0x404040FF,
00404 0,
00405 SPARK_SPINS | SPARK_GROWS | SPARK_SEMI,
00406 #endif
00407 Real(0.03),
00408 Real(0.0),
00409 Real(0.0),
00410 Real(0.0),
00411 1500,
00412 100,
00413 Real(0.0), Real(6.0),
00414 Real(2.0),
00415 Real(0.0), Real(36.0),
00416 TRAIL_NONE,
00417 },
00418 {
00419 #ifdef _PC
00420 {4.0f, 4.0f,
00421 224.0f / 256.0f, 16.0f / 256.0f,
00422 16.0f / 256.0f, 16.0f / 256.0f,
00423 TPAGE_FX1, 0,
00424 0x808080},
00425 #endif
00426 #ifdef _N64
00427 4.0f, 4.0f,
00428 GFX_SPR_PARTS_2,
00429 GFX_S_PT2_YSPRK_U, GFX_S_PT2_YSPRK_V,
00430 16, 16,
00431 0x0000ffFF,
00432 FME_FLARE,
00433 #endif
00434 SPARK_SEMI,
00435 Real(0.0),
00436 Real(0.0),
00437 Real(0.0),
00438 Real(0.0),
00439 500,
00440 0,
00441 Real(0.0), Real(0.0),
00442 Real(0.0),
00443 Real(0.0), Real(0.0),
00444 TRAIL_NONE,
00445 },
00446 {
00447 #ifdef _PC
00448 {4.0f, 4.0f,
00449 224.0f / 256.0f, 16.0f / 256.0f,
00450 16.0f / 256.0f, 16.0f / 256.0f,
00451 TPAGE_FX1, 0,
00452 0x808080},
00453 #endif
00454 #ifdef _N64
00455 4.0f, 4.0f,
00456 GFX_SPR_FLARE2,
00457 0, 0,
00458 GFX_SPR_FLARE2_W, GFX_SPR_FLARE2_H,
00459 0x0000FFFF,
00460 FME_FLARE,
00461 #endif
00462 SPARK_FIELD_AFFECT | SPARK_SEMI,
00463 Real(0.1),
00464 Real(0.02),
00465 Real(0.1),
00466 Real(0.5),
00467 500,
00468 500,
00469 Real(0.0), Real(0.0),
00470 Real(8.0),
00471 Real(0.0), Real(0.0),
00472 TRAIL_NONE,
00473 },
00474 {
00475 #ifdef _PC
00476 {18.0f, 18.0f,
00477 192.0f / 256.0f, 32 / 256.0f,
00478 16.0f / 256.0f, 16.0f / 256.0f,
00479 TPAGE_FX1, 0,
00480 0xffffffff},
00481 #endif
00482 #ifdef _N64
00483 10.0f, 10.0f,
00484 GFX_SPR_PARTS_2,
00485 GFX_S_PT2_YSPRK_U, GFX_S_PT2_YSPRK_V,
00486 16, 16,
00487 0xFFA000FF,
00488 FME_FLARE,
00489 #endif
00490 SPARK_WORLD_COLLIDE | SPARK_FIELD_AFFECT | SPARK_SEMI,
00491 Real(0.03),
00492 Real(0.016),
00493 Real(0.6),
00494 Real(0.0),
00495 1200,
00496 500,
00497 ZERO, ZERO,
00498 Real(2),
00499 Real(-2), ZERO,
00500 TRAIL_FIREWORK,
00501 },
00502 {
00503 #ifdef _PC
00504 {20.0f, 20.0f,
00505 240.0f / 256.0f, 32 / 256.0f,
00506 16.0f / 256.0f, 16.0f / 256.0f,
00507 TPAGE_FX1, 0,
00508 0xffffffff},
00509 #endif
00510 #ifdef _N64
00511 10.0f, 10.0f,
00512 GFX_SPR_PARTS_2,
00513 GFX_S_PT2_RSPRK_U, GFX_S_PT2_RSPRK_V,
00514 16, 16,
00515 0xFF0000FF,
00516 FME_FLARE,
00517 #endif
00518 SPARK_WORLD_COLLIDE | SPARK_CREATE_TRAIL | SPARK_FIELD_AFFECT | SPARK_SEMI,
00519 Real(0.03),
00520 Real(0.012),
00521 Real(0.6),
00522 Real(0.0),
00523 1500,
00524 500,
00525 ZERO, ZERO,
00526 Real(5),
00527 Real(-5), ZERO,
00528 TRAIL_FIREWORK,
00529 },
00530 {
00531 #ifdef _PC
00532 {12.0f, 12.0f,
00533 64.0f / 256.0f, 0 / 256.0f,
00534 64.0f / 256.0f, 64.0f / 256.0f,
00535 TPAGE_FX1, 0,
00536 0xffffffff},
00537 #endif
00538 #ifdef _N64
00539 10.0f, 10.0f,
00540 GFX_SPR_FIRE,
00541 0, 0,
00542 GFX_SPR_FIRE_W, GFX_SPR_FIRE_H,
00543 0x808080FF,
00544 FME_FLARE,
00545 #endif
00546 SPARK_SEMI | SPARK_SPINS | SPARK_GROWS,
00547 Real(0.03),
00548 Real(0.015),
00549 Real(0.6),
00550 Real(0.0),
00551 500,
00552 000,
00553 ZERO, Real(6),
00554 Real(0),
00555 Real(128), Real(0),
00556 TRAIL_NONE,
00557 },
00558 {
00559 #ifdef _PC
00560 {8.0f, 8.0f,
00561 64.0f / 256.0f, 0 / 256.0f,
00562 64.0f / 256.0f, 64.0f / 256.0f,
00563 TPAGE_FX1, 0,
00564 0xffffffff},
00565 #endif
00566 #ifdef _N64
00567 10.0f, 10.0f,
00568 GFX_SPR_FIRE,
00569 0, 0,
00570 GFX_SPR_FIRE_W, GFX_SPR_FIRE_H,
00571 0x808080FF,
00572 FME_FLARE,
00573 #endif
00574 SPARK_SEMI | SPARK_SPINS | SPARK_GROWS,
00575 Real(0.03),
00576 Real(0.015),
00577 Real(0.6),
00578 Real(0.0),
00579 500,
00580 300,
00581 ZERO, Real(32),
00582 Real(0),
00583 Real(12), Real(5),
00584 TRAIL_NONE,
00585 },
00586 {
00587 #ifdef _PC
00588 {8.0f, 8.0f,
00589 241.0f / 256.0f, 32 / 256.0f,
00590 15.0f / 256.0f, 16.0f / 256.0f,
00591 TPAGE_FX1, 0,
00592 0xffffff},
00593 #endif
00594 #ifdef _N64
00595 4.0f, 4.0f,
00596 GFX_SPR_PARTS_2,
00597 GFX_S_PT2_YSPRK_U, GFX_S_PT2_YSPRK_V,
00598 16, 16,
00599 0x00ffffff,
00600 FME_FLARE | FME_NOZB,
00601 #endif
00602 SPARK_SEMI | SPARK_GROWS,
00603 Real(0.0),
00604 Real(0.0),
00605 Real(0.0),
00606 Real(0.0),
00607 500,
00608 0,
00609 Real(0.0), Real(0.0),
00610 Real(0.0),
00611 Real(30.0), Real(0.0),
00612 TRAIL_NONE,
00613 },
00614 };
00615
00616
00618
00619
00620
00622
00623 TRAIL_DATA TrailData[TRAIL_NTYPES] = {
00624 {
00625 225.0f / 256.0f, 33.0f / 256.0f,
00626 14.0f / 256.0f, 14.0f / 256.0f,
00627 225.0f / 256.0f, 33.0f / 256.0f,
00628 0xff, 0xff, 0xff, 0xff,
00629 TRAIL_FADES | TRAIL_SHRINKS,
00630 Real(0.3),
00631 Real(5),
00632 TRAIL_MAX_BITS,
00633 },
00634 {
00635 246.0f / 256.0f, 0.0f / 256.0f,
00636 2.0f / 256.0f, 16.0f / 256.0f,
00637 246.0f / 256.0f, 0.0f / 256.0f,
00638 0xff, 0xff, 0xff, 0xff,
00639 TRAIL_FADES | TRAIL_SHRINKS,
00640 Real(0.03),
00641 Real(1),
00642 2,
00643 },
00644 {
00645 224.0f / 256.0f, 48.0f / 256.0f,
00646 16.0f / 256.0f, 16.0f / 256.0f,
00647 240.0f / 256.0f, 48.0f / 256.0f,
00648 0xff, 0x88, 0x88, 0xaa,
00649 TRAIL_FADES | TRAIL_EXPANDS,
00650 Real(0.4),
00651 Real(10),
00652 TRAIL_MAX_BITS,
00653 },
00654 };
00655
00656
00658
00659
00660
00662
00663 TRAIL *GetFreeTrail(long trailType)
00664 {
00665 int iTrail;
00666
00667 Assert(trailType < TRAIL_NTYPES);
00668
00669 for (iTrail = 0; iTrail < MAX_TRAILS; iTrail++) {
00670 if (SparkTrail[iTrail].Free) {
00671 NActiveTrails++;
00672 SparkTrail[iTrail].Free = FALSE;
00673 SparkTrail[iTrail].Data = &TrailData[trailType];
00674 SparkTrail[iTrail].NTrails = 0;
00675 SparkTrail[iTrail].MaxTrails = TrailData[trailType].MaxTrails;
00676 SparkTrail[iTrail].FirstTrail = 0;
00677 return &SparkTrail[iTrail];
00678 }
00679 }
00680
00681 return NULL;
00682 }
00683
00685
00686
00687
00689
00690 void FreeTrail(TRAIL *trail)
00691 {
00692 trail->Free = TRUE;
00693 NActiveTrails--;
00694 }
00695
00696
00698
00699
00700
00702
00703 void UpdateTrail(TRAIL *trail, VEC *newPos)
00704 {
00705 if (trail->FirstTrail == trail->MaxTrails - 1) {
00706 trail->FirstTrail = 0;
00707 } else {
00708 trail->FirstTrail++;
00709 }
00710
00711 if (trail->NTrails < trail->MaxTrails) {
00712 trail->NTrails++;
00713 }
00714
00715 CopyVec(newPos, &trail->Pos[trail->FirstTrail]);
00716 }
00717
00718 void ModifyFirstTrail(TRAIL *trail, VEC *newPos)
00719 {
00720 CopyVec(newPos, &trail->Pos[trail->FirstTrail]);
00721 }
00722
00724
00725
00726
00728
00729 void InitSparks()
00730 {
00731 int iSpark, iTrail;
00732
00733 for (iSpark = 0; iSpark < MAX_SPARKS; iSpark++) {
00734 Sparks[iSpark].Free = TRUE;
00735 }
00736 NActiveSparks = 0;
00737
00738 for (iTrail = 0; iTrail < MAX_TRAILS; iTrail++) {
00739 SparkTrail[iTrail].Free = TRUE;
00740 }
00741 NActiveTrails = 0;
00742 }
00743
00745
00746
00747
00749
00750 SPARK *GetFreeSpark()
00751 {
00752 int iSpark;
00753
00754
00755 for (iSpark = 0; iSpark < MAX_SPARKS; iSpark++) {
00756 if (Sparks[iSpark].Free) {
00757 Sparks[iSpark].Free = FALSE;
00758 NActiveSparks++;
00759 return &Sparks[iSpark];
00760 }
00761 }
00762
00763
00764 return NULL;
00765 }
00766
00768
00769
00770
00772
00773 void FreeSpark(SPARK *spark)
00774 {
00775 if (spark->Trail != NULL) {
00776 FreeTrail(spark->Trail);
00777 }
00778
00779 spark->Free = TRUE;
00780 NActiveSparks--;
00781 }
00782
00784
00785
00786
00788
00789 void ProcessSparks()
00790 {
00791
00792 #ifndef _PSX
00793
00794 int iSpark;
00795 VEC imp, angImp, oldPos;
00796 FIELD_DATA fieldData;
00797 SPARK *spark;
00798
00799 for (iSpark = 0; iSpark < MAX_SPARKS; iSpark++) {
00800 spark = &Sparks[iSpark];
00801
00802
00803 if (spark->Free) continue;
00804
00805 #ifndef _PSX
00806
00807 if (CamVisiMask & spark->VisiMask) continue;
00808 #endif
00809
00810
00811 spark->Age += TimerDiff;
00812 if (spark->Age > MS2TIME(spark->Data->LifeTime)) {
00813 FreeSpark(spark);
00814 continue;
00815 }
00816
00817
00818 if (spark->Data->SparkType & SPARK_SPINS) {
00819 spark->Spin += spark->SpinRate * TimeStep;
00820 }
00821
00822
00823 if (spark->Data->SparkType & SPARK_GROWS) {
00824 spark->Grow += spark->GrowRate * TimeStep;
00825
00826 }
00827
00828
00829 if (spark->Data->SparkType & SPARK_FIELD_AFFECT) {
00830 fieldData.ObjectID = FIELD_PARENT_NONE;
00831 fieldData.Mass = spark->Data->Mass;
00832 fieldData.Pos = &spark->Pos;
00833 fieldData.Vel = &spark->Vel;
00834 fieldData.AngVel = &ZeroVector;
00835 fieldData.Quat = &IdentityQuat;
00836 fieldData.Mat = &Identity;
00837
00838 AllFieldImpulses(&fieldData, &imp, &angImp);
00839
00840
00841 VecPlusEqScalarVec(&spark->Vel, ONE / spark->Data->Mass, &imp);
00842 }
00843
00844
00845 VecMulScalar(&spark->Vel, ONE - (spark->Data->Resistance * FRICTION_TIME_SCALE * TimeStep));
00846
00847
00848 CopyVec(&spark->Pos, &oldPos);
00849 VecPlusEqScalarVec(&spark->Pos, TimeStep, &spark->Vel);
00850
00851
00852 if (spark->Data->SparkType & SPARK_OBJECT_COLLIDE) {
00853 SparkObjectCollide(spark);
00854 }
00855 if (spark->Data->SparkType & SPARK_WORLD_COLLIDE) {
00856 SparkWorldCollide(spark, &oldPos);
00857 }
00858 #ifdef _PC
00859 if (spark->Data->SparkType & SPARK_CAMERA_COLLIDE) {
00860 SparkCameraCollide(spark, &oldPos);
00861 }
00862 #endif
00863
00864
00865 if (spark->Trail != NULL) {
00866 spark->TrailTime += TimeStep;
00867 if (spark->TrailTime > spark->Trail->Data->LifeTime / spark->Trail->MaxTrails) {
00868 UpdateTrail(spark->Trail, &spark->Pos);
00869 spark->TrailTime = ZERO;
00870 } else {
00871 ModifyFirstTrail(spark->Trail, &spark->Pos);
00872 }
00873
00874 }
00875 }
00876
00877
00878
00879 #endif
00880
00881 }
00882
00883
00885
00886
00887
00889 #ifdef _PC
00890 void SparkCameraCollide(SPARK *spark, VEC *oldPos)
00891 {
00892 REAL time, depth, velDotNorm;
00893 VEC dPos, wPos;
00894 BBOX bBox;
00895 NEWCOLLPOLY *collPoly;
00896
00897 collPoly = &CAM_MainCamera->CollPoly;
00898
00899
00900 SetBBox(&bBox,
00901 Min(spark->Pos.v[X], oldPos->v[X]),
00902 Max(spark->Pos.v[X], oldPos->v[X]),
00903 Min(spark->Pos.v[Y], oldPos->v[Y]),
00904 Max(spark->Pos.v[Y], oldPos->v[Y]),
00905 Min(spark->Pos.v[Z], oldPos->v[Z]),
00906 Max(spark->Pos.v[Z], oldPos->v[Z]));
00907 if(!BBTestXZY(&bBox, &collPoly->BBox)) return;
00908
00909
00910 if (!LinePlaneIntersect(oldPos, &spark->Pos, &collPoly->Plane, &time, &depth)) {
00911 return;
00912 }
00913
00914
00915 VecMinusVec(&spark->Pos, oldPos, &dPos);
00916 VecPlusScalarVec(oldPos, time, &dPos, &wPos);
00917
00918
00919 velDotNorm = VecDotVec(&spark->Vel, PlaneNormal(&collPoly->Plane));
00920 if (velDotNorm > ZERO) return;
00921
00922
00923
00924 if (!PointInCollPolyBounds(&wPos, collPoly)) {
00925 return;
00926 }
00927
00928
00929 VecPlusEqScalarVec(&spark->Pos, -depth + COLL_EPSILON, PlaneNormal(&collPoly->Plane));
00930 VecPlusEqScalarVec(&spark->Pos, TimeStep, &CAM_MainCamera->Vel);
00931
00932
00933 VecPlusEqScalarVec(&spark->Vel, -velDotNorm, PlaneNormal(&collPoly->Plane));
00934 VecMulScalar(&spark->Vel, (ONE - spark->Data->Friction));
00935 VecPlusEqScalarVec(&spark->Vel, -(spark->Data->Restitution * velDotNorm), PlaneNormal(&collPoly->Plane));
00936
00937
00938 }
00939 #endif
00940
00942
00943
00944
00946
00947 void SparkWorldCollide(SPARK *spark, VEC *oldPos)
00948 {
00949 int iPoly;
00950 REAL time, depth, velDotNorm;
00951 VEC dPos, wPos;
00952 BBOX bBox;
00953 COLLGRID *grid;
00954 NEWCOLLPOLY *collPoly;
00955
00956 grid = PosToCollGrid(&spark->Pos);
00957 if (grid == NULL) return;
00958
00959 for (iPoly = 0; iPoly < grid->NCollPolys; iPoly++)
00960 {
00961 #ifndef _PSX
00962 collPoly = grid->CollPolyPtr[iPoly];
00963 #else
00964 collPoly = &COL_WorldCollPoly[grid->CollPolyIndices[iPoly]];
00965 #endif
00966
00967 if (PolyCameraOnly(collPoly)) continue;
00968
00969
00970 SetBBox(&bBox,
00971 Min(spark->Pos.v[X], oldPos->v[X]),
00972 Max(spark->Pos.v[X], oldPos->v[X]),
00973 Min(spark->Pos.v[Y], oldPos->v[Y]),
00974 Max(spark->Pos.v[Y], oldPos->v[Y]),
00975 Min(spark->Pos.v[Z], oldPos->v[Z]),
00976 Max(spark->Pos.v[Z], oldPos->v[Z]));
00977 if(!BBTestYXZ(&bBox, &collPoly->BBox)) continue;
00978
00979
00980 if (!LinePlaneIntersect(oldPos, &spark->Pos, &collPoly->Plane, &time, &depth)) {
00981 continue;
00982 }
00983
00984
00985 VecMinusVec(&spark->Pos, oldPos, &dPos);
00986 VecPlusScalarVec(oldPos, time, &dPos, &wPos);
00987
00988
00989 velDotNorm = VecDotVec(&spark->Vel, PlaneNormal(&collPoly->Plane));
00990 if (velDotNorm > ZERO) continue;
00991
00992
00993
00994 if (!PointInCollPolyBounds(&wPos, collPoly)) {
00995 continue;
00996 }
00997
00998
00999 VecPlusEqScalarVec(&spark->Pos, -depth, PlaneNormal(&collPoly->Plane));
01000
01001
01002 VecPlusEqScalarVec(&spark->Vel, -velDotNorm, PlaneNormal(&collPoly->Plane));
01003 VecMulScalar(&spark->Vel, (ONE - spark->Data->Friction));
01004 VecPlusEqScalarVec(&spark->Vel, -(spark->Data->Restitution * velDotNorm), PlaneNormal(&collPoly->Plane));
01005
01006
01007 }
01008 }
01009
01010
01011
01013
01014
01015
01017
01018 void SparkObjectCollide(SPARK *spark)
01019 {
01020 OBJECT *obj;
01021
01022 for (obj = OBJ_ObjectHead; obj != NULL; obj = obj->next) {
01023
01024
01025 if (obj->CollType == COLL_TYPE_NONE) continue;
01026 if (obj->body.CollSkin.AllowObjColls == FALSE) continue;
01027
01028
01029 if(!PointInBBox(&spark->Pos, &obj->body.CollSkin.BBox)) continue;
01030
01031 if (IsBodyConvex(&obj->body)) {
01032 SparkConvexCollide(spark, &obj->body);
01033 } else if (IsBodySphere(&obj->body)) {
01034 SparkSphereCollide(spark, &obj->body);
01035 }
01036 }
01037 }
01038
01039 void SparkConvexCollide(SPARK *spark, NEWBODY *body)
01040 {
01041 int iSkin;
01042 REAL depth, velDotNorm;
01043 VEC dVel;
01044 PLANE plane;
01045
01046 for (iSkin = 0; iSkin < body->CollSkin.NConvex; iSkin++) {
01047
01048 if (!PointInConvex(&spark->Pos, &body->CollSkin.WorldConvex[iSkin], &plane, &depth)) continue;
01049
01050
01051 VecPlusEqScalarVec(&spark->Pos, -depth + COLL_EPSILON, PlaneNormal(&plane));
01052 velDotNorm = VecDotVec(&spark->Vel, PlaneNormal(&plane));
01053 VecPlusEqScalarVec(&spark->Vel, -(ONE + spark->Data->Restitution) * velDotNorm, PlaneNormal(&plane));
01054
01055
01056 VecMinusVec(&body->Centre.Vel, &spark->Vel, &dVel);
01057 VecPlusEqScalarVec(&spark->Vel, spark->Data->Friction, &dVel);
01058 }
01059 }
01060
01061 void SparkSphereCollide(SPARK *spark, NEWBODY *body)
01062 {
01063
01064 }
01065
01066
01067
01069
01070
01071
01072
01074
01075 bool CreateSpark(SPARK_TYPE type, VEC *pos, VEC *vel, REAL velVar, VISIMASK mask)
01076 {
01077
01078
01079 #ifndef _PSX
01080
01081 VEC dV;
01082 SPARK *spark;
01083
01084
01085 Assert(type < SPARK_NTYPES);
01086
01087
01088 spark = GetFreeSpark();
01089
01090
01091 if (spark == NULL) return FALSE;
01092
01093
01094 spark->VisiMask = mask;
01095
01096
01097 SetVec(&dV, velVar - frand(2 * velVar), velVar - frand(2 * velVar), velVar - frand(2 * velVar));
01098
01099
01100 VecPlusVec(vel, &dV, &spark->Vel)
01101
01102
01103 CopyVec(pos, &spark->Pos);
01104
01105
01106 spark->Data = &SparkData[type];
01107
01108
01109 spark->Age = (long)frand(SparkData[type].LifeTimeVar);
01110
01111
01112 if (spark->Data->SparkType & SPARK_SPINS) {
01113 spark->Spin = frand(ONE);
01114 spark->SpinRate = spark->Data->SpinRateBase + (spark->Data->SpinRateVar * HALF) - frand(spark->Data->SpinRateVar);
01115 } else {
01116 spark->Spin = ZERO;
01117 spark->SpinRate = ZERO;
01118 }
01119
01120
01121 spark->Grow = frand(spark->Data->SizeVar);
01122 if (spark->Data->SparkType & SPARK_GROWS) {
01123 spark->GrowRate = spark->Data->GrowRateBase + frand(spark->Data->GrowRateVar);
01124 } else {
01125 spark->GrowRate = ZERO;
01126 }
01127
01128
01129 if (spark->Data->SparkType & SPARK_CREATE_TRAIL) {
01130 spark->Trail = GetFreeTrail(spark->Data->TrailType);
01131 if (spark->Trail != NULL) {
01132 CopyVec(&spark->Pos, &spark->Trail->Pos[0]);
01133 spark->TrailTime = ZERO;
01134 }
01135 } else {
01136 spark->Trail = NULL;
01137 }
01138
01139
01140 return TRUE;
01141
01142 #endif
01143
01144 }
01145
01146
01148
01149
01150
01151
01153
01154 REAL SparkProbability(REAL vel)
01155 {
01156 REAL prob;
01157
01158 prob = (vel - MIN_SPARK_VEL) / (MAX_SPARK_VEL - MIN_SPARK_VEL);
01159
01160 if (prob < ZERO) return ZERO;
01161 if (prob > ONE) return ONE;
01162 return prob;
01163 }
01164
01165
01167
01168
01169
01171
01172 #ifdef _PC
01173 void DrawSparkTrail(TRAIL *trail)
01174 {
01175 int iTrail, thisTrail, lastTrail;
01176 long a, r, g, b;
01177 REAL dx, dy, dt, dLen, width;
01178 DRAW_SEMI_POLY poly;
01179 VERTEX_TEX1 sPos, ePos;
01180 VERTEX_TEX1 *vert = poly.Verts;
01181
01182 poly.Fog = FALSE;
01183 poly.VertNum = 4;
01184 poly.Tpage = TPAGE_FX1;
01185 poly.DrawFlag = D3DDP_DONOTUPDATEEXTENTS;
01186 poly.SemiType = TRUE;
01187
01188 SET_TPAGE((short)poly.Tpage);
01189 vert[3].tu = trail->Data->U;
01190 vert[3].tv = trail->Data->V;
01191
01192 vert[0].tu = trail->Data->U + trail->Data->Usize;
01193 vert[0].tv = trail->Data->V;
01194
01195 vert[1].tu = trail->Data->U + trail->Data->Usize;
01196 vert[1].tv = trail->Data->V + trail->Data->Vsize;
01197
01198 vert[2].tu = trail->Data->U;
01199 vert[2].tv = trail->Data->V + trail->Data->Vsize;
01200
01201
01202 FOG_OFF();
01203 ALPHA_SRC(D3DBLEND_ONE);
01204 ALPHA_DEST(D3DBLEND_ONE);
01205
01206 thisTrail = trail->FirstTrail;
01207 lastTrail = (trail->FirstTrail - 1);
01208 if (lastTrail < 0) lastTrail = trail->MaxTrails - 1;
01209
01210
01211 RotTransPersVector(&ViewMatrixScaled, &ViewTransScaled, &trail->Pos[thisTrail], (REAL*)&ePos);
01212 RotTransPersVector(&ViewMatrixScaled, &ViewTransScaled, &trail->Pos[lastTrail], (REAL*)&sPos);
01213 dx = ePos.sx - sPos.sx;
01214 dy = ePos.sy - sPos.sy;
01215 dLen = (REAL)sqrt(dx * dx + dy * dy);
01216 dt = dx;
01217 dx = dy / dLen;
01218 dy = -dt / dLen;
01219
01220
01221 width = trail->Data->Width;
01222 vert[2].sx = ePos.sx + dx * width * ePos.rhw * RenderSettings.GeomPers;
01223 vert[2].sy = ePos.sy + dy * width * ePos.rhw * RenderSettings.GeomPers;
01224 vert[2].sz = ePos.sz;
01225 vert[2].rhw = ePos.rhw;
01226 vert[3].sx = ePos.sx - dx * width * ePos.rhw * RenderSettings.GeomPers;
01227 vert[3].sy = ePos.sy - dy * width * ePos.rhw * RenderSettings.GeomPers;
01228 vert[3].sz = ePos.sz;
01229 vert[3].rhw = ePos.rhw;
01230
01231 for (iTrail = 1; iTrail < trail->NTrails; iTrail++) {
01232
01233
01234 RotTransPersVector(&ViewMatrixScaled, &ViewTransScaled, &trail->Pos[lastTrail], (REAL*)&sPos);
01235 dx = ePos.sx - sPos.sx;
01236 dy = ePos.sy - sPos.sy;
01237 dLen = (REAL)sqrt(dx * dx + dy * dy);
01238 if (dLen < SMALL_REAL) {
01239 continue;
01240 }
01241 dt = dx;
01242 dx = dy / dLen;
01243 dy = -dt / dLen;
01244
01245
01246 if (trail->Data->Type & TRAIL_SHRINKS) {
01247 width = trail->Data->Width - (trail->Data->Width * iTrail) / trail->MaxTrails;
01248 } else if (trail->Data->Type & TRAIL_EXPANDS) {
01249 width = trail->Data->Width + (3 * trail->Data->Width * iTrail) / (trail->MaxTrails * 2);
01250 } else {
01251 width = trail->Data->Width;
01252 }
01253 vert[0].sx = sPos.sx - dx * width * sPos.rhw * RenderSettings.GeomPers;
01254 vert[0].sy = sPos.sy - dy * width * sPos.rhw * RenderSettings.GeomPers;
01255 vert[0].sz = sPos.sz;
01256 vert[0].rhw = sPos.rhw;
01257 vert[1].sx = sPos.sx + dx * width * sPos.rhw * RenderSettings.GeomPers;
01258 vert[1].sy = sPos.sy + dy * width * sPos.rhw * RenderSettings.GeomPers;
01259 vert[1].sz = sPos.sz;
01260 vert[1].rhw = sPos.rhw;
01261
01262
01263 if (trail->Data->Type & TRAIL_FADES) {
01264 a = trail->Data->A - iTrail * (trail->Data->A / trail->NTrails);
01265 r = trail->Data->R - iTrail * (trail->Data->R / trail->NTrails);
01266 g = trail->Data->G - iTrail * (trail->Data->G / trail->NTrails);
01267 b = trail->Data->B - iTrail * (trail->Data->B / trail->NTrails);
01268 } else {
01269 a = trail->Data->A;
01270 r = trail->Data->R;
01271 g = trail->Data->G;
01272 b = trail->Data->B;
01273 }
01274 vert[0].color = vert[1].color = r << 16 | g << 8 | b;
01275 if (trail->Data->Type & TRAIL_FADES) {
01276 a = trail->Data->A - (iTrail - 1) * (trail->Data->A / trail->NTrails);
01277 r = trail->Data->R - (iTrail - 1) * (trail->Data->R / trail->NTrails);
01278 g = trail->Data->G - (iTrail - 1) * (trail->Data->G / trail->NTrails);
01279 b = trail->Data->B - (iTrail - 1) * (trail->Data->B / trail->NTrails);
01280 } else {
01281 a = trail->Data->A;
01282 r = trail->Data->R;
01283 g = trail->Data->G;
01284 b = trail->Data->B;
01285 }
01286 vert[2].color = vert[3].color = r << 16 | g << 8 | b;
01287
01288 if (iTrail == trail->NTrails - 1) {
01289 vert[3].tu = trail->Data->EndU;
01290 vert[3].tv = trail->Data->EndV;
01291
01292 vert[0].tu = trail->Data->EndU + trail->Data->Usize;
01293 vert[0].tv = trail->Data->EndV;
01294
01295 vert[1].tu = trail->Data->EndU + trail->Data->Usize;
01296 vert[1].tv = trail->Data->EndV + trail->Data->Vsize;
01297
01298 vert[2].tu = trail->Data->EndU;
01299 vert[2].tv = trail->Data->EndV + trail->Data->Vsize;
01300 }
01301
01302
01303 D3Ddevice->DrawPrimitive(D3DPT_TRIANGLEFAN, FVF_TEX1, poly.Verts, poly.VertNum, poly.DrawFlag);
01304
01305
01306 ePos.sx = sPos.sx;
01307 ePos.sy = sPos.sy;
01308 ePos.sz = sPos.sz;
01309 ePos.rhw = sPos.rhw;
01310
01311 vert[2].sx = vert[1].sx;
01312 vert[2].sy = vert[1].sy;
01313 vert[2].sz = vert[1].sz;
01314 vert[2].rhw = vert[1].rhw;
01315 vert[3].sx = vert[0].sx;
01316 vert[3].sy = vert[0].sy;
01317 vert[3].sz = vert[0].sz;
01318 vert[3].rhw = vert[0].rhw;
01319
01320
01321 thisTrail = lastTrail;
01322 if (--lastTrail < 0) lastTrail = trail->MaxTrails - 1;
01323
01324 }
01325 }
01326
01327 void DrawSparks()
01328 {
01329 int iSpark;
01330 long per, semi;
01331 MAT mat;
01332 FACING_POLY poly, *sparkPoly;
01333 SPARK *spark;
01334
01335 ALPHA_ON();
01336 ALPHA_SRC(D3DBLEND_ONE);
01337 ALPHA_DEST(D3DBLEND_ONE);
01338
01339 ZWRITE_OFF();
01340
01341
01342
01343 for (iSpark = 0; iSpark < MAX_SPARKS; iSpark++) {
01344 if (!Sparks[iSpark].Free) {
01345 spark = &Sparks[iSpark];
01346 sparkPoly = &spark->Data->FacingPoly;
01347
01348
01349 if (CamVisiMask & spark->VisiMask) continue;
01350
01351
01352 poly.Tpage = sparkPoly->Tpage;
01353 poly.Xsize = sparkPoly->Xsize;
01354 poly.Ysize = sparkPoly->Ysize;
01355 poly.U = sparkPoly->U;
01356 poly.V = sparkPoly->V;
01357 poly.Usize = sparkPoly->Usize;
01358 poly.Vsize = sparkPoly->Vsize;
01359
01360 poly.RGB = sparkPoly->RGB;
01361
01362
01363 poly.Xsize += spark->Grow;
01364 poly.Ysize += spark->Grow;
01365 if (poly.Xsize < 0.0f) {
01366 continue;
01367 }
01368 if (poly.Ysize < 0.0f) {
01369 continue;
01370 }
01371
01372
01373 if (spark->Data->SparkType & SPARK_SEMI) {
01374 semi = 0;
01375 per = (100 * (spark->Data->LifeTime - spark->Age)) / spark->Data->LifeTime;
01376 ModelChangeGouraud((MODEL_RGB*)&poly.RGB, per);
01377 ALPHA_ON();
01378 ZWRITE_OFF();
01379 } else {
01380 semi = -1;
01381 ALPHA_OFF();
01382 ZWRITE_ON();
01383 }
01384
01385
01386 if (spark->Data->SparkType & SPARK_SPINS) {
01387 RotationZ(&mat, spark->Spin);
01388 DrawFacingPolyRot(&Sparks[iSpark].Pos, &mat, &poly, -1, 0);
01389 } else {
01390 DrawFacingPoly(&Sparks[iSpark].Pos, &poly, -1, 0);
01391 }
01392
01393 }
01394 }
01395 }
01396
01398
01399
01400
01402
01403 void DrawTrails()
01404 {
01405 int iTrail;
01406
01407 for (iTrail = 0; iTrail < MAX_TRAILS; iTrail++) {
01408 if (SparkTrail[iTrail].Free) continue;
01409
01410 DrawSparkTrail(&SparkTrail[iTrail]);
01411 }
01412 }
01413
01414 #endif
01415
01416
01417
01418 #ifdef _N64
01419
01420 void DrawSparks()
01421 {
01422 int iSpark;
01423 long alpha;
01424
01425
01426 for (iSpark = 0; iSpark < MAX_SPARKS; iSpark++)
01427 {
01428 if (!Sparks[iSpark].Free)
01429 {
01430 alpha = (Sparks[iSpark].Data->Colour & 0xFF) - ((0xff * Sparks[iSpark].Age) / (Sparks[iSpark].Data->LifeTime));
01431 if (alpha < 0) { alpha = 0; }
01432 FME_AddFaceMe(Sparks[iSpark].Data->GfxIdx, Sparks[iSpark].Data->u, Sparks[iSpark].Data->v, Sparks[iSpark].Data->w, Sparks[iSpark].Data->h,
01433 &Sparks[iSpark].Pos, Sparks[iSpark].Data->XSize + Sparks[iSpark].Grow, Sparks[iSpark].Data->YSize + Sparks[iSpark].Grow, Sparks[iSpark].Spin, (Sparks[iSpark].Data->Colour & 0xFFFFFF00) | (alpha & 0xFF), Sparks[iSpark].Data->Flag);
01434 }
01435 }
01436 }
01437 #endif