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
711void 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
1672SDLModelData::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
25101SDLMatPacket::SDLMatPacket () { }
26102
103+ void SDLMatPacket::beParasiteDL (J3DMatPacket*) { }
104+
105+ void SDLMatPacket::newSingleDL (u32 ) { }
106+
27107SDLModel::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+
36118void 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