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
|
//
// Generated by dtk
// Translation Unit: J3DJoint.cpp
//
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/J3DGraphAnimator/J3DJoint.h"
#include "JSystem/J3DGraphAnimator/J3DAnimation.h"
#include "JSystem/J3DGraphAnimator/J3DModel.h"
#include "JSystem/J3DGraphBase/J3DSys.h"
#include "JSystem/J3DGraphBase/J3DDrawBuffer.h"
#include "JSystem/J3DGraphAnimator/J3DMaterialAnm.h"
#include "dolphin/types.h"
/* 802F4DC0-802F4EB0 .text calc__13J3DMtxCalcAnmFUs */
void J3DMtxCalcAnm::calc(u16 jnt_no) {
j3dSys.setCurrentMtxCalc(this);
J3DTransformInfo info;
J3DAnmTransform* transform = mOne[0];
if (transform) {
transform->getTransform(jnt_no, &info);
} else {
info = j3dSys.getModel()->getModelData()->getJointNodePointer(jnt_no)->getTransformInfo();
}
calcTransform(jnt_no, info);
}
/* 802F4EB0-802F4EF8 .text __ct__15J3DMtxCalcBasicFv */
J3DMtxCalcBasic::J3DMtxCalcBasic() {}
/* 802F4EF8-802F5090 .text recursiveCalc__15J3DMtxCalcBasicFP7J3DNode */
void J3DMtxCalcBasic::recursiveCalc(J3DNode* node) {
if (!node) {
return;
}
J3DMtxCalcBasic mtxCalc;
MTXCopy(J3DSys::mCurrentMtx, mtxCalc.getBackupMtx());
mtxCalc.setBackupS(J3DSys::mCurrentS);
mtxCalc.setBackupParentS(J3DSys::mParentS);
node->calcIn();
if (node->getCallBack()) {
node->getCallBack()(node, J3DNodeCBCalcTiming_In);
}
recursiveCalc(node->getChild());
MTXCopy(mtxCalc.getBackupMtx(), J3DSys::mCurrentMtx);
J3DSys::mCurrentS = mtxCalc.getBackupS();
J3DSys::mParentS = mtxCalc.getBackupParentS();
node->calcOut();
if (node->getCallBack()) {
node->getCallBack()(node, J3DNodeCBCalcTiming_Out);
}
recursiveCalc(node->getYounger());
}
/* 802F5090-802F525C .text calcTransform__15J3DMtxCalcBasicFUsRC16J3DTransformInfo */
void J3DMtxCalcBasic::calcTransform(u16 jnt_no, const J3DTransformInfo& info) {
J3DSys::mCurrentS.x *= info.mScale.x;
J3DSys::mCurrentS.y *= info.mScale.y;
J3DSys::mCurrentS.z *= info.mScale.z;
s32 r29;
if (checkScaleOne(J3DSys::mCurrentS)) {
j3dSys.getModel()->setScaleFlag(jnt_no, 1);
r29 = 1;
} else {
j3dSys.getModel()->setScaleFlag(jnt_no, 0);
r29 = 0;
}
Mtx mtx;
J3DGetTranslateRotateMtx(info, mtx);
if (r29 == 0) {
mtx[0][0] *= info.mScale.x;
mtx[0][1] *= info.mScale.y;
mtx[0][2] *= info.mScale.z;
mtx[1][0] *= info.mScale.x;
mtx[1][1] *= info.mScale.y;
mtx[1][2] *= info.mScale.z;
mtx[2][0] *= info.mScale.x;
mtx[2][1] *= info.mScale.y;
mtx[2][2] *= info.mScale.z;
}
MTXConcat(J3DSys::mCurrentMtx, mtx, J3DSys::mCurrentMtx);
J3DModel* model = j3dSys.getModel();
model->setAnmMtx(jnt_no, J3DSys::mCurrentMtx);
}
/* 802F525C-802F52BC .text calc__15J3DMtxCalcBasicFUs */
void J3DMtxCalcBasic::calc(u16 jnt_no) {
j3dSys.setCurrentMtxCalc(this);
calcTransform(jnt_no, j3dSys.getModel()->getModelData()->getJointNodePointer(jnt_no)->getTransformInfo());
}
/* 802F52BC-802F5508 .text calcTransform__19J3DMtxCalcSoftimageFUsRC16J3DTransformInfo */
void J3DMtxCalcSoftimage::calcTransform(u16 jnt_no, const J3DTransformInfo& info) {
/* Nonmatching */
Mtx mtx;
J3DGetTranslateRotateMtx(
info.mRotation.x,
info.mRotation.y,
info.mRotation.z,
info.mTranslate.x * J3DSys::mCurrentS.x,
info.mTranslate.y * J3DSys::mCurrentS.y,
info.mTranslate.z * J3DSys::mCurrentS.z,
mtx
);
MTXConcat(J3DSys::mCurrentMtx, mtx, J3DSys::mCurrentMtx);
J3DSys::mCurrentS.x = J3DSys::mCurrentS.x * info.mScale.x;
J3DSys::mCurrentS.y = J3DSys::mCurrentS.y * info.mScale.y;
J3DSys::mCurrentS.z = J3DSys::mCurrentS.z * info.mScale.z;
s32 var2;
if (checkScaleOne(J3DSys::mCurrentS)) {
j3dSys.getModel()->setScaleFlag(jnt_no, 1);
var2 = 1;
} else {
j3dSys.getModel()->setScaleFlag(jnt_no, 0);
var2 = 0;
}
if (!var2) {
mtx[0][0] = J3DSys::mCurrentMtx[0][0] * J3DSys::mCurrentS.x;
mtx[0][1] = J3DSys::mCurrentMtx[0][1] * J3DSys::mCurrentS.y;
mtx[0][2] = J3DSys::mCurrentMtx[0][2] * J3DSys::mCurrentS.z;
mtx[0][3] = J3DSys::mCurrentMtx[0][3];
mtx[1][0] = J3DSys::mCurrentMtx[1][0] * J3DSys::mCurrentS.x;
mtx[1][1] = J3DSys::mCurrentMtx[1][1] * J3DSys::mCurrentS.y;
mtx[1][2] = J3DSys::mCurrentMtx[1][2] * J3DSys::mCurrentS.z;
mtx[1][3] = J3DSys::mCurrentMtx[1][3];
mtx[2][0] = J3DSys::mCurrentMtx[2][0] * J3DSys::mCurrentS.x;
mtx[2][1] = J3DSys::mCurrentMtx[2][1] * J3DSys::mCurrentS.y;
mtx[2][2] = J3DSys::mCurrentMtx[2][2] * J3DSys::mCurrentS.z;
mtx[2][3] = J3DSys::mCurrentMtx[2][3];
J3DModel* model = j3dSys.getModel();
model->setAnmMtx(jnt_no, mtx);
} else {
J3DModel* model = j3dSys.getModel();
model->setAnmMtx(jnt_no, J3DSys::mCurrentMtx);
}
}
/* 802F5508-802F5724 .text calcTransform__14J3DMtxCalcMayaFUsRC16J3DTransformInfo */
void J3DMtxCalcMaya::calcTransform(u16 jnt_no, const J3DTransformInfo& param_2) {
J3DModel* model = j3dSys.getModel();
u8 scaleCompensate = model->getModelData()->getJointNodePointer(jnt_no)->getScaleCompensate();
s32 tmp;
if (param_2.mScale.x == 1.0f && param_2.mScale.y == 1.0f && param_2.mScale.z == 1.0f) {
model->setScaleFlag(jnt_no, 1);
tmp = true;
} else {
model->setScaleFlag(jnt_no, 0);
tmp = false;
}
Mtx mtx;
J3DGetTranslateRotateMtx(param_2, mtx);
if (tmp == 0) {
mtx[0][0] *= param_2.mScale.x;
mtx[0][1] *= param_2.mScale.y;
mtx[0][2] *= param_2.mScale.z;
mtx[1][0] *= param_2.mScale.x;
mtx[1][1] *= param_2.mScale.y;
mtx[1][2] *= param_2.mScale.z;
mtx[2][0] *= param_2.mScale.x;
mtx[2][1] *= param_2.mScale.y;
mtx[2][2] *= param_2.mScale.z;
}
if (scaleCompensate == 1) {
f32 x = 1.0f / J3DSys::mParentS.x;
f32 y = 1.0f / J3DSys::mParentS.y;
f32 z = 1.0f / J3DSys::mParentS.z;
mtx[0][0] *= x;
mtx[0][1] *= x;
mtx[0][2] *= x;
mtx[1][0] *= y;
mtx[1][1] *= y;
mtx[1][2] *= y;
mtx[2][0] *= z;
mtx[2][1] *= z;
mtx[2][2] *= z;
}
MTXConcat(J3DSys::mCurrentMtx, mtx, J3DSys::mCurrentMtx);
model = j3dSys.getModel();
model->setAnmMtx(jnt_no, J3DSys::mCurrentMtx);
J3DSys::mParentS.x = param_2.mScale.x;
J3DSys::mParentS.y = param_2.mScale.y;
J3DSys::mParentS.z = param_2.mScale.z;
}
/* 802F5724-802F5814 .text initialize__8J3DJointFv */
void J3DJoint::initialize() {
mJntNo = 0;
mKind = 1;
mScaleCompensate = 0;
mTransformInfo = j3dDefaultTransformInfo;
mRadius = 0.0f;
mMin = (Vec){0.0f, 0.0f, 0.0f};
mMax = (Vec){0.0f, 0.0f, 0.0f};
mMtxCalc = NULL;
mOldMtxCalc = NULL;
mMesh = NULL;
}
/* 802F5814-802F5834 .text addMesh__8J3DJointFP11J3DMaterial */
void J3DJoint::addMesh(J3DMaterial* material) {
if (!mMesh) {
mMesh = material;
return;
}
material->setNext(mMesh);
mMesh = material;
}
/* 802F5834-802F58B4 .text calcIn__8J3DJointFv */
void J3DJoint::calcIn() {
if (mMtxCalc) {
mOldMtxCalc = j3dSys.getCurrentMtxCalc();
mMtxCalc->calc(mJntNo);
} else if (j3dSys.getCurrentMtxCalc()) {
j3dSys.getCurrentMtxCalc()->calc(mJntNo);
}
}
/* 802F58B4-802F58D8 .text calcOut__8J3DJointFv */
void J3DJoint::calcOut() {
if (!mOldMtxCalc) {
return;
}
j3dSys.setCurrentMtxCalc(mOldMtxCalc);
mOldMtxCalc = NULL;
}
/* 802F58D8-802F5A78 .text entryIn__8J3DJointFv */
void J3DJoint::entryIn() {
MtxP anmMtx = j3dSys.getModel()->getAnmMtx(mJntNo);
j3dSys.getDrawBuffer(0)->setZMtx(anmMtx);
j3dSys.getDrawBuffer(1)->setZMtx(anmMtx);
for (J3DMaterial* mesh = mMesh; mesh != NULL; ) {
if (mesh->getShape()->checkFlag(J3DShpFlag_Hide)) {
mesh = mesh->getNext();
} else {
J3DMatPacket* matPacket = j3dSys.getModel()->getMatPacket(mesh->getIndex());
J3DShapePacket* shapePacket = j3dSys.getModel()->getShapePacket(mesh->getShape()->getIndex());
if (!matPacket->isLocked()) {
if (mesh->getMaterialAnm()) {
J3DMaterialAnm* piVar8 = mesh->getMaterialAnm();
piVar8->calc(mesh);
}
mesh->calc(anmMtx);
}
mesh->setCurrentMtx();
matPacket->setMaterialAnmID(mesh->getMaterialAnm());
matPacket->setShapePacket(shapePacket);
J3DDrawBuffer* drawBuffer = j3dSys.getDrawBuffer(mesh->isDrawModeOpaTexEdge());
if ((u8)matPacket->entry(drawBuffer)) {
j3dSys.setMatPacket(matPacket);
J3DDrawBuffer::entryNum++;
mesh->makeDisplayList();
}
mesh = mesh->getNext();
}
}
}
|