forked from SpiritQuaddicted/reQuiem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gl_part_H2.c
1446 lines (1255 loc) · 29.9 KB
/
gl_part_H2.c
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "quakedef.h"
#ifdef HEXEN2_SUPPORT
#define SFL_FLUFFY 1 // All largish flakes
#define SFL_MIXED 2 // Mixed flakes
#define SFL_HALF_BRIGHT 4 // All flakes start darker
#define SFL_NO_MELT 8 // Flakes don't melt when his surface, just go away
#define SFL_IN_BOUNDS 16 // Flakes cannot leave the bounds of their box
#define SFL_NO_TRANS 32 // All flakes start non-translucent
extern unsigned d_8to24TranslucentTable[256];
extern vec3_t r_pright, r_pup;
extern particle_t *active_particles, *free_particles;
extern int particletexture_H2;
extern particle_t *AllocParticle (float lifetime);
int ramp1_H2[8] = { 416,416+2,416+4,416+6,416+8,416+10,416+12,416+14};
int ramp2_H2[8] = { 384+4,384+6,384+8,384+10,384+12,384+13,384+14,384+15};
extern int ramp3[8]; // same as Quake
int ramp4_H2[16] = { 416,416+1,416+2,416+3,416+4,416+5,416+6,416+7,416+8,416+9,416+10,416+11,416+12,416+13,416+14,416+15};
int ramp5_H2[16] = { 400,400+1,400+2,400+3,400+4,400+5,400+6,400+7,400+8,400+9,400+10,400+11,400+12,400+13,400+14,400+15};
int ramp6_H2[16] = { 256,256+1,256+2,256+3,256+4,256+5,256+6,256+7,256+8,256+9,256+10,256+11,256+12,256+13,256+14,256+15};
int ramp7_H2[16] = { 384,384+1,384+2,384+3,384+4,384+5,384+6,384+7,384+8,384+9,384+10,384+11,384+12,384+13,384+14,384+15};
int ramp8_H2[16] = {175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 13, 14, 15, 16, 17, 18};
int ramp9_H2[16] = { 416,416+1,416+2,416+3,416+4,416+5,416+6,416+7,416+8,416+9,416+10,416+11,416+12,416+13,416+14,416+15};
int ramp10_H2[16] = { 432,432+1,432+2,432+3,432+4,432+5,432+6,432+7,432+8,432+9,432+10,432+11,432+12,432+13,432+14,432+15};
int ramp11_H2[8] = { 424,424+1,424+2,424+3,424+4,424+5,424+6,424+7};
int ramp12_H2[8] = { 136,137,138,139,140,141,142,143};
static vec3_t rider_origin;
/*
byte dottexture[8][8] =
{
{0,1,1,0,0,0,0,0},
{1,1,1,1,0,0,0,0},
{1,1,1,1,0,0,0,0},
{0,1,1,0,0,0,0,0},
{0,0,0,0,1,0,0,0},
{0,0,0,0,1,0,0,1},
{0,0,0,0,0,0,1,0},
{0,0,0,1,0,0,0,1},
};
*/
byte dottexture[16][16] =
{
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},//1
{0,0,0,1,0,1,0,0,0,0,0,0,1,1,0,0},
{0,0,0,0,1,0,0,0,0,0,0,1,1,1,1,0},
{0,1,0,1,1,1,0,1,0,0,0,1,1,1,1,0},//4
{0,0,1,1,1,1,1,0,0,0,0,0,1,1,0,0},
{0,1,0,1,1,1,0,1,0,0,0,0,0,0,0,0},
{0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0},//8
{0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0},
{0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0},
{0,0,0,0,0,0,0,0,1,1,0,1,1,0,1,0},
{0,0,0,1,0,0,0,0,1,1,1,1,1,0,1,0},//12
{0,1,1,1,0,0,0,0,1,1,0,1,1,0,1,0},
{0,0,1,1,1,0,0,0,0,1,1,1,0,1,0,0},
{0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},//16
};
int particletexture_H2; // little dot for particles
void Hexen2_LoadParticleTexture (void)
{
int x, y;
unsigned int data[16][16];
particletexture_H2 = texture_extension_number++;
GL_Bind (particletexture_H2);
for (x=0 ; x<16 ; x++)
{
for (y=0 ; y<16 ; y++)
{
data[y][x] = 0x00FFFFFF | ((unsigned int)(dottexture[x][y]*255) << 24);
}
}
glTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
/*
===============
R_DarkFieldParticles
===============
*/
void R_DarkFieldParticles (entity_t *ent)
{
int i, j, k;
particle_t *p;
float vel;
vec3_t dir;
vec3_t org;
org[0] = ent->origin[0];
org[1] = ent->origin[1];
org[2] = ent->origin[2];
for (i=-16 ; i<16 ; i+=8)
{
for (j=-16 ; j<16 ; j+=8)
{
for (k=0 ; k<32 ; k+=8)
{
p = AllocParticle (0.2 + (rand()&7) * 0.02);
if (!p)
return;
p->color = 150 + rand()%6;
p->type = pt_slowgrav;
dir[0] = j*8;
dir[1] = i*8;
dir[2] = k*8;
p->org[0] = org[0] + i + (rand()&3);
p->org[1] = org[1] + j + (rand()&3);
p->org[2] = org[2] + k + (rand()&3);
VectorNormalize (dir);
vel = 50 + (rand()&63);
VectorScale (dir, vel, p->vel);
}
}
}
}
/*
===============
R_RunParticleEffect2
===============
*/
void R_RunParticleEffect2 (vec3_t org, vec3_t dmin, vec3_t dmax, int color, ptype_t effect, int count)
{
int i, j;
particle_t *p;
float num;
for (i=0 ; i<count ; i++)
{
p = AllocParticle (2);
if (!p)
return;
// p->die = cl.time + 0.1*(rand()%5);
// p->die = cl.time + 2;//0.1*(rand()%5);
p->color = color;
p->type = effect;
p->ramp = 0;
for (j=0 ; j<3 ; j++)
{
num = rand()*(1.0/RAND_MAX);//(rand ()&0x7fff) / ((float)0x7fff);
p->org[j] = org[j] + ((rand()&8)-4); //added randomness to org
p->vel[j] = dmin[j] + ((dmax[j] - dmin[j]) * num);
}
}
}
/*
===============
R_RunParticleEffect3
===============
*/
void R_RunParticleEffect3 (vec3_t org, vec3_t box, int color, ptype_t effect, int count)
{
int i, j;
particle_t *p;
float num;
for (i=0 ; i<count ; i++)
{
p = AllocParticle (2);
if (!p)
return;
// p->die = cl.time + 0.1*(rand()%5);
// p->die = cl.time + 2;//0.1*(rand()%5);
p->color = color;
p->type = effect;
p->ramp = 0;
for (j=0 ; j<3 ; j++)
{
num = rand()*(1.0/RAND_MAX);//(rand ()&0x7fff) / ((float)0x7fff);
p->org[j] = org[j] + ((rand()&15)-8);
p->vel[j] = (box[j] * num * 2) - box[j];
}
}
}
/*
===============
R_RunParticleEffect4
===============
*/
void R_RunParticleEffect4 (vec3_t org, float radius, int color, ptype_t effect, int count)
{
int i, j;
particle_t *p;
float num;
for (i=0 ; i<count ; i++)
{
p = AllocParticle (2);
if (!p)
return;
// p->die = cl.time + 0.1*(rand()%5);
// p->die = cl.time + 2;//0.1*(rand()%5);
p->color = color;
p->type = effect;
p->ramp = 0;
for (j=0 ; j<3 ; j++)
{
num = rand()*(1.0/RAND_MAX);//(rand ()&0x7fff) / ((float)0x7fff);
p->org[j] = org[j] + ((rand()&15)-8);
p->vel[j] = (radius * num * 2) - radius;
}
}
}
/*
===============
R_RunQuakeEffect
===============
*/
void R_RunQuakeEffect (vec3_t org, float distance)
{
int i;
particle_t *p;
float num,num2;
for (i=0 ; i<100 ; i++)
{
p = AllocParticle (0.3*(rand()%5));
if (!p)
return;
p->color = (rand() &3) + ((rand() % 3)*16) + (13 * 16) + 256 + 11;
p->type = pt_quake;
p->ramp = 0;
num = rand()*(1.0/RAND_MAX);//(rand ()&0x7fff) / ((float)0x7fff);
num2 = distance * num;
num = rand()*(1.0/RAND_MAX);//(rand ()&0x7fff) / ((float)0x7fff);
p->org[0] = org[0] + cos(num * 2 * M_PI)*num2;
p->org[1] = org[1] + sin(num * 2 * M_PI)*num2;
num = rand()*(1.0/RAND_MAX);//(rand ()&0x7fff) / ((float)0x7fff);
p->org[2] = org[2] + 15*num;
p->org[2] = org[2];
num = rand()*(1.0/RAND_MAX);//(rand ()&0x7fff) / ((float)0x7fff);
p->vel[0] = (num * 40) - 20;
num = rand()*(1.0/RAND_MAX);//(rand ()&0x7fff) / ((float)0x7fff);
p->vel[1] = (num * 40) - 20;
num = rand()*(1.0/RAND_MAX);//(rand ()&0x7fff) / ((float)0x7fff);
p->vel[2] = 65*num + 80;
}
}
/*
===============
R_SunStaffTrail
===============
*/
void R_SunStaffTrail(vec3_t source, vec3_t dest)
{
int i;
vec3_t vec, dist;
float length, size;
particle_t *p;
VectorSubtract(dest, source, vec);
length = VectorNormalize(vec);
dist[0] = vec[0];
dist[1] = vec[1];
dist[2] = vec[2];
size = 10;
while(length > 0)
{
length -= size;
p = AllocParticle (2);
if (!p)
return;
p->ramp = rand()&3;
p->color = ramp6_H2[(int)(p->ramp)];
p->type = pt_spit;
for(i = 0; i < 3; i++)
{
p->org[i] = source[i] + ((rand()&3)-2);
}
p->vel[0] = (rand()%10)-5;
p->vel[1] = (rand()%10)-5;
p->vel[2] = (rand()%10);
VectorAdd(source, dist, source);
}
}
/*
===============
R_RiderParticle
===============
*/
void R_RiderParticle(int count, vec3_t origin)
{
int i;
particle_t *p;
float radius, angle;
VectorCopy(origin, rider_origin);
for (i=0 ; i<count ; i++)
{
p = AllocParticle (4);
if (!p)
return;
p->color = 256+16+15;
p->type = pt_rd;
p->ramp = 0;
VectorCopy(origin,p->org);
//num = (rand ()&0x7fff) / ((float)0x7fff);
angle = (rand() % 360) / (2 * M_PI);
radius = 300 + (rand() & 255);
p->org[0] += sin(angle) * radius;
p->org[1] += cos(angle) * radius;
p->org[2] += (rand() & 255) - 30;
p->vel[0] = (rand() & 255) - 127;
p->vel[1] = (rand() & 255) - 127;
p->vel[2] = (rand() & 255) - 127;
}
}
/*
===============
R_GravityWellParticle
===============
*/
void R_GravityWellParticle(int count, vec3_t origin, int color)
{
int i;
particle_t *p;
float radius,angle;
VectorCopy(origin, rider_origin);
for (i=0 ; i<count ; i++)
{
p = AllocParticle (4);
if (!p)
return;
p->color = color + (rand() & 15);
p->type = pt_gravwell;
p->ramp = 0;
VectorCopy(origin,p->org);
angle = (rand() % 360) / (2 * M_PI);
radius = 300 + (rand() & 255);
p->org[0] += sin(angle) * radius;
p->org[1] += cos(angle) * radius;
p->org[2] += (rand() & 255) - 30;
p->vel[0] = (rand() & 255) - 127;
p->vel[1] = (rand() & 255) - 127;
p->vel[2] = (rand() & 255) - 127;
}
}
/*
===============
Hexen2_RocketTrail
===============
*/
void Hexen2_RocketTrail (vec3_t start, vec3_t end, int type)
{
vec3_t vec, dist;
float len,size,lifetime;
int j;
particle_t *p;
static int tracercount;
VectorSubtract (end, start, vec);
len = VectorNormalize (vec);
VectorCopy(vec, dist);
lifetime = 2;
switch (type)
{
case SPIT_TRAIL:
size = 1;
break;
case ICE_TRAIL:
size = 5*3;
dist[0] *= 5*3;
dist[1] *= 5*3;
dist[2] *= 5*3;
break;
case ACID_TRAIL:
size = 5;
lifetime = 0.8;
break;
default:
size = 3;
dist[0] *= 3;
dist[1] *= 3;
dist[2] *= 3;
break;
}
while (len > 0)
{
len -= size;
p = AllocParticle (lifetime);
if (!p)
return;
VectorCopy (vec3_origin, p->vel);
switch (type)
{
case ROCKET_TRAIL:
p->ramp = (rand()&3);
p->color = ramp3[(int)p->ramp];
p->type = pt_fire;
for (j=0 ; j<3 ; j++)
p->org[j] = start[j] + ((rand()%6)-3);
break;
case GRENADE_TRAIL: // smoke smoke
p->ramp = (rand()&3) + 2;
p->color = ramp3[(int)p->ramp];
p->type = pt_fire;
for (j=0 ; j<3 ; j++)
p->org[j] = start[j] + ((rand()%6)-3);
break;
case BLOOD_TRAIL:
p->type = pt_slowgrav;
p->color = 134 + (rand()&7);
for (j=0 ; j<3 ; j++)
p->org[j] = start[j] + ((rand()%6)-3);
break;
case TRACER1_TRAIL:
case TRACER2_TRAIL:
p->endtime = cl.time + 0.5;
p->type = pt_static;
if (type == TRACER1_TRAIL)
p->color = 130 + (rand() & 6);
// p->color = 243 + (rand() & 3);
else
p->color = 230 + ((tracercount&4)<<1);
tracercount++;
VectorCopy (start, p->org);
if (tracercount & 1)
{
p->vel[0] = 30*vec[1];
p->vel[1] = 30*-vec[0];
}
else
{
p->vel[0] = 30*-vec[1];
p->vel[1] = 30*vec[0];
}
break;
case SLIGHT_BLOOD_TRAIL:
p->type = pt_slowgrav;
p->color = 134 + (rand()&7);
for (j=0 ; j<3 ; j++)
p->org[j] = start[j] + ((rand()%6)-3);
len -= size;
break;
case BLOODSHOT_TRAIL:// bloodshot trail
p->type = pt_darken;
p->color = 136 + (rand()&5);
for (j=0 ; j<3 ; j++)
p->org[j] = start[j] + ((rand()&3)-2);
len -= size;
break;
case VOOR_TRAIL:
p->color = 9*16 + 8 + (rand()&3);
p->type = pt_static;
p->endtime = cl.time + 0.3;
for (j=0 ; j<3 ; j++)
p->org[j] = start[j] + ((rand()&15)-8);
break;
case LAVA_TRAIL:
p->ramp = rand()&3;
p->color = ramp4_H2[(int)(p->ramp)];
p->type = pt_fireball;
for (j=0 ; j<3 ; j++)
p->org[j] = start[j] + ((rand()&3)-2);
p->org[2] += 2; // compensate for model
p->vel[0] = (rand() % 200) - 100;
p->vel[1] = (rand() % 200) - 100;
p->vel[2] = (rand() % 200) - 100;
break;
case ACID_TRAIL: // Acid ball
p->ramp = rand()&3;
p->color = ramp10_H2[(int)(p->ramp)];
p->type = pt_acidball;
p->endtime = cl.time + 0.5;
for (j=0 ; j<3 ; j++)
p->org[j] = start[j] + ((rand()&3)-2);
p->org[2] += 2; // compensate for model
p->vel[0] = (rand() % 40) - 20;
p->vel[1] = (rand() % 40) - 20;
p->vel[2] = (rand() % 40) - 20;
break;
case ICE_TRAIL: // Ice
p->ramp = rand()&3;
p->color = ramp5_H2[(int)(p->ramp)];
p->type = pt_ice;
for (j=0 ; j<3 ; j++)
p->org[j] = start[j] + ((rand()&3)-2);
p->org[2] += 2; // compensate for model
p->vel[0] = (rand() % 16) - 8;
p->vel[1] = (rand() % 16) - 8;
p->vel[2] = (rand() % 20) - 40;
break;
case SPIT_TRAIL: // Spit
p->ramp = rand()&3;
p->color = ramp6_H2[(int)(p->ramp)];
p->type = pt_spit;
for (j=0 ; j<3 ; j++)
p->org[j] = start[j] + ((rand()&3)-2);
p->org[2] += 2; // compensate for model
p->vel[0] = (rand() % 10) - 5;
p->vel[1] = (rand() % 10) - 5;
p->vel[2] = (rand() % 10);
break;
case SPELL_TRAIL: // Spell
p->ramp = rand()&3;
p->color = ramp6_H2[(int)(p->ramp)];
p->type = pt_spell;
for (j=0 ; j<3 ; j++)
p->org[j] = start[j] + ((rand()&3)-2);
p->vel[0] = (rand() % 10) - 5;
p->vel[1] = (rand() % 10) - 5;
p->vel[2] = (rand() % 10);
p->vel[0] = vec[0]*-10;
p->vel[1] = vec[1]*-10;
p->vel[2] = vec[2]*-10;
break;
case VORPAL_TRAIL: // vorpal missile
p->type = pt_vorpal;
p->color = 44 + (rand()&3) + 256;
for (j=0 ; j<2 ; j++)
p->org[j] = start[j] + ((rand()%48)-24);
p->org[2] = start[2] + ((rand()&15)-8);
break;
case STAFF_TRAIL: // set staff
p->type = pt_setstaff;
p->color = ramp9_H2[0];
p->ramp = rand()&3;
for (j=0 ; j<2 ; j++)
p->org[j] = start[j] + ((rand()%6)-3);
p->org[2] = start[2] + ((rand()%10)-5);
p->vel[0] = (rand() &7) - 4;
p->vel[1] = (rand() &7) - 4;
break;
case MAGICMISSILE_TRAIL: // magic missile
p->type = pt_magicmissile;
p->color = 148 + (rand()&11);
p->ramp = rand()&3;
for (j=0 ; j<2 ; j++)
p->org[j] = start[j] + ((rand()%48)-24);
p->org[2] = start[2] + ((rand()%48)-24);
p->vel[2] = -((rand()&15)+8);
break;
case BONESHARD_TRAIL: // bone shard
p->type = pt_boneshard;
p->color = 368 + (rand()&16);
for (j=0 ; j<2 ; j++)
p->org[j] = start[j] + ((rand()%48)-24);
p->org[2] = start[2] + ((rand()%48)-24);
p->vel[2] = -((rand()&15)+8);
break;
case SCARAB_TRAIL: // scarab staff
p->type = pt_scarab;
p->color = 250 + (rand()&3);
for (j=0 ; j<3 ; j++)
p->org[j] = start[j] + (rand()&7);
p->vel[2] = -(rand()&7);
break;
}
VectorAdd (start, dist, start);
}
}
/*
===============
R_RainEffect
===============
*/
void R_RainEffect (vec3_t org, vec3_t e_size, int x_dir, int y_dir, int color, int count)
{
int i,holdint;
particle_t *p;
float z_time;
for (i=0 ; i<count ; i++)
{
p = AllocParticle (0);
if (!p)
return;
p->vel[0] = x_dir; //X and Y motion
p->vel[1] = y_dir;
p->vel[2] = -((rand() % 956)) ;
if (p->vel[2] > -256)
{
p->vel[2] += -256;
}
z_time = -(e_size[2]/p->vel[2]);
p->color = color;
p->endtime = cl.time + z_time;
p->ramp = (rand()&3);
//p->veer = veer;
p->type = pt_rain;
holdint=e_size[0];
p->org[0] = org[0] + (rand() % holdint);
holdint=e_size[1];
p->org[1] = org[1] + (rand() % holdint);
p->org[2] = org[2];
}
}
/*
===============
R_SnowEffect
===============
*/
void R_SnowEffect (vec3_t org1, vec3_t org2, int flags, vec3_t alldir, int count)
{
int i,j,holdint;
particle_t *p;
mleaf_t *l;
count *= Cvar_VariableValue("snow_active");
for (i=0 ; i<count ; i++)
{
p = AllocParticle (7);
if (!p)
return;
p->vel[0] = alldir[0]; //X and Y motion
p->vel[1] = alldir[1];
p->vel[2] = alldir[2] * ((rand() & 15) + 7)/10;
p->flags = flags;
if ((rand() & 0x7f) <= 1)//have a console variable 'happy_snow' that makes all snowflakes happy snow!
p->count = 69; //happy snow!
else if ((flags & SFL_FLUFFY) || ((flags & SFL_MIXED) && (rand() & 3)))
p->count = (rand() & 31) + 10;//From 10 to 41 scale, will be divided
else
p->count = 10;
if (flags & SFL_HALF_BRIGHT)//Start darker
p->color = 26 + (rand() % 5);
else
p->color = 18 + (rand() % 12);
if (!(flags & SFL_NO_TRANS))//Start translucent
p->color += 256;
p->ramp = (rand()&3);
//p->veer = veer;
p->type = pt_snow;
holdint=org2[0] - org1[0];
p->org[0] = org1[0] + (rand() % holdint);
holdint=org2[1] - org1[1];
p->org[1] = org1[1] + (rand() % holdint);
p->org[2] = org2[2];
j=50;
l = Mod_PointInLeaf (p->org, cl.worldmodel);
while ((l->contents != CONTENTS_EMPTY) && j)
{//Make sure it doesn't start in a solid
holdint = org2[0] - org1[0];
p->org[0] = org1[0] + (rand() % holdint);
holdint = org2[1] - org1[1];
p->org[1] = org1[1] + (rand() % holdint);
j--;//No infinite loops
l = Mod_PointInLeaf (p->org, cl.worldmodel);
}
if (l->contents != CONTENTS_EMPTY)
Sys_Error ("Snow entity top plane is not in an empty area (sorry!)");
VectorCopy(org1, p->min_org);
VectorCopy(org2, p->max_org);
}
}
/*
===============
R_ColoredParticleExplosion
===============
*/
void R_ColoredParticleExplosion (vec3_t org, int color, int radius, int counter)
{
int i, j;
particle_t *p;
for (i=0 ; i<counter ; i++)
{
p = AllocParticle (3);
if (!p)
return;
p->color = color;
p->ramp = (rand()&3);
if (i & 1)
{
p->type = pt_c_explode;
for (j=0 ; j<3 ; j++)
{
p->org[j] = org[j] + ((rand()%(radius*2))-radius);
p->vel[j] = (rand()&511)-256;
}
}
else
{
p->type = pt_c_explode2;
for (j=0 ; j<3 ; j++)
{
p->org[j] = org[j] + ((rand()%(radius*2))-radius);
p->vel[j] = (rand()&511)-256;
}
}
}
}
/*
===============
Hexen2_DrawParticles
===============
*/
void Hexen2_DrawParticles (void)
{
particle_t *p, *kill;
float scale;
GL_Bind(particletexture_H2);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (!gl_solidparticles.value)
glDepthMask (GL_FALSE);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBegin (GL_TRIANGLES);
VectorScale (vup, 1.5, r_pup);
VectorScale (vright, 1.5, r_pright);
for ( ;; )
{
kill = active_particles;
if (kill && PARTICLE_INACTIVE(kill))
{
active_particles = kill->next;
kill->next = free_particles;
free_particles = kill;
continue;
}
break;
}
for (p=active_particles ; p ; p=p->next)
{
for ( ;; )
{
kill = p->next;
if (kill && PARTICLE_INACTIVE(kill))
{
p->next = kill->next;
kill->next = free_particles;
free_particles = kill;
continue;
}
break;
}
if (p->type==pt_rain)
{
// hack a scale up to keep particles from disapearing
scale = (p->org[0] - r_origin[0])*vpn[0] + (p->org[1] - r_origin[1])*vpn[1]
+ (p->org[2] - r_origin[2])*vpn[2];
if (scale < 20)
scale = 1;
else
scale = 1 + scale * 0.004;
if (p->color <= 255)
glColor3ubv ((byte *)&d_8to24table[(int)p->color]);
else
glColor4ubv ((byte *)&d_8to24TranslucentTable[(int)p->color-256]);
//fixme: need rain texture
glTexCoord2f (1,0);
glVertex3fv (p->org);
glTexCoord2f (1,0.5);
glVertex3f (p->org[0] + r_pup[0]*scale, p->org[1] + r_pup[1]*scale, p->org[2] + r_pup[2]*scale);
glTexCoord2f (0.5,0);
glVertex3f (p->org[0] + r_pright[0]*scale, p->org[1] + r_pright[1]*scale, p->org[2] + r_pright[2]*scale);
}
else if (p->type==pt_snow)
{
//IDEA: Put a snowflake texture on two-sided poly
scale = (p->org[0] - r_origin[0])*vpn[0] + (p->org[1] - r_origin[1])*vpn[1]
+ (p->org[2] - r_origin[2])*vpn[2];
if (scale < 20)
scale = p->count/10;
else
scale = p->count/10 + scale * 0.004;
if (p->color <= 255)
glColor3ubv ((byte *)&d_8to24table[(int)p->color]);
else
glColor4ubv ((byte *)&d_8to24TranslucentTable[(int)p->color-256]);
if(p->count>=69)
glTexCoord2f (1,1);//happy snow!- bottom right
else if(p->count>=40)
glTexCoord2f (0,0); //normal snow - top left
else if(p->count>=30)
glTexCoord2f (0,1); //bottom left
else
glTexCoord2f (1,0); //top right
glVertex3fv (p->org);
if(p->count>=69)
glTexCoord2f (1,.18);//top right
else if(p->count>=40)
glTexCoord2f (.815,0);//top right
else if(p->count>=30)
glTexCoord2f (0.5,1);//bottom middle
else
glTexCoord2f (1,0.5);//middle right
glVertex3f (p->org[0] + r_pup[0]*scale, p->org[1] + r_pup[1]*scale, p->org[2] + r_pup[2]*scale);
if(p->count>=69)
glTexCoord2f (.18,1);//bottom left
else if(p->count>=40)
glTexCoord2f (0,.815);//bottom left
else if(p->count>=30)
glTexCoord2f (0,0.5);//left middle
else
glTexCoord2f (0.5,0);//middle top
glVertex3f (p->org[0] + r_pright[0]*scale, p->org[1] + r_pright[1]*scale, p->org[2] + r_pright[2]*scale);
}
else
{
// hack a scale up to keep particles from disapearing
scale = (p->org[0] - r_origin[0])*vpn[0] + (p->org[1] - r_origin[1])*vpn[1]
+ (p->org[2] - r_origin[2])*vpn[2];
if (scale < 20)
scale = 1;
else
scale = 1 + scale * 0.004;
if (p->color <= 255)
glColor3ubv ((byte *)&d_8to24table[(int)p->color]);
else
glColor4ubv ((byte *)&d_8to24TranslucentTable[(int)p->color-256]);
glTexCoord2f (1, 0);
glVertex3fv (p->org);
glTexCoord2f (1, 0.625); // JDH: was (1, 0.5), but corner got clipped
glVertex3f (p->org[0] + r_pup[0]*scale, p->org[1] + r_pup[1]*scale, p->org[2] + r_pup[2]*scale);
glTexCoord2f (0.375, 0); // JDH: was (0.5, 1)
glVertex3f (p->org[0] + r_pright[0]*scale, p->org[1] + r_pright[1]*scale, p->org[2] + r_pright[2]*scale);
}
}
glEnd ();
glDisable (GL_BLEND);
glDepthMask (GL_TRUE);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glColor3f (1, 1, 1);
}
/*
===============
R_UpdateParticles
===============
*/
void R_UpdateParticles (void)
{
particle_t *p, *kill;
float grav,grav2,percent;
int i;
float time2, time3, time4;
float time1;
float dvel;
float frametime;
float vel0, vel1, vel2;
float colindex;
vec3_t diff;
if (cls.state == ca_disconnected)
return;
frametime = cl.time - cl.oldtime;
// Con_Printf("%10.5f\n",frametime);
time4 = frametime * 20;
time3 = frametime * 15;
time2 = frametime * 10;
time1 = frametime * 5;
grav = frametime * sv_gravity.value * 0.05;
grav2 = frametime * sv_gravity.value * 0.025;
dvel = 4*frametime;
percent = (frametime / HX_FRAME_TIME);
for ( ;; )
{
kill = active_particles;
if (kill && PARTICLE_INACTIVE(kill))
{
active_particles = kill->next;
kill->next = free_particles;
free_particles = kill;
continue;
}
break;
}
for (p=active_particles ; p ; p=p->next)
{
for ( ;; )
{
kill = p->next;
if (kill && PARTICLE_INACTIVE(kill))
{
p->next = kill->next;