SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
SpinDriverPathDrawer.cpp
1#include "Game/MapObj/SpinDriverPathDrawer.hpp"
2#include "Game/Scene/SceneObjHolder.hpp"
3#include "Game/Util.hpp"
4#include "Game/Util/DirectDraw.hpp"
5
6
7SpinDriverPathDrawInit::SpinDriverPathDrawInit() : NameObj("スピンドライバーレール描画初期化"),
8 mOrangeTexture(nullptr), mGreenTexture(nullptr), mPinkTexture(nullptr), mMaskTexture(nullptr), mIsPathAtOpa(false) {
9
10 void (SpinDriverPathDrawInit::*drawFunc)(void) = &SpinDriverPathDrawInit::initDraw;
11 MR::registerPreDrawFunction(MR::Functor(this, drawFunc), 18);
12 mOrangeTexture = new JUTTexture(MR::loadTexFromArc("SpinDriverPath.arc", "NormalColor.bti"), 0);
13 mGreenTexture = new JUTTexture(MR::loadTexFromArc("SpinDriverPath.arc", "Green.bti"), 0);
14 mPinkTexture = new JUTTexture(MR::loadTexFromArc("SpinDriverPath.arc", "Pink.bti"), 0);
15 mMaskTexture = new JUTTexture(MR::loadTexFromArc("SpinDriverPath.arc", "Mask.bti"), 0);
16}
17
18SpinDriverPathDrawer::SpinDriverPathDrawer(SpinDriverShootPath *pShootPath) : LiveActor("パス描画") {
19 mShootPath = pShootPath;
20 _90 = 0;
21 _94 = 0;
22 _98 = 0;
23 _9C = 0;
24 mPositionCount = 0;
25 _A4 = 0;
26 _A8 = 0;
27 _AC = 0.0f;
28 _B0 = 0.0f;
29 mColor = -1;
30 _B8 = 0.0f;
31 mFadeScale = 1.0f;
32 mMaskLength = 5000.0f;
33 MR::createSceneObj(SceneObj_SpinDrawerPathDrawInit);
34}
35
36#ifdef NON_MATCHING
37void SpinDriverPathDrawInit::initDraw() {
38 TDDraw::cameraInit3D();
39 GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
40 GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_POS_XYZ, GX_F32, 0);
41 GXClearVtxDesc();
42 GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
43 GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
44 GXLoadPosMtxImm(MR::getCameraViewMtx(), 0);
45 GXSetCurrentMtx(0);
46 GXSetNumChans(0);
47 GXSetNumTexGens(2u);
48 GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 0x1E, 0, 0x7D);
49 GXSetTexCoordGen2(GX_TEXCOORD1, GX_TG_MTX2x4, GX_TG_TEX0, 0x21, 0, 0x7D);
50 GXSetNumTevStages(2);
51 GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
52 GXSetTevOp(GX_TEVSTAGE0, GX_REPLACE);
53 GXSetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD1, GX_TEXMAP1, GX_COLOR_NULL);
54 GXSetTevColorIn(GX_TEVSTAGE1, GX_CC_CPREV, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO);
55 GXSetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
56 GXSetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_APREV, GX_CA_TEXA, GX_CA_ZERO);
57 GXSetTevAlphaOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
58 GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_ONE, GX_LO_CLEAR);
59 GXSetAlphaCompare(GX_GREATER, 0, GX_AOP_OR, GX_GREATER, 0);
60 GXSetZMode(1, GX_LEQUAL, 0);
61 GXSetZCompLoc(1);
62 GXSetCullMode(GX_CULL_NONE);
63 GXSetClipMode(GX_CLIP_ENABLE);
64 Color8 color = Color8(0);
65 GXSetFog(GX_FOG_NONE, 0.0f, 0.0f, 0.0f, 0.0f, (GXColor&)color);
66 GXSetFogRangeAdj(GX_FALSE, 0, nullptr);
67 mMaskTexture->load(GX_TEXMAP1);
68}
69#endif
70
71namespace MR {
72 void setSpinDriverPathColorNormal() {
73 MR::getSceneObj<SpinDriverPathDrawInit*>(SceneObj_SpinDrawerPathDrawInit)->mOrangeTexture->load(GX_TEXMAP0);
74 }
75
76 void setSpinDriverPathColorGreen() {
77 MR::getSceneObj<SpinDriverPathDrawInit*>(SceneObj_SpinDrawerPathDrawInit)->mGreenTexture->load(GX_TEXMAP0);
78 }
79
80 void setSpinDriverPathColorPink() {
81 MR::getSceneObj<SpinDriverPathDrawInit*>(SceneObj_SpinDrawerPathDrawInit)->mPinkTexture->load(GX_TEXMAP0);
82 }
83
84 bool isDrawSpinDriverPathAtOpa() {
85 if (!MR::isExistSceneObj(SceneObj_SpinDrawerPathDrawInit)) {
86 return false;
87 }
88
89 return MR::getSceneObj<SpinDriverPathDrawInit*>(SceneObj_SpinDrawerPathDrawInit)->mIsPathAtOpa;
90 }
91
92 void onDrawSpinDriverPathAtOpa() {
93 MR::getSceneObj<SpinDriverPathDrawInit*>(SceneObj_SpinDrawerPathDrawInit)->mIsPathAtOpa = true;
94 }
95
96 void offDrawSpinDriverPathAtOpa() {
97 MR::getSceneObj<SpinDriverPathDrawInit*>(SceneObj_SpinDrawerPathDrawInit)->mIsPathAtOpa = false;
98 }
99};
100
102 MR::connectToScene(this, -1, -1, -1, 0x12);
103 initPositionList(75.0f, 20.0f);
104 initClipping();
105 initPathEnd();
106 makeActorDead();
107}
108
109// SpinDriverPathDrawer::calcPositionCount
110// SpinDriverPathDrawer::initPositionList
111
112void SpinDriverPathDrawer::initClipping() {
113 f32 v3 = 0.0f;
114 mShootPath->calcClippingInfo(&mPosition, &v3, 150.0f, 150.0f);
115 MR::setClippingTypeSphere(this, v3);
116 MR::validateClipping(this);
117 MR::setClippingFarMax(this);
118}
119
120void SpinDriverPathDrawer::initPathEnd() {
121 s32 arg = -1;
122 MR::getRailArg1WithInit(mShootPath->mRailRider, &arg);
123
124 if (arg >= 0) {
125 _B8 = arg / 1000.0f;
126 }
127 else {
128 _B8 = 0.0f;
129 }
130}
131
132f32 SpinDriverPathDrawer::calcDrawCode() const {
133 if (_B8 <= 0.0f) {
134 return _AC;
135 }
136
137 f32 val = 1.0f - _B8;
138 f32 ret = (_AC < val) ? _AC : val;
139 return ret;
140}
141
142f32 SpinDriverPathDrawer::calcDrawBaseCode() const {
143 if (_B8 <= 0.0f) {
144 return _B0;
145 }
146
147 f32 val = _B0;
148
149 if (val < (1.0f - _B8)) {
150 return val;
151 }
152
153 return 1.0f - _B8;
154}
155
156void SpinDriverPathDrawer::setCoord(f32 coord) {
157 _AC = coord;
158 if (_B0 < coord) {
159 _B0 = coord;
160 }
161}
162
163void SpinDriverPathDrawer::setColorNormal() {
164 mColor = -1;
165}
166
167void SpinDriverPathDrawer::setColorGreen() {
168 mColor = 0;
169}
170
171void SpinDriverPathDrawer::setColorPink() {
172 mColor = 1;
173}
174
175void SpinDriverPathDrawer::setMaskLength(f32 mask) {
176 if (mask < 1.0f) {
177 mMaskLength = 1.0f;
178 }
179 else {
180 mMaskLength = mask;
181 }
182}
183
184void SpinDriverPathDrawer::setFadeScale(f32 fade) {
185 if (fade < 0.001f) {
186 mFadeScale = 0.001f;
187 }
188 else {
189 mFadeScale = fade;
190 }
191}
192
193// SpinDriverPathDrawer::draw
194
195void SpinDriverPathDrawer::sendPoint(const TVec3f &a1, f32 a2, f32 a3) {
196 GXWGFifo.f32 = a1.x;
197 GXWGFifo.f32 = a1.y;
198 GXWGFifo.f32 = a1.z;
199 GXWGFifo.f32 = a2;
200 GXWGFifo.f32 = a3;
201}
202
203SpinDriverPathDrawer::~SpinDriverPathDrawer() {
204
205}
206
207SpinDriverPathDrawInit::~SpinDriverPathDrawInit() {
208
209}
The basis of a drawable actor that can contain states (see: Nerve)
Definition LiveActor.hpp:24
TVec3f mPosition
3D vector of the actor's position.
Definition LiveActor.hpp:95
The most basic form of an object.
Definition NameObj.hpp:11
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.