Skip to content

Commit 6707b29

Browse files
committed
Some SDLModel
1 parent 45ac164 commit 6707b29

3 files changed

Lines changed: 136 additions & 10 deletions

File tree

include/Camera/Camera.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ class CPolarSubCamera : public JDrama::TLookAtCamera {
128128
void execGroundCheck_(Vec);
129129

130130
s16 getUnk2C8() const { return unk2C8; }
131+
MtxPtr getUnk1EC() { return unk1EC; }
131132

132133
public:
133134
/* 0x50 */ int mMode;

include/M3DUtil/SDLModel.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,21 @@ class J3DNode;
1111
class SDLModel;
1212

1313
struct SDLDrawBufToken {
14+
SDLDrawBufToken()
15+
{
16+
unk0[0] = nullptr;
17+
unk0[1] = nullptr;
18+
unk8 = nullptr;
19+
}
20+
1421
/* 0x0 */ J3DDrawBuffer* unk0[2];
15-
/* 0x8 */ J3DModel* unk8;
22+
/* 0x8 */ SDLModel* unk8;
1623
};
1724

1825
// 0x1CU
1926
class SDLModelData {
2027
public:
2128
SDLModelData(J3DModelData*);
22-
~SDLModelData();
2329

2430
void entrySDLModels();
2531
void registerSDLModel(SDLModel*);
@@ -40,7 +46,6 @@ class SDLModelData {
4046
class SDLMatPacket : public J3DMatPacket {
4147
public:
4248
SDLMatPacket();
43-
~SDLMatPacket() { }
4449

4550
void newSingleDL(u32);
4651
void beParasiteDL(J3DMatPacket*);
@@ -51,7 +56,6 @@ class SDLModel : public J3DModel {
5156
public:
5257
SDLModel(J3DModelData*, u32);
5358
SDLModel(SDLModelData*, u32, u32);
54-
virtual ~SDLModel() { }
5559

5660
virtual void viewCalcSimple();
5761
void entry();
@@ -62,7 +66,7 @@ class SDLModel : public J3DModel {
6266

6367
public:
6468
/* 0xA0 */ SDLModelData* unkA0;
65-
/* 0xA4 */ J3DDrawBuffer* unkA4;
69+
/* 0xA4 */ SDLModel* unkA4;
6670
/* 0xA8 */ u32 unkA8;
6771
};
6872

src/M3DUtil/SDLModel.cpp

Lines changed: 126 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,108 @@
22
#include <JSystem/JKernel/JKRHeap.hpp>
33
#include <JSystem/J3D/J3DGraphBase/J3DMaterial.hpp>
44
#include <JSystem/J3D/J3DGraphBase/J3DShape.hpp>
5+
#include <JSystem/J3D/J3DGraphBase/J3DSys.hpp>
6+
#include <JSystem/J3D/J3DGraphAnimator/J3DJoint.hpp>
7+
#include <Enemy/Conductor.hpp>
8+
#include <Camera/Camera.hpp>
59
#include <macros.h>
610

711
void SDLModelData::entrySameMat(J3DMaterial* param_1, SDLDrawBufToken* param_2)
812
{
13+
SDLModel* model = param_2->unk8;
14+
while (model != nullptr) {
15+
if (model->unkA8 & 0x1)
16+
break;
17+
model = model->unkA4;
18+
}
19+
20+
if (model != nullptr) {
21+
j3dSys.setModel(model);
22+
j3dSys.setTexture(unk0->getTexture());
23+
24+
SDLMatPacket* matPacket
25+
= (SDLMatPacket*)model->getMatPacket(param_1->getIndex());
26+
matPacket->drawClear();
27+
28+
J3DShapePacket* shapePacket
29+
= model->getShapePacket(param_1->getShape()->getIndex());
30+
shapePacket->drawClear();
31+
32+
matPacket->setShapePacket(shapePacket);
33+
34+
SDLModel* model2 = model->unkA4;
35+
while (model2 != nullptr) {
36+
if (model->unkA8 & 1) {
37+
J3DShapePacket* shapePacket2
38+
= model2->getShapePacket(param_1->getShape()->getIndex());
39+
shapePacket2->drawClear();
40+
matPacket->addShapePacket(shapePacket2);
41+
}
42+
model2 = model2->unkA4;
43+
}
44+
param_2->unk0[param_1->isDrawModeOpaTexEdge() ? 0 : 1]->entryImm(
45+
matPacket, 0);
46+
}
947
}
1048

11-
void SDLModelData::entryNode(J3DNode* param_1, SDLDrawBufToken* param_2) { }
49+
void SDLModelData::entryNode(J3DNode* param_1, SDLDrawBufToken* param_2)
50+
{
51+
J3DJoint* joint = (J3DJoint*)param_1;
52+
J3DMaterial* material = joint->getMesh();
53+
while (material != nullptr) {
54+
if (material->getShape()->checkFlag(0x1)) {
55+
material = material->getNext();
56+
} else {
57+
entrySameMat(material, param_2);
58+
material = material->getNext();
59+
}
60+
}
61+
}
1262

13-
void SDLModelData::recursiveEntry(J3DNode* param_1, SDLDrawBufToken* param_2) {
63+
void SDLModelData::recursiveEntry(J3DNode* param_1, SDLDrawBufToken* param_2)
64+
{
65+
if (param_1) {
66+
entryNode(param_1, param_2);
67+
recursiveEntry(param_1->getChild(), param_2);
68+
recursiveEntry(param_1->getYounger(), param_2);
69+
}
1470
}
1571

1672
SDLModelData::SDLModelData(J3DModelData* model)
1773
: unk0(model)
1874
, unk4(0)
1975
, unk18(0)
2076
{
77+
gpConductor->registerSDLModelData(this);
2178
}
2279

23-
void SDLModelData::entrySDLModels() { }
80+
void SDLModelData::registerSDLModel(SDLModel*) { }
81+
82+
void SDLModelData::entrySDLModels()
83+
{
84+
if (unk18 & 0x1)
85+
return;
86+
87+
typedef JGadget::TList<SDLDrawBufToken*>::iterator I;
88+
for (I it = unk8.begin(), e = unk8.end(); it != e; ++it) {
89+
recursiveEntry(unk0->getRootNode(), *it);
90+
91+
SDLModel* model = (*it)->unk8;
92+
while (model != nullptr) {
93+
model->unkA8 &= ~0x1;
94+
model = model->unkA4;
95+
}
96+
97+
(*it)->unk8 = nullptr;
98+
}
99+
}
24100

25101
SDLMatPacket::SDLMatPacket() { }
26102

103+
void SDLMatPacket::beParasiteDL(J3DMatPacket*) { }
104+
105+
void SDLMatPacket::newSingleDL(u32) { }
106+
27107
SDLModel::SDLModel(SDLModelData* param_1, u32 param_2, u32 param_3)
28108
: unkA0(param_1)
29109
, unkA4(nullptr)
@@ -33,6 +113,8 @@ SDLModel::SDLModel(SDLModelData* param_1, u32 param_2, u32 param_3)
33113
entryModelDataSDL(param_1, param_2, param_3);
34114
}
35115

116+
SDLModel::SDLModel(J3DModelData*, u32) { }
117+
36118
void SDLModel::entryModelDataSDL(SDLModelData* param_1, u32 param_2,
37119
u32 param_3)
38120
{
@@ -175,6 +257,45 @@ void SDLModel::entryModelDataSDL(SDLModelData* param_1, u32 param_2,
175257
mVertexBuffer = new J3DVertexBuffer(&md->getVertexData());
176258
}
177259

178-
void SDLModel::entry() { }
260+
void SDLModel::entry()
261+
{
262+
if (!(unkA8 & 0x8) || !(unkA8 & 2) || !unkA0 || (unkA0->unk18 & 0x1)) {
263+
unkA8 &= ~0x1;
264+
J3DModel::entry();
265+
return;
266+
}
267+
268+
unkA8 |= 0x1;
269+
unkA4 = nullptr;
270+
271+
typedef JGadget::TList<SDLDrawBufToken*>::iterator I;
272+
for (I it = unkA0->unk8.begin(); it != unkA0->unk8.end(); ++it) {
273+
SDLDrawBufToken* token = *it;
179274

180-
void SDLModel::viewCalcSimple() { }
275+
bool found = token->unk0[0] == j3dSys.getDrawBuffer(0)
276+
&& token->unk0[1] == j3dSys.getDrawBuffer(1);
277+
278+
if (found) {
279+
unkA4 = token->unk8;
280+
token->unk8 = this;
281+
return;
282+
}
283+
}
284+
285+
SDLDrawBufToken* token = new SDLDrawBufToken;
286+
287+
token->unk0[0] = j3dSys.getDrawBuffer(0);
288+
token->unk0[1] = j3dSys.getDrawBuffer(1);
289+
token->unk8 = this;
290+
291+
unkA0->unk8.push_back(token);
292+
}
293+
294+
void SDLModel::viewCalcSimple()
295+
{
296+
swapDrawMtx();
297+
MtxPtr mA = gpCamera->getUnk1EC();
298+
for (int i = 0; i < mModelData->getDrawMtxNum(); ++i)
299+
MTXConcat(mA, mNodeMatrices[i], getDrawMtx(i));
300+
DCStoreRange(getDrawMtxPtr(), mModelData->getDrawMtxNum() * sizeof(Mtx));
301+
}

0 commit comments

Comments
 (0)