forked from JACoders/OpenJK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFxUtil.cpp
1420 lines (1211 loc) · 33.2 KB
/
FxUtil.cpp
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
/*
===========================================================================
Copyright (C) 2000 - 2013, Raven Software, Inc.
Copyright (C) 2001 - 2013, Activision, Inc.
Copyright (C) 2013 - 2015, OpenJK contributors
This file is part of the OpenJK source code.
OpenJK is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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, see <http://www.gnu.org/licenses/>.
===========================================================================
*/
#include "common_headers.h"
#if !defined(FX_SCHEDULER_H_INC)
#include "FxScheduler.h"
#endif
vec3_t WHITE = {1.0f, 1.0f, 1.0f};
struct SEffectList
{
CEffect *mEffect;
int mKillTime;
bool mPortal;
};
#define PI 3.14159f
SEffectList effectList[MAX_EFFECTS];
SEffectList *nextValidEffect;
SFxHelper theFxHelper;
int activeFx = 0;
int mMax = 0;
int mMaxTime = 0;
int drawnFx;
int mParticles;
int mOParticles;
int mLines;
int mTails;
qboolean fxInitialized = qfalse;
//-------------------------
// FX_Free
//
// Frees all FX
//-------------------------
bool FX_Free( void )
{
for ( int i = 0; i < MAX_EFFECTS; i++ )
{
if ( effectList[i].mEffect )
{
delete effectList[i].mEffect;
}
effectList[i].mEffect = 0;
}
activeFx = 0;
theFxScheduler.Clean();
return true;
}
//-------------------------
// FX_Stop
//
// Frees all active FX but leaves the templates
//-------------------------
void FX_Stop( void )
{
for ( int i = 0; i < MAX_EFFECTS; i++ )
{
if ( effectList[i].mEffect )
{
delete effectList[i].mEffect;
}
effectList[i].mEffect = 0;
}
activeFx = 0;
theFxScheduler.Clean(false);
}
//-------------------------
// FX_Init
//
// Preps system for use
//-------------------------
int FX_Init( void )
{
if ( fxInitialized == qfalse )
{
fxInitialized = qtrue;
for ( int i = 0; i < MAX_EFFECTS; i++ )
{
effectList[i].mEffect = 0;
}
}
FX_Free();
mMax = 0;
mMaxTime = 0;
nextValidEffect = &effectList[0];
theFxHelper.Init();
// ( nothing to see here, go away )
//
extern void FX_CopeWithAnyLoadedSaveGames();
FX_CopeWithAnyLoadedSaveGames();
return true;
}
//-------------------------
// FX_FreeMember
//-------------------------
static void FX_FreeMember( SEffectList *obj )
{
obj->mEffect->Die();
delete obj->mEffect;
obj->mEffect = 0;
// May as well mark this to be used next
nextValidEffect = obj;
activeFx--;
}
//-------------------------
// FX_GetValidEffect
//
// Finds an unused effect slot
//
// Note - in the editor, this function may return NULL, indicating that all
// effects are being stopped.
//-------------------------
static SEffectList *FX_GetValidEffect()
{
if ( nextValidEffect->mEffect == 0 )
{
return nextValidEffect;
}
int i;
SEffectList *ef;
// Blah..plow through the list till we find something that is currently untainted
for ( i = 0, ef = effectList; i < MAX_EFFECTS; i++, ef++ )
{
if ( ef->mEffect == 0 )
{
return ef;
}
}
// report the error.
#ifndef FINAL_BUILD
theFxHelper.Print( "FX system out of effects\n" );
#endif
// Hmmm.. just trashing the first effect in the list is a poor approach
FX_FreeMember( &effectList[0] );
// Recursive call
return nextValidEffect;
}
//-------------------------
// FX_ActiveFx
//
// Returns whether these are any active or scheduled effects
//-------------------------
bool FX_ActiveFx(void)
{
return ((activeFx > 0) || (theFxScheduler.NumScheduledFx() > 0));
}
//-------------------------
// FX_Add
//
// Adds all fx to the view
//-------------------------
void FX_Add( bool portal )
{
int i;
SEffectList *ef;
drawnFx = 0;
mParticles = 0;
mOParticles = 0;
mLines = 0;
mTails = 0;
int numFx = activeFx; //but stop when there can't be any more left!
for ( i = 0, ef = effectList; i < MAX_EFFECTS && numFx; i++, ef++ )
{
if ( ef->mEffect != 0)
{
--numFx;
if (portal != ef->mPortal)
{
continue; //this one does not render in this scene
}
// Effect is active
if ( theFxHelper.mTime > ef->mKillTime )
{
// Clean up old effects, calling any death effects as needed
// this flag just has to be cleared otherwise death effects might not happen correctly
ef->mEffect->ClearFlags( FX_KILL_ON_IMPACT );
FX_FreeMember( ef );
}
else
{
if ( ef->mEffect->Update() == false )
{
// We've been marked for death
FX_FreeMember( ef );
continue;
}
}
}
}
if ( fx_debug.integer == 2 && !portal )
{
if (theFxHelper.mFrameTime > 100 || theFxHelper.mFrameTime < 5)
theFxHelper.Print( "theFxHelper.mFrameTime = %i\n", theFxHelper.mFrameTime );
}
if ( fx_debug.integer == 1 && !portal )
{
if ( theFxHelper.mTime > mMaxTime )
{
// decay pretty harshly when we do it
mMax *= 0.9f;
mMaxTime = theFxHelper.mTime + 200; // decay 5 times a second if we haven't set a new max
}
if ( activeFx > mMax )
{
// but we can never be less that the current activeFx count
mMax = activeFx;
mMaxTime = theFxHelper.mTime + 4000; // since we just increased the max, hold it for at least 4 seconds
}
// Particles
if ( mParticles > 500 )
{
theFxHelper.Print( ">Particles ^1%4i ", mParticles );
}
else if ( mParticles > 250 )
{
theFxHelper.Print( ">Particles ^3%4i ", mParticles );
}
else
{
theFxHelper.Print( ">Particles %4i ", mParticles );
}
// Lines
if ( mLines > 500 )
{
theFxHelper.Print( ">Lines ^1%4i\n", mLines );
}
else if ( mLines > 250 )
{
theFxHelper.Print( ">Lines ^3%4i\n", mLines );
}
else
{
theFxHelper.Print( ">Lines %4i\n", mLines );
}
// OParticles
if ( mOParticles > 500 )
{
theFxHelper.Print( ">OParticles ^1%4i ", mOParticles );
}
else if ( mOParticles > 250 )
{
theFxHelper.Print( ">OParticles ^3%4i ", mOParticles );
}
else
{
theFxHelper.Print( ">OParticles %4i ", mOParticles );
}
// Tails
if ( mTails > 400 )
{
theFxHelper.Print( ">Tails ^1%4i\n", mTails );
}
else if ( mTails > 200 )
{
theFxHelper.Print( ">Tails ^3%4i\n", mTails );
}
else
{
theFxHelper.Print( ">Tails %4i\n", mTails );
}
// Active
if ( activeFx > 600 )
{
theFxHelper.Print( ">Active ^1%4i ", activeFx );
}
else if ( activeFx > 400 )
{
theFxHelper.Print( ">Active ^3%4i ", activeFx );
}
else
{
theFxHelper.Print( ">Active %4i ", activeFx );
}
// Drawn
if ( drawnFx > 600 )
{
theFxHelper.Print( ">Drawn ^1%4i ", drawnFx );
}
else if ( drawnFx > 400 )
{
theFxHelper.Print( ">Drawn ^3%4i ", drawnFx );
}
else
{
theFxHelper.Print( ">Drawn %4i ", drawnFx );
}
// Max
if ( mMax > 600 )
{
theFxHelper.Print( ">Max ^1%4i ", mMax );
}
else if ( mMax > 400 )
{
theFxHelper.Print( ">Max ^3%4i ", mMax );
}
else
{
theFxHelper.Print( ">Max %4i ", mMax );
}
// Scheduled
if ( theFxScheduler.NumScheduledFx() > 100 )
{
theFxHelper.Print( ">Scheduled ^1%4i\n", theFxScheduler.NumScheduledFx() );
}
else if ( theFxScheduler.NumScheduledFx() > 50 )
{
theFxHelper.Print( ">Scheduled ^3%4i\n", theFxScheduler.NumScheduledFx() );
}
else
{
theFxHelper.Print( ">Scheduled %4i\n", theFxScheduler.NumScheduledFx() );
}
}
}
//-------------------------
// FX_AddPrimitive
//
// Note - in the editor, this function may change *pEffect to NULL, indicating that
// all effects are being stopped.
//-------------------------
extern bool gEffectsInPortal; //from FXScheduler.cpp so i don't have to pass it in on EVERY FX_ADD*
void FX_AddPrimitive( CEffect **pEffect, int killTime )
{
SEffectList *item = FX_GetValidEffect();
item->mEffect = *pEffect;
item->mKillTime = theFxHelper.mTime + killTime;
item->mPortal = gEffectsInPortal; //global set in AddScheduledEffects
activeFx++;
// Stash these in the primitive so it has easy access to the vals
(*pEffect)->SetTimeStart( theFxHelper.mTime );
(*pEffect)->SetTimeEnd( theFxHelper.mTime + killTime );
}
//-------------------------
// FX_AddParticle
//-------------------------
CParticle *FX_AddParticle( int clientID, const vec3_t org, const vec3_t vel, const vec3_t accel, float gravity,
float size1, float size2, float sizeParm,
float alpha1, float alpha2, float alphaParm,
const vec3_t sRGB, const vec3_t eRGB, float rgbParm,
float rotation, float rotationDelta,
const vec3_t min, const vec3_t max, float elasticity,
int deathID, int impactID,
int killTime, qhandle_t shader, int flags, int modelNum, int boltNum )
{
if ( theFxHelper.mFrameTime < 1 )
{ // disallow adding effects when the system is paused
return 0;
}
CParticle *fx = new CParticle;
if ( fx )
{
if (flags&FX_RELATIVE && clientID>=0)
{
fx->SetOrigin1( NULL );
fx->SetOrgOffset( org );
fx->SetClient( clientID, modelNum, boltNum );
}
else
{
fx->SetOrigin1( org );
}
fx->SetVel( vel );
fx->SetAccel( accel );
fx->SetGravity( gravity );
// RGB----------------
fx->SetRGBStart( sRGB );
fx->SetRGBEnd( eRGB );
if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
{
fx->SetRGBParm( rgbParm * PI * 0.001f );
}
else if ( flags & FX_RGB_PARM_MASK )
{
// rgbParm should be a value from 0-100..
fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
}
// Alpha----------------
fx->SetAlphaStart( alpha1 );
fx->SetAlphaEnd( alpha2 );
if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
{
fx->SetAlphaParm( alphaParm * PI * 0.001f );
}
else if ( flags & FX_ALPHA_PARM_MASK )
{
fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime );
}
// Size----------------
fx->SetSizeStart( size1 );
fx->SetSizeEnd( size2 );
if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
{
fx->SetSizeParm( sizeParm * PI * 0.001f );
}
else if ( flags & FX_SIZE_PARM_MASK )
{
fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime );
}
fx->SetFlags( flags );
fx->SetShader( shader );
fx->SetRotation( rotation );
fx->SetRotationDelta( rotationDelta );
fx->SetElasticity( elasticity );
fx->SetMin( min );
fx->SetMax( max );
fx->SetDeathFxID( deathID );
fx->SetImpactFxID( impactID );
FX_AddPrimitive( (CEffect**)&fx, killTime );
// in the editor, fx may now be NULL
}
return fx;
}
//-------------------------
// FX_AddLine
//-------------------------
CLine *FX_AddLine( int clientID, vec3_t start, vec3_t end, float size1, float size2, float sizeParm,
float alpha1, float alpha2, float alphaParm,
vec3_t sRGB, vec3_t eRGB, float rgbParm,
int killTime, qhandle_t shader, int impactFX_id, int flags, int modelNum, int boltNum )
{
if ( theFxHelper.mFrameTime < 1 )
{ // disallow adding new effects when the system is paused
return 0;
}
CLine *fx = new CLine;
if ( fx )
{
if (flags&FX_RELATIVE && clientID>=0)
{
fx->SetOrigin1( NULL );
fx->SetOrgOffset( start ); //offset from bolt pos
fx->SetVel( end ); //vel is the vector offset from bolt+orgOffset
fx->SetClient( clientID, modelNum, boltNum );
}
else
{
fx->SetOrigin1( start );
fx->SetOrigin2( end );
}
// RGB----------------
fx->SetRGBStart( sRGB );
fx->SetRGBEnd( eRGB );
if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
{
fx->SetRGBParm( rgbParm * PI * 0.001f );
}
else if ( flags & FX_RGB_PARM_MASK )
{
// rgbParm should be a value from 0-100..
fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
}
// Alpha----------------
fx->SetAlphaStart( alpha1 );
fx->SetAlphaEnd( alpha2 );
if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
{
fx->SetAlphaParm( alphaParm * PI * 0.001f );
}
else if ( flags & FX_ALPHA_PARM_MASK )
{
fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime );
}
// Size----------------
fx->SetSizeStart( size1 );
fx->SetSizeEnd( size2 );
if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
{
fx->SetSizeParm( sizeParm * PI * 0.001f );
}
else if ( flags & FX_SIZE_PARM_MASK )
{
fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime );
}
fx->SetShader( shader );
fx->SetFlags( flags );
fx->SetSTScale( 1.0f, 1.0f );
fx->SetImpactFxID( impactFX_id );
FX_AddPrimitive( (CEffect**)&fx, killTime );
// in the editor, fx may now be NULL
}
return fx;
}
//-------------------------
// FX_AddElectricity
//-------------------------
CElectricity *FX_AddElectricity( int clientID, vec3_t start, vec3_t end, float size1, float size2, float sizeParm,
float alpha1, float alpha2, float alphaParm,
vec3_t sRGB, vec3_t eRGB, float rgbParm,
float chaos, int killTime, qhandle_t shader, int flags, int modelNum, int boltNum )
{
if ( theFxHelper.mFrameTime < 1 )
{ // disallow adding new effects when the system is paused
return 0;
}
CElectricity *fx = new CElectricity;
if ( fx )
{
if (flags&FX_RELATIVE && clientID>=0)
{
fx->SetOrigin1( NULL );
fx->SetOrgOffset( start );//offset
fx->SetVel( end ); //vel is the vector offset from bolt+orgOffset
fx->SetClient( clientID, modelNum, boltNum );
}
else
{
fx->SetOrigin1( start );
fx->SetOrigin2( end );
}
// RGB----------------
fx->SetRGBStart( sRGB );
fx->SetRGBEnd( eRGB );
if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
{
fx->SetRGBParm( rgbParm * PI * 0.001f );
}
else if ( flags & FX_RGB_PARM_MASK )
{
// rgbParm should be a value from 0-100..
fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
}
// Alpha----------------
fx->SetAlphaStart( alpha1 );
fx->SetAlphaEnd( alpha2 );
if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
{
fx->SetAlphaParm( alphaParm * PI * 0.001f );
}
else if ( flags & FX_ALPHA_PARM_MASK )
{
fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime );
}
// Size----------------
fx->SetSizeStart( size1 );
fx->SetSizeEnd( size2 );
if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
{
fx->SetSizeParm( sizeParm * PI * 0.001f );
}
else if ( flags & FX_SIZE_PARM_MASK )
{
fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime );
}
fx->SetShader( shader );
fx->SetFlags( flags );
fx->SetChaos( chaos );
fx->SetSTScale( 1.0f, 1.0f );
FX_AddPrimitive( (CEffect**)&fx, killTime );
// in the editor, fx may now be NULL?
if ( fx )
{
fx->Initialize();
}
}
return fx;
}
//-------------------------
// FX_AddTail
//-------------------------
CTail *FX_AddTail( int clientID, vec3_t org, vec3_t vel, vec3_t accel,
float size1, float size2, float sizeParm,
float length1, float length2, float lengthParm,
float alpha1, float alpha2, float alphaParm,
vec3_t sRGB, vec3_t eRGB, float rgbParm,
vec3_t min, vec3_t max, float elasticity,
int deathID, int impactID,
int killTime, qhandle_t shader, int flags, int modelNum, int boltNum )
{
if ( theFxHelper.mFrameTime < 1 )
{ // disallow adding effects when the system is paused
return 0;
}
CTail *fx = new CTail;
if ( fx )
{
if (flags&FX_RELATIVE && clientID>=0)
{
fx->SetOrigin1( NULL );
fx->SetOrgOffset( org );
fx->SetClient( clientID, modelNum, boltNum );
}
else
{
fx->SetOrigin1( org );
}
fx->SetVel( vel );
fx->SetAccel( accel );
// RGB----------------
fx->SetRGBStart( sRGB );
fx->SetRGBEnd( eRGB );
if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
{
fx->SetRGBParm( rgbParm * PI * 0.001f );
}
else if ( flags & FX_RGB_PARM_MASK )
{
// rgbParm should be a value from 0-100..
fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
}
// Alpha----------------
fx->SetAlphaStart( alpha1 );
fx->SetAlphaEnd( alpha2 );
if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
{
fx->SetAlphaParm( alphaParm * PI * 0.001f );
}
else if ( flags & FX_ALPHA_PARM_MASK )
{
fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime );
}
// Size----------------
fx->SetSizeStart( size1 );
fx->SetSizeEnd( size2 );
if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
{
fx->SetSizeParm( sizeParm * PI * 0.001f );
}
else if ( flags & FX_SIZE_PARM_MASK )
{
fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime );
}
// Length----------------
fx->SetLengthStart( length1 );
fx->SetLengthEnd( length2 );
if (( flags & FX_LENGTH_PARM_MASK ) == FX_LENGTH_WAVE )
{
fx->SetLengthParm( lengthParm * PI * 0.001f );
}
else if ( flags & FX_LENGTH_PARM_MASK )
{
fx->SetLengthParm( lengthParm * 0.01f * killTime + theFxHelper.mTime );
}
fx->SetFlags( flags );
fx->SetShader( shader );
fx->SetElasticity( elasticity );
fx->SetMin( min );
fx->SetMax( max );
fx->SetSTScale( 1.0f, 1.0f );
fx->SetDeathFxID( deathID );
fx->SetImpactFxID( impactID );
FX_AddPrimitive( (CEffect**)&fx, killTime );
// in the editor, fx may now be NULL
}
return fx;
}
//-------------------------
// FX_AddCylinder
//-------------------------
CCylinder *FX_AddCylinder( int clientID, vec3_t start, vec3_t normal,
float size1s, float size1e, float sizeParm,
float size2s, float size2e, float size2Parm,
float length1, float length2, float lengthParm,
float alpha1, float alpha2, float alphaParm,
vec3_t rgb1, vec3_t rgb2, float rgbParm,
int killTime, qhandle_t shader, int flags, int modelNum, int boltNum )
{
if ( theFxHelper.mFrameTime < 1 )
{ // disallow adding new effects when the system is paused
return 0;
}
CCylinder *fx = new CCylinder;
if ( fx )
{
if (flags&FX_RELATIVE && clientID>=0)
{
fx->SetOrigin1( NULL );
fx->SetOrgOffset( start );//offset
//NOTE: relative version doesn't ever use normal!
//fx->SetNormal( normal );
fx->SetClient( clientID, modelNum, boltNum );
}
else
{
fx->SetOrigin1( start );
fx->SetNormal( normal );
}
// RGB----------------
fx->SetRGBStart( rgb1 );
fx->SetRGBEnd( rgb2 );
if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
{
fx->SetRGBParm( rgbParm * PI * 0.001f );
}
else if ( flags & FX_RGB_PARM_MASK )
{
// rgbParm should be a value from 0-100..
fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
}
// Size1----------------
fx->SetSizeStart( size1s );
fx->SetSizeEnd( size1e );
if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
{
fx->SetSizeParm( sizeParm * PI * 0.001f );
}
else if ( flags & FX_SIZE_PARM_MASK )
{
fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime );
}
// Size2----------------
fx->SetSize2Start( size2s );
fx->SetSize2End( size2e );
if (( flags & FX_SIZE2_PARM_MASK ) == FX_SIZE2_WAVE )
{
fx->SetSize2Parm( size2Parm * PI * 0.001f );
}
else if ( flags & FX_SIZE2_PARM_MASK )
{
fx->SetSize2Parm( size2Parm * 0.01f * killTime + theFxHelper.mTime );
}
// Length1---------------
fx->SetLengthStart( length1 );
fx->SetLengthEnd( length2 );
if (( flags & FX_LENGTH_PARM_MASK ) == FX_LENGTH_WAVE )
{
fx->SetLengthParm( lengthParm * PI * 0.001f );
}
else if ( flags & FX_LENGTH_PARM_MASK )
{
fx->SetLengthParm( lengthParm * 0.01f * killTime + theFxHelper.mTime );
}
// Alpha----------------
fx->SetAlphaStart( alpha1 );
fx->SetAlphaEnd( alpha2 );
if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
{
fx->SetAlphaParm( alphaParm * PI * 0.001f );
}
else if ( flags & FX_ALPHA_PARM_MASK )
{
fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime );
}
fx->SetShader( shader );
fx->SetFlags( flags );
FX_AddPrimitive( (CEffect**)&fx, killTime );
}
return fx;
}
//-------------------------
// FX_AddEmitter
//-------------------------
CEmitter *FX_AddEmitter( vec3_t org, vec3_t vel, vec3_t accel,
float size1, float size2, float sizeParm,
float alpha1, float alpha2, float alphaParm,
vec3_t rgb1, vec3_t rgb2, float rgbParm,
vec3_t angs, vec3_t deltaAngs,
vec3_t min, vec3_t max, float elasticity,
int deathID, int impactID, int emitterID,
float density, float variance,
int killTime, qhandle_t model, int flags )
{
if ( theFxHelper.mFrameTime < 1 )
{ // disallow adding effects when the system is paused
return 0;
}
CEmitter *fx = new CEmitter;
if ( fx )
{
fx->SetOrigin1( org );
fx->SetVel( vel );
fx->SetAccel( accel );
// RGB----------------
fx->SetRGBStart( rgb1 );
fx->SetRGBEnd( rgb2 );
if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
{
fx->SetRGBParm( rgbParm * PI * 0.001f );
}
else if ( flags & FX_RGB_PARM_MASK )
{
// rgbParm should be a value from 0-100..
fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
}
// Size----------------
fx->SetSizeStart( size1 );
fx->SetSizeEnd( size2 );
if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
{
fx->SetSizeParm( sizeParm * PI * 0.001f );
}
else if ( flags & FX_SIZE_PARM_MASK )
{
fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime );
}
// Alpha----------------
fx->SetAlphaStart( alpha1 );
fx->SetAlphaEnd( alpha2 );
if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
{
fx->SetAlphaParm( alphaParm * PI * 0.001f );
}
else if ( flags & FX_ALPHA_PARM_MASK )
{
fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime );
}
fx->SetAngles( angs );
fx->SetAngleDelta( deltaAngs );
fx->SetFlags( flags );
fx->SetModel( model );
fx->SetElasticity( elasticity );
fx->SetMin( min );
fx->SetMax( max );
fx->SetDeathFxID( deathID );
fx->SetImpactFxID( impactID );
fx->SetEmitterFxID( emitterID );
fx->SetDensity( density );
fx->SetVariance( variance );
fx->SetOldTime( theFxHelper.mTime );
fx->SetLastOrg( org );
fx->SetLastVel( vel );
FX_AddPrimitive( (CEffect**)&fx, killTime );
// in the editor, fx may now be NULL
}
return fx;
}
//-------------------------
// FX_AddLight
//-------------------------
CLight *FX_AddLight( vec3_t org, float size1, float size2, float sizeParm,
vec3_t rgb1, vec3_t rgb2, float rgbParm,
int killTime, int flags )
{
if ( theFxHelper.mFrameTime < 1 )
{ // disallow adding effects when the system is paused
return 0;
}
CLight *fx = new CLight;
if ( fx )
{
fx->SetOrigin1( org );
// RGB----------------
fx->SetRGBStart( rgb1 );
fx->SetRGBEnd( rgb2 );
if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
{
fx->SetRGBParm( rgbParm * PI * 0.001f );
}
else if ( flags & FX_RGB_PARM_MASK )
{
// rgbParm should be a value from 0-100..
fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
}
// Size----------------
fx->SetSizeStart( size1 );