forked from bfbbdecomp/bfbb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxFX.cpp
More file actions
1361 lines (1138 loc) · 33.1 KB
/
xFX.cpp
File metadata and controls
1361 lines (1138 loc) · 33.1 KB
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 "xFX.h"
#include "iFX.h"
#include "iMath.h"
#include "xDebug.h"
#include "xstransvc.h"
#include "xScrFx.h"
#include "zEntPickup.h"
#include "zParEmitter.h"
#include "zSurface.h"
#include "zFX.h"
#include "zGlobals.h"
#include "zRumble.h"
#include <string.h>
#include <rpmatfx.h>
#include <rwplcore.h>
#include <rpskin.h>
// no clue why this file is so out of order
/* boot.HIP texture IDs */
#define ID_gloss_edge 0xB8C2351E
#define ID_rainbowfilm_smooth32 0x741B0566
/* Global variables from .comm segment */
xFXRing ringlist[RING_COUNT];
xFXStreak sStreakList[10];
xFXShine sShineList[2];
RpAtomicCallBackRender gAtomicRenderCallBack = NULL;
RpLight* MainLight = NULL;
F32 EnvMapShininess = 1.0f;
/* End global variables */
static U32 num_fx_atomics = 0;
static U32 xfx_initted = 0;
static void LightResetFrame(RpLight* light);
void xFXInit()
{
if (!xfx_initted)
{
xfx_initted = 1;
RpLight* light = RpLightCreate(rpLIGHTDIRECTIONAL);
if (light)
{
RwFrame* frame = RwFrameCreate();
if (frame)
{
RpLightSetFrame(light, frame);
LightResetFrame(light);
MainLight = light;
}
else
{
RpLightDestroy(light);
}
}
xFXanimUVCreate();
xFXAuraInit();
}
}
static U32 Im3DBufferPos = 0;
static RwTexture* g_txtr_drawRing = NULL;
static xFXBubbleParams defaultBFX = {
// pass1, pass2, pass3, padding
1, 1, 1, 0,
// pass1_alpha, pass2_alpha, pass3_alpha, pass1_fbsk
0, 0, 192, 0xFFFFFFFF,
// fresnel_map, fresnel_map_coeff
ID_gloss_edge, 0.75f,
// env_map, env_map_coeff
ID_rainbowfilm_smooth32, 0.5f
};
static U32 bfx_curr = 0;
static xFXBubbleParams* BFX = &defaultBFX;
static U32 sFresnelMap = 0;
static U32 sEnvMap = 0;
static S32 sTweaked = 0;
static RxPipeline* xFXanimUVPipeline = NULL;
F32 xFXanimUVRotMat0[2] = { 1.0f, 0.0f };
F32 xFXanimUVRotMat1[2] = { 0.0f, 1.0f };
F32 xFXanimUVTrans[2] = { 0.0f, 0.0f };
F32 xFXanimUVScale[2] = { 1.0f, 1.0f };
F32 xFXanimUV2PRotMat0[2] = { 1.0f, 0.0f };
F32 xFXanimUV2PRotMat1[2] = { 0.0f, 1.0f };
F32 xFXanimUV2PTrans[2] = { 0.0f, 0.0f };
F32 xFXanimUV2PScale[2] = { 1.0f, 1.0f };
RwTexture* xFXanimUV2PTexture = NULL;
static void DrawRingSetup()
{
g_txtr_drawRing = (RwTexture*)xSTFindAsset(ID_rainbowfilm_smooth32, NULL);
}
static void DrawRingSceneExit()
{
g_txtr_drawRing = NULL;
}
static void DrawRing(xFXRing* m)
{
// todo: uses int-to-float conversion
}
xFXRing* xFXRingCreate(const xVec3* pos, const xFXRing* params)
{
xFXRing* ring = &ringlist[0];
if (!pos || !params)
{
return NULL;
}
for (S32 i = 0; i < RING_COUNT; i++, ring++)
{
if (ring->time <= 0.0f)
{
// non-matching: 1.0f is only loaded once
memcpy(ring, params, sizeof(xFXRing));
ring->time = 0.001f;
ring->pos = *pos;
ring->ring_radius_delta *= 1.0f / ring->lifetime;
ring->ring_height_delta *= 1.0f / ring->lifetime;
ring->ring_tilt_delta *= 1.0f / ring->lifetime;
return ring;
}
}
return NULL;
}
static void xFXRingUpdate(F32 dt)
{
xFXRing* ring = &ringlist[0];
if ((F32)iabs(dt) < 0.001f)
{
return;
}
for (S32 i = 0; i < RING_COUNT; i++, ring++)
{
if (ring->time <= 0.0f)
{
continue;
}
F32 lifetime = ring->lifetime;
if (lifetime < dt)
{
lifetime = dt;
}
ring->time += dt;
F32 t = ring->time / lifetime;
// non-matching: float scheduling
if (t > 1.0f)
{
ring->time = 0.0f;
if (ring->parent)
{
*ring->parent = NULL;
}
ring->parent = NULL;
}
}
}
void xFXRingRender()
{
S32 i;
xFXRing* ring = &ringlist[0];
for (i = 0; i < RING_COUNT; i++, ring++)
{
if (ring->time > 0.0f)
{
DrawRing(ring);
}
}
}
static RpMaterial* MaterialSetEnvMap(RpMaterial* material, void* data);
static RpMaterial* MaterialSetBumpMap(RpMaterial* material, void* data);
static RpMaterial* MaterialSetBumpEnvMap(RpMaterial* material, RwTexture* env, F32 shininess,
RwTexture* bump, F32 bumpiness);
void xFX_SceneEnter(RpWorld* world)
{
S32 i;
S32 num = RpWorldGetNumMaterials(world);
for (i = 0; i < num; i++)
{
xSurface* sp = zSurfaceGetSurface(i);
zSurfaceProps* pp = (zSurfaceProps*)sp->moprops;
if (pp && pp->asset)
{
zSurfMatFX* fxp = &pp->asset->matfx;
if (fxp->flags)
{
if (fxp->flags == 0x10)
{
fxp->flags |= 0x1;
}
RpMaterial* mp = RpWorldGetMaterial(world, i);
if (RpMaterialGetTexture(mp))
{
gFXSurfaceFlags = fxp->flags;
if (fxp->flags & 0x1)
{
RwTexture* env = (RwTexture*)xSTFindAsset(fxp->envmapID, NULL);
if (!env)
{
continue;
}
MaterialSetEnvMap(mp, env);
RpMatFXMaterialSetEnvMapCoefficient(mp, 0.5f * fxp->shininess);
}
if (fxp->flags & 0x2)
{
RwTexture* bump = (RwTexture*)xSTFindAsset(fxp->bumpmapID, NULL);
if (!bump)
{
continue;
}
MaterialSetBumpMap(mp, bump);
RpMatFXMaterialSetBumpMapCoefficient(mp, fxp->bumpiness);
}
if (fxp->flags & 0x4)
{
RwTexture* env = (RwTexture*)xSTFindAsset(fxp->envmapID, NULL);
RwTexture* bump = (RwTexture*)xSTFindAsset(fxp->bumpmapID, NULL);
if (!env || !bump)
{
continue;
}
MaterialSetBumpEnvMap(mp, env, fxp->shininess, bump, fxp->bumpiness);
}
}
}
}
}
zScene* sc = globals.sceneCur;
for (i = 0; i < sc->num_act_ents; i++)
{
xEnt* ent = sc->act_ents[i];
if (!gAtomicRenderCallBack && ent->model)
{
RpAtomicCallBackRender tmp = RpAtomicGetRenderCallBack(ent->model->Data);
RpAtomicSetRenderCallBack(ent->model->Data, NULL);
gAtomicRenderCallBack = RpAtomicGetRenderCallBack(ent->model->Data);
RpAtomicSetRenderCallBack(ent->model->Data, tmp);
}
if (ent->model)
{
U32 bubble = 0;
bubble |= (ent->id == xStrHash("bubble buddy"));
bubble |= (ent->id == xStrHash("bubble missile"));
bubble |= (ent->id == xStrHash("bubble helmet"));
bubble |= (ent->id == xStrHash("bubble bowling ball"));
bubble |= (ent->id == xStrHash("bubble shoeL"));
bubble |= (ent->id == xStrHash("bubble shoeR"));
if (bubble)
{
xSTAssetName(ent->id);
RpAtomicSetRenderCallBack(ent->model->Data, xFXBubbleRender);
}
}
}
num_fx_atomics = 0;
}
void xFX_SceneExit(RpWorld*)
{
}
void xFXUpdate(F32 dt)
{
xFXRingUpdate(dt);
xFXRibbonUpdate(dt);
xFXAuraUpdate(dt);
}
static const RwV3d _1168 = { 1, 0, 0 };
static const RwV3d _1169 = { 0, 1, 0 };
static void LightResetFrame(RpLight* light)
{
// non-matching: lwzu instruction
RwV3d v1 = { 1, 0, 0 };
RwV3d v2 = { 0, 1, 0 };
RwFrame* frame = RpLightGetFrame(light);
RwFrameRotate(frame, &v1, 45.0f, rwCOMBINEREPLACE);
RwFrameRotate(frame, &v2, 45.0f, rwCOMBINEPOSTCONCAT);
}
static RpMaterial* MaterialDisableMatFX(RpMaterial* material, void*)
{
RpMatFXMaterialSetEffects(material, rpMATFXEFFECTNULL);
return material;
}
RpAtomic* AtomicDisableMatFX(RpAtomic* atomic)
{
RpMatFXAtomicEnableEffects(atomic);
RpGeometry* geometry = RpAtomicGetGeometry(atomic);
if (geometry)
{
RpGeometryForAllMaterials(geometry, MaterialDisableMatFX, NULL);
}
return atomic;
}
static RpAtomic* PreAllocMatFX_cb(RpAtomic* atomic, void*)
{
AtomicDisableMatFX(atomic);
return atomic;
}
void xFXPreAllocMatFX(RpClump* clump)
{
RpClumpForAllAtomics(clump, PreAllocMatFX_cb, NULL);
}
RpMaterial* MaterialSetShininess(RpMaterial* material, void*)
{
RpMatFXMaterialFlags flags = RpMatFXMaterialGetEffects(material);
if (flags == rpMATFXEFFECTENVMAP || flags == rpMATFXEFFECTBUMPENVMAP)
{
RpMatFXMaterialSetEnvMapCoefficient(material, EnvMapShininess);
}
return material;
}
static RpAtomic* AtomicSetShininess(RpAtomic* atomic, void* data)
{
RpGeometry* geometry = RpAtomicGetGeometry(atomic);
if (geometry)
{
RpGeometryForAllMaterials(geometry, MaterialSetShininess, data);
}
return atomic;
}
static RpAtomic* AtomicSetEnvMap(RpAtomic* atomic, void* data)
{
RpMatFXAtomicEnableEffects(atomic);
if (atomic->geometry != 0)
{
RpGeometryForAllMaterials(atomic->geometry, MaterialSetEnvMap2, data);
}
return atomic;
}
RpAtomic* xFXAtomicEnvMapSetup(RpAtomic* atomic, U32 aid, F32 shininess)
{
void* asset = xSTFindAsset(aid, NULL);
if (asset)
{
AtomicSetEnvMap(atomic, asset);
F32 oldShininess = EnvMapShininess;
EnvMapShininess = shininess;
AtomicSetShininess(atomic, NULL);
EnvMapShininess = oldShininess;
RpSkin* skin = RpSkinGeometryGetSkin(atomic->geometry);
if (skin)
{
RpSkinAtomicSetType(atomic, rpSKINTYPEMATFX);
}
return atomic;
}
return NULL;
}
void xFXAuraAdd(void*, xVec3*, iColor_tag*, F32)
{
}
void xFXAuraInit()
{
}
void xFXAuraUpdate(F32)
{
}
U32 xFXanimUVCreate()
{
if (xFXanimUVPipeline == NULL)
{
xFXanimUVPipeline = iFXanimUVCreatePipe();
}
return (-(U32)xFXanimUVPipeline | (U32)xFXanimUVPipeline) >> 0x1f;
}
namespace
{
struct vert_data
{
xVec3 loc;
xVec3 norm;
RwRGBA color;
RwTexCoords uv;
F32 depth;
};
struct tri_data
{
vert_data vert[3];
};
// TODO: Check all lerp return types. Only the first is in dwarf
void lerp(vert_data& v, F32 frac, const vert_data& v0, const vert_data& v1);
void lerp(RwTexCoords& unk0, F32 unk1, const RwTexCoords& unk2, const RwTexCoords& unk3);
F32 lerp(F32& unk0, F32 unk1, F32 unk2, F32 unk3);
void lerp(RwRGBA& unk0, F32 unk1, RwRGBA unk2, RwRGBA unk3);
void lerp(U8& unk0, F32 unk1, U8 unk2, U8 unk3);
void lerp(xVec3& unk0, F32 unk1, const xVec3& unk2, const xVec3& unk3);
void lerp(vert_data& v, F32 frac, const vert_data& v0, const vert_data& v1)
// Yes, These are the actual parameter names for this function from the dwarf
{
lerp(v.loc, frac, v0.loc, v1.loc);
lerp(v.norm, frac, v0.norm, v1.norm);
lerp(v.color, frac, v0.color, v1.color);
lerp(v.uv, frac, v0.uv, v1.uv);
}
void lerp(RwTexCoords& unk0, F32 unk1, const RwTexCoords& unk2, const RwTexCoords& unk3)
{
lerp(unk0.u, unk1, unk2.u, unk3.u);
lerp(unk0.v, unk1, unk2.v, unk3.v);
}
F32 lerp(F32& unk0, F32 unk1, F32 unk2, F32 unk3)
{
return (unk0 = unk2 + (unk3 - unk2) * unk1);
}
void lerp(RwRGBA& unk0, F32 unk1, RwRGBA unk2, RwRGBA unk3)
{
lerp(unk0.red, unk1, unk2.red, unk3.red);
lerp(unk0.green, unk1, unk2.green, unk3.green);
lerp(unk0.blue, unk1, unk2.blue, unk3.blue);
lerp(unk0.alpha, unk1, unk2.alpha, unk3.alpha);
}
void lerp(U8& unk0, F32 unk1, U8 unk2, U8 unk3)
{
}
void lerp(xVec3& unk0, F32 unk1, const xVec3& unk2, const xVec3& unk3)
{
lerp(unk0.x, unk1, unk2.x, unk3.x);
lerp(unk0.y, unk1, unk2.y, unk3.y);
lerp(unk0.z, unk1, unk2.z, unk3.z);
}
} // namespace
namespace
{
#define ALPHA_COUNT 300
U8 alpha_count0[ALPHA_COUNT];
U8 alpha_count1[ALPHA_COUNT];
} // namespace
// clip_triangle jumptable
static U32 _1933[] = { 0x80028610, 0x80028640, 0x80028640, 0x80028640, 0x80028640, 0x80028640,
0x80028640, 0x80028620, 0x80028640, 0x80028640, 0x80028640, 0x80028640,
0x80028640, 0x80028640, 0x80028630, 0x80028640, 0x80028640, 0x80028640,
0x80028640, 0x80028640, 0x80028640, 0x80028630, 0x80028640, 0x80028640,
0x80028640, 0x80028640, 0x80028640, 0x80028640, 0x80028620, 0x80028640,
0x80028640, 0x80028640, 0x80028640, 0x80028640, 0x80028640, 0x80028610 };
static const U8 segments_1637[43] = { 0, 1, 3, 0, 1, 2, 4, 0, 3, 4, 3, 0, 0, 0, 0,
0, 1, 2, 4, 0, 2, 1, 2, 0, 4, 2, 1, 0, 0, 0,
0, 0, 3, 4, 3, 0, 4, 2, 1, 0, 3, 1, 0 };
struct _tagFirework
{
S32 state;
F32 timer;
xVec3 vel;
xVec3 pos;
F32 fuel;
};
#define FIREWORK_COUNT 10
static _tagFirework sFirework[FIREWORK_COUNT];
static zParEmitter* sFireworkTrailEmit = NULL;
static zParEmitter* sFirework1Emit = NULL;
static zParEmitter* sFirework2Emit = NULL;
static U32 sFireworkSoundID = 0;
static U32 sFireworkLaunchSoundID = 0;
static RwIm3DVertex sStripVert_2188[4];
static RwIm3DVertex blah_2485[4];
namespace
{
#define RIBBON_COUNT 64
xFXRibbon* active_ribbons[RIBBON_COUNT];
U32 active_ribbons_size = 0;
bool ribbons_dirty = false;
} // namespace
struct _xFXAuraAngle
{
F32 angle;
F32 cc;
F32 ss;
};
struct _xFXAura
{
xVec3 pos;
iColor_tag color;
F32 size;
void* parent;
U32 frame;
F32 dangle[2];
};
#define AURA_COUNT 32
static F32 sAuraPulse[2];
static F32 sAuraPulseAng[2];
static _xFXAuraAngle sAuraAngle[2];
static RwTexture* gAuraTex = NULL;
static _xFXAura sAura[AURA_COUNT];
void xFXStartup()
{
}
void xFXShutdown()
{
}
void xFXSceneInit()
{
}
void xFXSceneSetup()
{
}
void xFXSceneReset()
{
}
void xFXScenePrepare()
{
}
void xFXSceneFinish()
{
}
void xFXanimUV2PSetTexture(RwTexture* tex)
{
xFXanimUV2PTexture = tex;
}
void xFXanimUVSetAngle(F32 angle)
{
F32 sin = isin(angle);
F32 cos = icos(angle);
xFXanimUVRotMat0[0] = cos;
xFXanimUVRotMat0[1] = -sin;
xFXanimUVRotMat1[0] = sin;
xFXanimUVRotMat1[1] = cos;
}
void xFXanimUV2PSetScale(const xVec3* scale)
{
xFXanimUV2PScale[0] = scale->x;
xFXanimUV2PScale[1] = scale->y;
}
void xFXanimUVSetScale(const xVec3* scale)
{
xFXanimUVScale[0] = scale->x;
xFXanimUVScale[1] = scale->y;
}
void xFXanimUVSetTranslation(const xVec3* translation)
{
xFXanimUVTrans[0] = translation->x;
xFXanimUVTrans[1] = translation->y;
}
void xFXStreakUpdate(U32 id, const xVec3* a, const xVec3* b)
{
xFXStreak* s;
}
U32 xFXStreakStart(F32 frequency, F32 alphaFadeRate, F32 alphaStart, U32 textureID,
const iColor_tag* edge_a, const iColor_tag* edge_b, S32 taper)
{
for (U32 i = 0; i < 10; i++)
{
if (sStreakList[i].flags == 0x0)
{
sStreakList[i].flags = 0x1;
if (taper != 0)
{
sStreakList[i].flags |= 0x4;
}
sStreakList[i].frequency = frequency;
sStreakList[i].alphaFadeRate = alphaFadeRate;
sStreakList[i].alphaStart = alphaStart;
sStreakList[i].head = 0;
sStreakList[i].elapsed = 0.0f;
sStreakList[i].lifetime = 0.0f;
sStreakList[i].textureRasterPtr = NULL;
sStreakList[i].texturePtr = NULL;
for (S32 j = 0; j < 50; j++)
{
sStreakList[i].elem[j].flag = 0x0;
}
if (edge_a != NULL)
{
sStreakList[i].color_a = *edge_a;
}
else
{
sStreakList[i].color_a.a = 255;
sStreakList[i].color_a.b = 255;
sStreakList[i].color_a.g = 255;
sStreakList[i].color_a.r = 255;
}
if (edge_b != NULL)
{
sStreakList[i].color_b = *edge_a;
}
else
{
sStreakList[i].color_b.a = 255;
sStreakList[i].color_b.b = 255;
sStreakList[i].color_b.g = 255;
sStreakList[i].color_b.r = 255;
}
if (textureID == 0)
{
textureID = xStrHash("fx_streak1");
}
sStreakList[i].texturePtr = (RwTexture*)xSTFindAsset(textureID, NULL);
if (sStreakList[i].texturePtr != NULL)
{
sStreakList[i].textureRasterPtr = RwTextureGetRaster(sStreakList[i].texturePtr);
}
else
{
return 0;
}
}
}
return 10;
}
void xFXStreakStop(U32)
{
}
void xFXStreakUpdate(F32)
{
}
void xParInterp::set(F32 value1, F32 value2, F32 freq, U32 interp)
{
this->val[0] = value1;
this->val[1] = value2;
this->freq = freq;
if (freq != 0.0f)
{
this->oofreq = 1.0f / freq;
}
else
{
this->oofreq = 0.0f;
}
this->interp = interp;
}
void xFXShineInit()
{
for (S32 i = 0; i < 2; i++)
{
memset(&sShineList[0], 0, sizeof(xFXShine));
sShineList[i] = sShineList[i];
}
}
U32 xFXShineStart(const xVec3*, F32, F32, F32, F32, U32, const iColor_tag*, const iColor_tag*, F32,
S32)
{
return 2;
}
namespace
{
S32 compare_ribbons(const void* e1, const void* e2)
{
return 0;
}
void sort_ribbons()
{
}
void activate_ribbon(xFXRibbon*)
{
}
void deactivate_ribbon(xFXRibbon*)
{
}
} // namespace
void xFXShineUpdate(F32)
{
}
void xFXShineRender()
{
}
static void RenderRotatedBillboard(xVec3* pos, _xFXAuraAngle* rot, U32 count, F32 width, F32 height,
iColor_tag tint, U32 flipUV)
{
}
void xFXAuraRender()
{
// TODO: Fix function
// Honestly the closest I can get this function.
// fogstate is in the dwarf but currently isn't used in the function.
S32 fogstate;
_xFXAura* ap;
_xFXAuraAngle* auraAng;
if (gAuraTex != NULL)
{
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)gAuraTex->raster);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)0x1);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)0x5);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)0x2);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)0x1);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)0x0);
RwRenderStateGet(rwRENDERSTATEFOGTYPE, (void*)0x1);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)0x0);
ap = sAura;
for (S32 i = 0; i < 32; i++)
{
if (ap->frame == gFrameCount)
{
auraAng = &sAuraAngle[0];
RenderRotatedBillboard(&ap->pos, auraAng, 1, 0, 0, ap->color, 0);
auraAng = &sAuraAngle[1];
RenderRotatedBillboard(&ap->pos, auraAng, 1, 0, 0, ap->color, 1);
}
ap = (_xFXAura*)ap->dangle;
}
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)0x5);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)0x6);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)0x1);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)0x1);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)0x10);
ap = sAura;
for (S32 i = 0; i < 32; i++)
{
if (ap->frame == gFrameCount && ap->parent != 0)
{
zEntPickup_RenderOne((xEnt*)ap->parent);
}
ap = (_xFXAura*)ap->dangle;
}
}
}
void xFXFireworksInit(const char* trailEmit, const char* emit1, const char* emit2,
const char* mainSound, const char* launchSound)
{
sFireworkTrailEmit = zParEmitterFind(trailEmit);
sFirework1Emit = zParEmitterFind(emit1);
sFirework2Emit = zParEmitterFind(emit2);
sFireworkSoundID = xStrHash(mainSound);
sFireworkLaunchSoundID = xStrHash(launchSound);
memset(sFirework, 0, sizeof(sFirework));
for (U32 i = 0; i < FIREWORK_COUNT; ++i)
{
sFirework[i].state = 0;
}
}
void xFXFireworksLaunch(F32 time, const xVec3* pos, F32 fuel)
{
U32 counter = FIREWORK_COUNT;
_tagFirework* candidate = sFirework;
while (counter)
{
if (candidate->state == 0)
{
candidate->state = 1;
candidate->timer = time;
candidate->pos = *pos;
candidate->fuel = fuel;
return;
}
--counter;
++candidate;
}
}
void xFXFireworksUpdate(F32 dt)
{
for (S32 i = 0; i < FIREWORK_COUNT; ++i)
{
if (sFirework[i].state == 0)
{
continue;
}
if (sFirework[i].state == 1)
{
sFirework[i].timer -= dt;
if (sFirework[i].timer <= 0.0f)
{
sFirework[i].vel.x = 13.0f * xurand() + 6.5f;
sFirework[i].vel.y = 0.0f;
sFirework[i].vel.z = 13.0f * xurand() + 6.5f;
sFirework[i].state = 2;
if (sFireworkLaunchSoundID != 0)
{
xSndPlay3D(sFireworkLaunchSoundID,
0.308f, // Volume
0.0f, // Pitch
0x80, // Priority
0, // Flags
&sFirework[i].pos,
20.0f, // Radius
5.0f, SND_CAT_GAME,
0.0f); // Delay
}
}
}
else
{
sFirework[i].fuel -= dt;
if (sFirework[i].fuel > 0.0f)
{
sFirework[i].vel.y += 15.0f * dt;
}
xParEmitterCustomSettings settings;
settings.custom_flags = 0x100;
sFirework[i].pos.x += sFirework[i].vel.x * dt;
sFirework[i].pos.y += sFirework[i].vel.y * dt;
sFirework[i].pos.z += sFirework[i].vel.z * dt;
settings.pos = sFirework[i].pos;
xParEmitterEmitCustom(sFireworkTrailEmit, dt, &settings);
if (sFirework[i].fuel <= 0.0f)
{
sFirework[i].state = 0;
sFirework[i].timer = 0.0f;
zParEmitter* emit = sFirework1Emit;
if (xurand() < 0.75f)
{
emit = sFirework2Emit;
}
xParEmitterCustomSettings settings2;
settings2.custom_flags = 0xD00;
settings2.pos = sFirework[i].pos;
if (emit != NULL)
{
settings2.color_birth[0].set(127.0f * xurand() + 128.0f, 75.0f, 0.0f, 0);
settings2.color_birth[1].set(127.0f * xurand() + 128.0f, 75.0f, 0.0f, 0);
settings2.color_birth[2].set(127.0f * xurand() + 128.0f, 75.0f, 0.0f, 0);
settings2.color_birth[3].set(255.0f, 0.0f, 1.0f, 0);
memcpy(settings2.color_death, &settings2.color_birth,
sizeof(settings2.color_birth));
settings2.color_death[3].set(0.0f, 0.0f, 1.0f, 0);
xParEmitterEmitCustom(emit, dt, &settings2);
}
F32 a = 0.4f * xurand() + 0.1f;
F32 b = 0.5f * xurand() + 0.5f;
F32 g = 0.5f * xurand() + 0.5f;
F32 r = 0.5f * xurand() + 0.5f;
F32 size = 5.0f * xurand() + 2.0f;
F32 intensity = 0.3f * xurand() + 0.1f;
F32 life = 0.5f * xurand() + 0.5f;
xScrFXGlareAdd(&sFirework[i].pos, life, intensity, size, r, g, b, a, NULL);
xVec3 diff;
xVec3Sub(&diff, xEntGetPos(&globals.player.ent), &sFirework[i].pos);
zRumbleStartDistance(globals.currentActivePad, diff.x * diff.x + diff.z * diff.z,
48.0f, eRumble_Medium, 0.35f);
sFirework[i].pos.y = xEntGetPos(&globals.player.ent)->y;
if (sFireworkSoundID != 0)
{
xSndPlay3D(sFireworkSoundID,
0.77f, // Volume
0.0f, // Pitch
0x80, // Priority
0, // Flags
&sFirework[i].pos,
20.0f, // Radius
5.0f, SND_CAT_GAME,
0.0f); // Delay
}
}
}
}
}
RpMaterial* MaterialSetBumpMap(RpMaterial* material, void* data)