SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
Sky.cpp
1#include "Game/Map/Sky.hpp"
2#include "Game/LiveActor/MirrorReflectionModel.hpp"
3#include "Game/Map/SpaceInner.hpp"
4
5NrvSky::HostTypeWait NrvSky::HostTypeWait::sInstance;
6NrvSky::HostTypeChange NrvSky::HostTypeChange::sInstance;
7
8Sky::Sky(const char *pSkyName) : LiveActor(pSkyName) {
9 mSpaceInner = 0;
10 mReflectionModel = 0;
11}
12
13void Sky::init(const JMapInfoIter &rIter) {
14 MR::initDefaultPos(this, rIter);
15 const char* objectName = 0;
16 MR::getObjectName(&objectName, rIter);
17 initModel(objectName);
18 MR::connectToSceneSky(this);
19 MR::useStageSwitchReadA(this, rIter);
20 MR::useStageSwitchReadB(this, rIter);
21 MR::useStageSwitchReadAppear(this, rIter);
22
23 if (MR::isEqualString(objectName, "SummerSky")) {
24 mSpaceInner = new SpaceInner("内側宇宙");
25 mSpaceInner->initWithoutIter();
26
27 if (MR::isValidSwitchB(this)) {
28 void (Sky::*d)(void) = &Sky::disappearSpaceInner;
29 void (Sky::*a)(void) = &Sky::appearSpaceInner;
30 MR::listenStageSwitchOnOffB(this, MR::Functor(this, d), MR::Functor(this, a));
31 }
32 }
33
34 s32 arg = -1;
35 MR::getJMapInfoArg0NoInit(rIter, &arg);
36
37 if (!arg) {
38 mReflectionModel = new MirrorReflectionModel(this, "鏡内モデル", objectName, getBaseMtx());
39 mReflectionModel->initWithoutIter();
40 }
41
42 MR::tryStartAllAnim(this, objectName);
43
44 if (mReflectionModel) {
45 MR::tryStartAllAnim(mReflectionModel, objectName);
46 }
47
48 MR::invalidateClipping(this);
49 MR::registerDemoSimpleCastAll(this);
50 initNerve(&NrvSky::HostTypeWait::sInstance);
51
52 if (MR::isValidSwitchAppear(this)) {
53 MR::syncStageSwitchAppear(this);
54 makeActorDead();
55 }
56 else {
57 makeActorAppeared();
58 }
59}
60
61void Sky::calcAnim() {
62 TVec3f pos = MR::getCamPos();
63 mPosition.x = pos.x;
64 mPosition.y = pos.y;
65 mPosition.z = pos.z;
66 LiveActor::calcAnim();
67}
68
69void Sky::initModel(const char *pModelName) {
70 initModelManagerWithAnm(pModelName, 0, false);
71}
72
73void Sky::control() {
74 if (mSpaceInner && MR::isValidSwitchB(this)) {
75 if (MR::isDead(mSpaceInner)) {
76 MR::showModelIfHidden(this);
77 }
78 else {
79 if (mSpaceInner->isAppeared()) {
80 MR::hideModelIfHidden(this);
81 }
82 else {
83 MR::showModelIfHidden(this);
84 }
85 }
86 }
87}
88
89void Sky::appearSpaceInner() {
90 if (mSpaceInner && MR::isValidSwitchB(this)) {
91 mSpaceInner->appear();
92 }
93}
94
95void Sky::disappearSpaceInner() {
96 if (mSpaceInner && MR::isValidSwitchB(this)) {
97 mSpaceInner->disappear();
98 }
99}
100
101ProjectionMapSky::ProjectionMapSky(const char *pSkyName) : Sky(pSkyName) {
102 mMtxSetter = 0;
103}
104
105Sky::~Sky() {
106
107}
108
111
112 if (mMtxSetter) {
113 mMtxSetter->updateMtxUseBaseMtx();
114 }
115}
116
117void ProjectionMapSky::initModel(const char *pName) {
118 initModelManagerWithAnm(pName, 0, true);
119 mMtxSetter = MR::initDLMakerProjmapEffectMtxSetter(this);
120 MR::newDifferedDLBuffer(this);
121 mMtxSetter->updateMtxUseBaseMtx();
122}
123
124namespace NrvSky {
125 void HostTypeChange::execute(Spine *pSpine) const {
126 Sky* sky = reinterpret_cast<Sky*>(pSpine->mExecutor);
127
128 if (MR::isFirstStep(sky)) {
129 MR::startAllAnim(sky, cChangeAnimName);
130 }
131 }
132
133 void HostTypeWait::execute(Spine *pSpine) const {
134 Sky* sky = reinterpret_cast<Sky*>(pSpine->mExecutor);
135
136 if (MR::isValidSwitchA(sky) && MR::isOnSwitchA(sky)) {
137 sky->setNerve(&NrvSky::HostTypeChange::sInstance);
138 }
139 }
140};
141
142ProjectionMapSky::~ProjectionMapSky() {
143
144}
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
virtual void calcAndSetBaseMtx()
Calculates and sets the base matrix of the actor.
virtual MtxPtr getBaseMtx() const
Gets the base matrix of the model used for the actor.
void initWithoutIter()
Initializes a NameObj without a JMapInfoIter instance.
Definition NameObj.cpp:41
virtual void calcAndSetBaseMtx()
Calculates and sets the base matrix of the actor.
Definition Sky.cpp:109
Definition Sky.hpp:9
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
Definition Sky.cpp:13
Definition Spine.hpp:9