SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
WarpCube.cpp
1#include "Game/AreaObj/WarpCube.hpp"
2#include "Game/LiveActor/ActorCameraInfo.hpp"
3#include "Game/Util/DirectDraw.hpp"
4#include <cstdio>
5#include <cstring>
6
7WarpCube::~WarpCube() {
8
9}
10
11void WarpCube::movement() {
12 if (_48 != 0) {
13 if (_48 == 1) {
14 TVec3f pos;
15 MR::calcCubePos(this, &pos);
16
17 if (MR::calcDistanceToPlayer(pos) < 300.0f) {
18 return;
19 }
20 }
21
22 if (--_48 == 0) {
23 mValid = true;
24 }
25 }
26}
27
28void WarpCube::draw() const {
29 TDDraw::setup(0, 1, 0);
30 GXSetCullMode(GX_CULL_NONE);
31 GXSetZMode(GX_TRUE, GX_LEQUAL, GX_FALSE);
32
33 TVec3f rotate;
34 TVec3f up;
35
36 up.x = 0.0f;
37 up.y = 1.0f;
38 up.z = 0.0f;
39
40 MR::calcCubeRotate(this, &rotate);
41
42 Mtx matrix;
43 MR::makeMtxTR(matrix, 0.0f, 0.0f, 0.0f, rotate.x, rotate.y, rotate.z);
44 PSMTXMultVecSR(matrix, reinterpret_cast<Vec *>(&up), reinterpret_cast<Vec *>(&up));
45
46 TVec3f pos;
47 MR::calcCubePos(this, &pos);
48
49 u32 uVar2 = 0x1FFF080;
50
51 bool enabled = false;
52
53 if (mValid && _15 && mAwake) {
54 enabled = true;
55 }
56
57 if (!enabled) {
58 uVar2 = 0x1FCF0010;
59 }
60
61 TDDraw::drawSphere(MR::createVecAndScaleByAndAdd(up, pos), 120.0f, uVar2, 16);
62}
63
64void WarpCube::init(const JMapInfoIter &rIter) {
65 AreaObj::init(rIter);
66
67 s32 groupID = -1;
68 MR::getJMapInfoGroupID(rIter, &groupID);
69
70 if (groupID >= 0) {
71 mMapIdInfo = new JMapIdInfo(groupID, rIter);
72 }
73
74 mCameraInfo = new ActorCameraInfo(rIter);
75
76 s32 local118;
77 MR::getJMapInfoArg0WithInit(rIter, &local118);
78
79 char eventName[0x100];
80 sprintf(eventName, "ワープカメラ %d-%c", groupID, local118 + 65);
81
82 MR::declareEventCamera(mCameraInfo, eventName);
83
84 s32 eventNameLength = strlen(&eventName[0]);
85 mEventName = new char[eventNameLength + 1];
86 strcpy(mEventName, &eventName[0]);
87
88 MR::connectToScene(this, 13, -1, -1, 24);
89 _48 = 0;
90}
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
Definition AreaObj.cpp:41
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
Definition WarpCube.cpp:64
virtual void draw() const
Draws the object. Does nothing until overridden.
Definition WarpCube.cpp:28