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
|
#include <common.h>
#include <game.h>
#include <g3dhax.h>
class dMeteor : public dStageActor_c {
int onCreate();
int onDelete();
int onExecute();
int onDraw();
static dMeteor *build();
mHeapAllocator_c allocator;
m3d::mdl_c bodyModel;
nw4r::g3d::ResFile resFile;
int timer;
int spinSpeed;
char spinDir;
Physics MakeItRound;
void updateModelMatrices();
};
dMeteor *dMeteor::build() {
void *buffer = AllocFromGameHeap1(sizeof(dMeteor));
return new(buffer) dMeteor;
}
// extern "C" dStageActor_c *GetSpecificPlayerActor(int num);
// extern "C" void *modifyPlayerPropertiesWithRollingObject(dStageActor_c *Player, float _52C);
extern "C" void *spinningPhysicsCallback();
int dMeteor::onCreate() {
// Setup Model
allocator.link(-1, GameHeaps[0], 0, 0x20);
this->resFile.data = getResource("kazan_rock", "g3d/kazan_rock.brres");
nw4r::g3d::ResMdl mdl = this->resFile.GetResMdl("kazan_rock");
bodyModel.setup(mdl, &allocator, 0x224, 1, 0);
SetupTextures_Enemy(&bodyModel, 0);
allocator.unlink();
// Retrieve Scale and set it up
float sca = (float)((this->settings >> 8) & 0xFF);
sca = (sca/5.0) + 0.2;
this->scale = (Vec){sca,sca,sca};
// Other settings
this->spinDir = this->settings & 0x1;
this->spinSpeed = ((this->settings >> 16) & 0xFF) * 80;
// Setup Physics
MakeItRound.baseSetup(this, &spinningPhysicsCallback, 0, 0, 1, 0);
MakeItRound.x = 0.0;
MakeItRound.y = 0.0;
MakeItRound.diameter = 16.0 * sca;
MakeItRound.isRound = 1;
MakeItRound.update();
MakeItRound.addToList();
this->pos.z = -3458.0;
this->onExecute();
return true;
}
int dMeteor::onDelete() {
return true;
}
int dMeteor::onExecute() {
if (spinDir == 0) { rot.z -= spinSpeed; }
else { rot.z += spinSpeed; }
MakeItRound.update();
updateModelMatrices();
// 518 == opposite of direction
// for (i=0; i<4; i++) {
// dStageActor_c *player = GetSpecificPlayerActor(i);
// modifyPlayerPropertiesWithRollingObject(player, );
// }
return true;
}
int dMeteor::onDraw() {
bodyModel.scheduleForDrawing();
bodyModel._vf1C();
return true;
}
void dMeteor::updateModelMatrices() {
// This won't work with wrap because I'm lazy.
matrix.translation(pos.x, pos.y, pos.z);
matrix.applyRotationYXZ(&rot.x, &rot.y, &rot.z);
bodyModel.setDrawMatrix(matrix);
bodyModel.setScale(&scale);
bodyModel.calcWorld(false);
}
|