J3DModelLoader 99%

mostly copied from TP decomp
This commit is contained in:
LagoLunatic
2023-12-18 19:54:29 -05:00
parent 3510a17d02
commit 457a32d3b8
19 changed files with 910 additions and 254 deletions
@@ -23,10 +23,10 @@ struct J3DJointBlock {
/* 0x08 */ u16 mJointNum;
/* 0x0A */ u16 _pad;
/* 0x0C */ J3DJointInitData* mJointInitData;
/* 0x10 */ u16* mIndexTable;
/* 0x14 */ ResNTAB* mNameTable;
};
/* 0x0C */ J3DJointInitData* mpJointInitData;
/* 0x10 */ u16* mpIndexTable;
/* 0x14 */ ResNTAB* mpNameTable;
}; // Size: 0x18
struct J3DJointFactory {
J3DJointFactory(J3DJointBlock const&);
@@ -3,4 +3,67 @@
#include "dolphin/types.h"
class J3DMaterial;
class J3DMaterialBlock;
class J3DMaterialDLBlock;
class J3DMaterialFactory {
public:
enum MaterialType {
MATERIAL_TYPE_NORMAL = 0,
MATERIAL_TYPE_LOCKED = 1,
MATERIAL_TYPE_PATCHED = 2,
};
J3DMaterialFactory(const J3DMaterialBlock&);
J3DMaterialFactory(const J3DMaterialDLBlock&);
u16 countUniqueMaterials();
void countTexGens(int) const;
void countStages(int) const;
J3DMaterial* create(J3DMaterial*, MaterialType, int, unsigned long) const;
void createNormalMaterial(J3DMaterial*, int, unsigned long) const;
void createPatchedMaterial(J3DMaterial*, int, unsigned long) const;
void modifyPatchedCurrentMtx(J3DMaterial*, int) const;
void createLockedMaterial(J3DMaterial*, int, unsigned long) const;
void calcSize(J3DMaterial*, MaterialType, int, unsigned long) const;
void calcSizeNormalMaterial(J3DMaterial*, int, unsigned long) const;
void calcSizePatchedMaterial(J3DMaterial*, int, unsigned long) const;
void calcSizeLockedMaterial(J3DMaterial*, int, unsigned long) const;
void newMatColor(int, int) const;
void newColorChanNum(int) const;
void newColorChan(int, int) const;
void newAmbColor(int, int) const;
void newTexGenNum(int) const;
void newTexCoord(int, int) const;
void newTexMtx(int, int) const;
void newCullMode(int) const;
void newTexNo(int, int) const;
void newTevOrder(int, int) const;
void newTevColor(int, int) const;
void newTevKColor(int, int) const;
void newTevStageNum(int) const;
void newTevStage(int, int) const;
void newTevSwapModeTable(int, int) const;
void newIndTexStageNum(int) const;
void newIndTexOrder(int, int) const;
void newIndTexMtx(int, int) const;
void newIndTevStage(int, int) const;
void newIndTexCoordScale(int, int) const;
void newFog(int) const;
void newAlphaComp(int) const;
void newBlend(int) const;
void newZMode(int) const;
void newZCompLoc(int) const;
void newDither(int) const;
void newNBTScale(int) const;
u16 getMaterialID(int i_idx) const { return mpMaterialID[i_idx]; }
void getMaterialMode(int) const {}
private:
/* 0x00 */ u8 field_0x00[8];
/* 0x08 */ u16* mpMaterialID;
/* 0x0C */ u8 field_0x0c[0x7C];
};
#endif /* J3DMATERIALFACTORY_H */
@@ -3,4 +3,88 @@
#include "dolphin/types.h"
class J3DMaterial;
class J3DMaterialInitData_v21;
class J3DIndInitData;
class J3DColorChanInfo;
class J3DLightInfo;
class J3DTexCoordInfo;
class J3DTexCoord2Info;
class J3DTexMtxInfo;
class J3DTevOrderInfo;
class J3DTevStageInfo;
class J3DTevSwapModeInfo;
class J3DTevSwapModeTableInfo;
class J3DFogInfo;
class J3DAlphaCompInfo;
class J3DBlendInfo;
class J3DZModeInfo;
class J3DNBTScaleInfo;
class J3DDisplayListInit;
class J3DPatchingInfo;
class J3DCurrentMtxInfo;
class J3DMaterialFactory_v21 {
public:
J3DMaterialFactory_v21(const J3DMaterialBlock_v21&);
u16 countUniqueMaterials();
void countTexGens(int) const;
void countStages(int) const;
J3DMaterial* create(J3DMaterial*, int, unsigned long) const;
void newMatColor(int, int) const;
void newColorChanNum(int) const;
void newColorChan(int, int) const;
void newTexGenNum(int) const;
void newTexCoord(int, int) const;
void newTexMtx(int, int) const;
void newCullMode(int) const;
void newTexNo(int, int) const;
void newTevOrder(int, int) const;
void newTevColor(int, int) const;
void newTevKColor(int, int) const;
void newTevStageNum(int) const;
void newTevStage(int, int) const;
void newTevSwapModeTable(int, int) const;
void newFog(int) const;
void newAlphaComp(int) const;
void newBlend(int) const;
void newZMode(int) const;
void newZCompLoc(int) const;
void newDither(int) const;
void newNBTScale(int) const;
u16 getMaterialID(int idx) const { return mpMaterialID[idx]; }
void getMaterialMode(int) const {}
/* 0x00 */ u16 mMaterialNum;
/* 0x04 */ J3DMaterialInitData_v21* field_0x04;
/* 0x08 */ u16* mpMaterialID;
/* 0x0C */ GXColor* field_0x0c;
/* 0x10 */ u8* field_0x10;
/* 0x14 */ J3DColorChanInfo* field_0x14;
/* 0x18 */ u8* field_0x18;
/* 0x1C */ J3DTexCoordInfo* field_0x1c;
/* 0x20 */ J3DTexCoord2Info* field_0x20;
/* 0x24 */ J3DTexMtxInfo* field_0x24;
/* 0x28 */ J3DTexMtxInfo* field_0x28;
/* 0x2C */ u16* field_0x2c;
/* 0x30 */ GXCullMode* field_0x30;
/* 0x34 */ J3DTevOrderInfo* field_0x34;
/* 0x38 */ GXColorS10* field_0x38;
/* 0x3C */ GXColor* field_0x3c;
/* 0x40 */ u8* field_0x40;
/* 0x44 */ J3DTevStageInfo* field_0x44;
/* 0x48 */ J3DTevSwapModeTableInfo* field_0x48;
/* 0x4C */ J3DFogInfo* field_0x4c;
/* 0x50 */ J3DAlphaCompInfo* field_0x50;
/* 0x54 */ J3DBlendInfo* field_0x54;
/* 0x58 */ J3DZModeInfo* field_0x58;
/* 0x5C */ u8* field_0x5c;
/* 0x60 */ u8* field_0x60;
/* 0x64 */ J3DNBTScaleInfo* field_0x64;
/* 0x68 */ u16 field_0x68;
/* 0x69 */ u8 field_0x69;
/* 0x6A */ u8 field_0x6a;
};
#endif /* J3DMATERIALFACTORY_V21_H */
+130 -15
View File
@@ -4,18 +4,116 @@
#include "dolphin/types.h"
#include "JSystem/J3DGraphAnimator/J3DModelData.h"
class J3DModelData;
class J3DMaterialTable;
class J3DModelInfoBlock;
class J3DVertexBlock;
class J3DEnvelopBlock;
class J3DDrawBlock;
class J3DJointBlock;
class J3DShapeBlock;
class J3DTextureBlock;
class J3DMaterialBlock;
class J3DMaterialBlock_v21;
class J3DMaterialDLBlock;
inline u32 getBdlFlag_MaterialType(u32 i_flags) {
return i_flags & 0x3000;
}
struct J3DModelBlock {
/* 0x00 */ u32 mBlockType;
/* 0x04 */ u32 mBlockSize;
};
struct J3DModelFileData {
/* 0x00 */ u32 mMagic1;
/* 0x04 */ u32 mMagic2;
/* 0x08 */ u8 field_0x08[4];
/* 0x0C */ u32 mBlockNum;
/* 0x10 */ u8 field_0x10[0x10];
/* 0x20 */ J3DModelBlock mBlocks[1];
};
struct J3DModelInfoBlock : public J3DModelBlock {
/* 0x08 */ u16 mFlags;
/* 0x0C */ u32 mPacketNum;
/* 0x10 */ u32 mVtxNum;
/* 0x14 */ void* mpHierarchy;
}; // Size: 0x18
struct J3DVertexBlock : public J3DModelBlock {
/* 0x08 */ void* mpVtxAttrFmtList;
/* 0x0C */ void* mpVtxPosArray;
/* 0x10 */ void* mpVtxNrmArray;
/* 0x14 */ void* mpVtxNBTArray;
/* 0x18 */ void* mpVtxColorArray[2];
/* 0x20 */ void* mpVtxTexCoordArray[8];
}; // Size: 0x40
struct J3DEnvelopBlock : public J3DModelBlock {
/* 0x08 */ u16 mWEvlpMtxNum;
/* 0x0C */ void* mpWEvlpMixMtxNum;
/* 0x10 */ void* mpWEvlpMixIndex;
/* 0x14 */ void* mpWEvlpMixWeight;
/* 0x18 */ void* mpInvJointMtx;
}; // Size: 0x1C
struct J3DDrawBlock : public J3DModelBlock {
/* 0x08 */ u16 mMtxNum;
/* 0x0C */ void* mpDrawMtxFlag;
/* 0x10 */ void* mpDrawMtxIndex;
}; // Size: 0x14
struct J3DJointBlock;
struct J3DMaterialBlock : public J3DModelBlock {
/* 0x08 */ u16 mMaterialNum;
/* 0x0C */ void* mpMaterialInitData;
/* 0x10 */ void* mpMaterialID;
/* 0x14 */ void* mpNameTable;
/* 0x18 */ void* mpIndInitData;
/* 0x1C */ void* mpCullMode;
/* 0x20 */ void* mpMatColor;
/* 0x24 */ void* mpColorChanNum;
/* 0x28 */ void* mpColorChanInfo;
/* 0x2C */ void* mpAmbColor;
/* 0x30 */ void* mpLightInfo;
/* 0x34 */ void* mpTexGenNum;
/* 0x38 */ void* mpTexCoordInfo;
/* 0x3C */ void* mpTexCoord2Info;
/* 0x40 */ void* mpTexMtxInfo;
/* 0x44 */ void* field_0x44;
/* 0x48 */ void* mpTexNo;
/* 0x4C */ void* mpTevOrderInfo;
/* 0x50 */ void* mpTevColor;
/* 0x54 */ void* mpTevKColor;
/* 0x58 */ void* mpTevStageNum;
/* 0x5C */ void* mpTevStageInfo;
/* 0x60 */ void* mpTevSwapModeInfo;
/* 0x64 */ void* mpTevSwapModeTableInfo;
/* 0x68 */ void* mpFogInfo;
/* 0x6C */ void* mpAlphaCompInfo;
/* 0x70 */ void* mpBlendInfo;
/* 0x74 */ void* mpZModeInfo;
/* 0x78 */ void* mpZCompLoc;
/* 0x7C */ void* mpDither;
/* 0x80 */ void* mpNBTScaleInfo;
};
struct J3DMaterialBlock_v21 : public J3DModelBlock {
/* 0x08 */ u16 mMaterialNum;
/* 0x0C */ void* field_0x0c;
/* 0x10 */ void* field_0x10;
/* 0x14 */ void* mpNameTable;
/* more */
};
struct J3DMaterialDLBlock : public J3DModelBlock {
/* 0x08 */ u16 mMaterialNum;
/* 0x0C */ void* field_0x0c;
/* 0x10 */ void* field_0x10;
/* 0x14 */ void* field_0x14;
/* 0x18 */ void* field_0x18;
/* 0x1C */ void* field_0x1c;
/* 0x20 */ void* mpNameTable;
/* more */
};
struct J3DShapeBlock;
struct J3DTextureBlock : public J3DModelBlock {
/* 0x08 */ u16 mTextureNum;
/* 0x0C */ void* mpTextureRes;
/* 0x10 */ void* mpNameTable;
};
class J3DModelLoaderDataBase {
public:
@@ -26,9 +124,17 @@ public:
class J3DModelLoader {
public:
virtual void load(const void*, u32);
virtual void loadMaterialTable(const void*);
virtual void loadBinaryDisplayList(const void*, u32);
J3DModelLoader() :
mpModelData(NULL),
mpMaterialTable(NULL),
mpShapeBlock(NULL),
mpMaterialBlock(NULL),
mpModelHierarchy(NULL),
field_0x18(0) {}
virtual J3DModelData* load(const void*, u32);
virtual J3DMaterialTable* loadMaterialTable(const void*);
virtual J3DModelData* loadBinaryDisplayList(const void*, u32);
virtual void calcLoadSize(const void*, u32);
virtual void calcLoadMaterialTableSize(const void*);
virtual void calcLoadBinaryDisplayListSize(const void*, u32);
@@ -60,6 +166,15 @@ public:
void calcSizeTextureTable(const J3DTextureBlock*);
void calcSizePatchedMaterial(const J3DMaterialBlock*, u32);
void calcSizeMaterialDL(const J3DMaterialDLBlock*, u32);
protected:
/* 0x04 */ J3DModelData* mpModelData;
/* 0x08 */ J3DMaterialTable* mpMaterialTable;
/* 0x0C */ const J3DShapeBlock* mpShapeBlock;
/* 0x10 */ const J3DMaterialBlock* mpMaterialBlock;
/* 0x14 */ J3DModelHierarchy* mpModelHierarchy;
/* 0x18 */ u8 field_0x18;
/* 0x19 */ u8 field_0x19;
};
class J3DModelLoader_v21 : public J3DModelLoader {
@@ -38,18 +38,18 @@ struct J3DShapeBlock {
/* 0x08 */ u16 mShapeNum;
/* 0x0A */ u16 _pad;
/* 0x0C */ J3DShapeInitData* mShapeInitData;
/* 0x10 */ u16* mIndexTable;
/* 0x14 */ ResNTAB* mNameTable;
/* 0x18 */ GXVtxDescList* mVtxDescList;
/* 0x1C */ u16* mMtxTable;
/* 0x20 */ u8* mDisplayListData;
/* 0x24 */ J3DShapeMtxInitData* mMtxInitData;
/* 0x28 */ J3DShapeDrawInitData* mDrawInitData;
};
/* 0x0C */ J3DShapeInitData* mpShapeInitData;
/* 0x10 */ u16* mpIndexTable;
/* 0x14 */ ResNTAB* mpNameTable;
/* 0x18 */ GXVtxDescList* mpVtxDescList;
/* 0x1C */ u16* mpMtxTable;
/* 0x20 */ u8* mpDisplayListData;
/* 0x24 */ J3DShapeMtxInitData* mpMtxInitData;
/* 0x28 */ J3DShapeDrawInitData* mpDrawInitData;
}; // Size: 0x2C
struct J3DShapeFactory {
J3DShapeFactory(J3DShapeBlock const&);
J3DShapeFactory(const J3DShapeBlock&);
J3DShape* create(int, u32, GXVtxDescList*);
J3DShapeMtx* newShapeMtx(u32, int, int) const;
J3DShapeDraw* newShapeDraw(int, int) const;
@@ -58,21 +58,20 @@ struct J3DShapeFactory {
s32 calcSizeVcdVatCmdBuffer(u32);
s32 calcSizeShapeMtx(u32, int, int) const;
/* 0x00 */ J3DShapeInitData* mShapeInitData;
/* 0x04 */ u16* mIndexTable;
/* 0x08 */ GXVtxDescList* mVtxDescList;
/* 0x0C */ u16* mMtxTable;
/* 0x10 */ u8* mDisplayListData;
/* 0x14 */ J3DShapeMtxInitData* mMtxInitData;
/* 0x18 */ J3DShapeDrawInitData* mDrawInitData;
/* 0x1C */ u8* mVcdVatCmdBuffer;
/* 0x00 */ J3DShapeInitData* mpShapeInitData;
/* 0x04 */ u16* mpIndexTable;
/* 0x08 */ GXVtxDescList* mpVtxDescList;
/* 0x0C */ u16* mpMtxTable;
/* 0x10 */ u8* mpDisplayListData;
/* 0x14 */ J3DShapeMtxInitData* mpMtxInitData;
/* 0x18 */ J3DShapeDrawInitData* mpDrawInitData;
/* 0x1C */ u8* mpVcdVatCmdBuffer;
u32 getMtxGroupNum(int no) const { return mShapeInitData[mIndexTable[no]].mMtxGroupNum; }
GXVtxDescList* getVtxDescList(int no) const { return (GXVtxDescList*)((u8*)mVtxDescList + mShapeInitData[mIndexTable[no]].mVtxDescListIndex); }
f32 getRadius(int no) const { return mShapeInitData[mIndexTable[no]].mRadius; }
Vec& getMin(int no) const { return mShapeInitData[mIndexTable[no]].mMin; }
Vec& getMax(int no) const { return mShapeInitData[mIndexTable[no]].mMax; }
u32 getMtxGroupNum(int no) const { return mpShapeInitData[mpIndexTable[no]].mMtxGroupNum; }
GXVtxDescList* getVtxDescList(int no) const { return (GXVtxDescList*)((u8*)mpVtxDescList + mpShapeInitData[mpIndexTable[no]].mVtxDescListIndex); }
f32 getRadius(int no) const { return mpShapeInitData[mpIndexTable[no]].mRadius; }
Vec& getMin(int no) const { return mpShapeInitData[mpIndexTable[no]].mMin; }
Vec& getMax(int no) const { return mpShapeInitData[mpIndexTable[no]].mMax; }
};
#endif /* J3DSHAPEFACTORY_H */
#endif /* J3DSHAPEFACTORY_H */