diff options
| author | Caroline Madsen <69010899+randomsalience@users.noreply.github.com> | 2023-11-08 22:56:00 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-08 19:56:00 -0800 |
| commit | 46d2283278000633218fddd6f0fd51593e5e94bf (patch) | |
| tree | 61bb4b4d0c6cfc5b8a201dd939149135d8c2c04b /include/JSystem/J3DGraphLoader | |
| parent | 557d0822e56fc287243535a825f7a0a534fa14bd (diff) | |
work on J3DModelLoader (#1982)
Diffstat (limited to 'include/JSystem/J3DGraphLoader')
| -rw-r--r-- | include/JSystem/J3DGraphLoader/J3DJointFactory.h | 14 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphLoader/J3DMaterialFactory.h | 61 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphLoader/J3DMaterialFactory_v21.h | 86 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphLoader/J3DModelLoader.h | 218 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphLoader/J3DShapeFactory.h | 18 |
5 files changed, 365 insertions, 32 deletions
diff --git a/include/JSystem/J3DGraphLoader/J3DJointFactory.h b/include/JSystem/J3DGraphLoader/J3DJointFactory.h index 2c7653b26d..5b6325d100 100644 --- a/include/JSystem/J3DGraphLoader/J3DJointFactory.h +++ b/include/JSystem/J3DGraphLoader/J3DJointFactory.h @@ -5,7 +5,7 @@ #include "dolphin/types.h" class J3DJoint; -struct ResNTAB; +struct J3DJointBlock; struct J3DJointInitData { /* 0x00 */ u16 mKind; @@ -16,18 +16,6 @@ struct J3DJointInitData { /* 0x2C */ Vec mMax; }; // Size: 0x30 -struct J3DJointBlock { - /* 0x00 */ u8 mMagic[4]; - /* 0x04 */ u32 mSize; - - /* 0x08 */ u16 mJointNum; - /* 0x0A */ u16 _pad; - - /* 0x0C */ J3DJointInitData* mJointInitData; - /* 0x10 */ u16* mIndexTable; - /* 0x14 */ ResNTAB* mNameTable; -}; - struct J3DJointFactory { /* 80337178 */ J3DJointFactory(J3DJointBlock const&); /* 803371D0 */ J3DJoint* create(int); diff --git a/include/JSystem/J3DGraphLoader/J3DMaterialFactory.h b/include/JSystem/J3DGraphLoader/J3DMaterialFactory.h index 50785d4c1e..f0c0e87f0c 100644 --- a/include/JSystem/J3DGraphLoader/J3DMaterialFactory.h +++ b/include/JSystem/J3DGraphLoader/J3DMaterialFactory.h @@ -1,6 +1,65 @@ #ifndef J3DMATERIALFACTORY_H #define J3DMATERIALFACTORY_H -#include "dolphin/types.h" +#include "JSystem/J3DGraphLoader/J3DModelLoader.h" + +class J3DMaterial; + +class J3DMaterialFactory { +public: + enum MaterialType { + MATERIAL_TYPE_NORMAL = 0, + MATERIAL_TYPE_LOCKED = 1, + MATERIAL_TYPE_PATCHED = 2, + }; + + /* 80330234 */ J3DMaterialFactory(J3DMaterialDLBlock const&); + /* 8032FFEC */ J3DMaterialFactory(J3DMaterialBlock const&); + /* 803302BC */ u16 countUniqueMaterials(); + /* 80330304 */ void countTexGens(int) const; + /* 8033033C */ void countStages(int) const; + /* 803303C4 */ J3DMaterial* create(J3DMaterial*, J3DMaterialFactory::MaterialType, int, u32) const; + /* 80330440 */ void createNormalMaterial(J3DMaterial*, int, u32) const; + /* 80330D84 */ void createPatchedMaterial(J3DMaterial*, int, u32) const; + /* 8033168C */ void modifyPatchedCurrentMtx(J3DMaterial*, int) const; + /* 803317D4 */ void createLockedMaterial(J3DMaterial*, int, u32) const; + /* 80331A7C */ void calcSize(J3DMaterial*, J3DMaterialFactory::MaterialType, int, u32) const; + /* 80331AFC */ void calcSizeNormalMaterial(J3DMaterial*, int, u32) const; + /* 80331C30 */ void calcSizePatchedMaterial(J3DMaterial*, int, u32) const; + /* 80331D00 */ void calcSizeLockedMaterial(J3DMaterial*, int, u32) const; + /* 80331D18 */ void newMatColor(int, int) const; + /* 80331D74 */ void newColorChanNum(int) const; + /* 80331DAC */ void newColorChan(int, int) const; + /* 80331F50 */ void newAmbColor(int, int) const; + /* 80331FAC */ void newTexGenNum(int) const; + /* 80331FE4 */ void newTexCoord(int, int) const; + /* 80332044 */ void newTexMtx(int, int) const; + /* 803320CC */ void newCullMode(int) const; + /* 8033210C */ void newTexNo(int, int) const; + /* 80332154 */ void newTevOrder(int, int) const; + /* 803321A0 */ void newTevColor(int, int) const; + /* 80332210 */ void newTevKColor(int, int) const; + /* 8033226C */ void newTevStageNum(int) const; + /* 803322A4 */ void newTevStage(int, int) const; + /* 80332304 */ void newTevSwapModeTable(int, int) const; + /* 803323A0 */ void newIndTexStageNum(int) const; + /* 803323C8 */ void newIndTexOrder(int, int) const; + /* 8033240C */ void newIndTexMtx(int, int) const; + /* 803324B4 */ void newIndTevStage(int, int) const; + /* 80332648 */ void newIndTexCoordScale(int, int) const; + /* 8033268C */ void newFog(int) const; + /* 80332768 */ void newAlphaComp(int) const; + /* 803327E8 */ void newBlend(int) const; + /* 8033282C */ void newZMode(int) const; + /* 8033288C */ void newZCompLoc(int) const; + /* 803328C4 */ void newDither(int) const; + /* 803328FC */ void newNBTScale(int) const; + + u16 getMaterialID(int i_idx) { return mpMaterialID[i_idx]; } + + /* 0x00 */ u8 field_0x00[8]; + /* 0x08 */ u16* mpMaterialID; + /* 0x0C */ u8 field_0x0c[0x7C]; +}; #endif /* J3DMATERIALFACTORY_H */ diff --git a/include/JSystem/J3DGraphLoader/J3DMaterialFactory_v21.h b/include/JSystem/J3DGraphLoader/J3DMaterialFactory_v21.h index 41e88bdec8..a2126d3a1e 100644 --- a/include/JSystem/J3DGraphLoader/J3DMaterialFactory_v21.h +++ b/include/JSystem/J3DGraphLoader/J3DMaterialFactory_v21.h @@ -1,6 +1,92 @@ #ifndef J3DMATERIALFACTORY_V21_H #define J3DMATERIALFACTORY_V21_H +#include "JSystem/J3DGraphLoader/J3DModelLoader.h" #include "dolphin/types.h" +#include "dolphin/gx/GXEnum.h" +#include "dolphin/gx/GXStruct.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: + /* 80332DA4 */ J3DMaterialFactory_v21(J3DMaterialBlock_v21 const&); + /* 80332F84 */ u16 countUniqueMaterials(); + /* 80332FA8 */ void countTexGens(int) const; + /* 80332FE0 */ void countStages(int) const; + /* 80333068 */ J3DMaterial* create(J3DMaterial*, int, u32) const; + /* 803337D8 */ void newMatColor(int, int) const; + /* 80333834 */ void newColorChanNum(int) const; + /* 8033386C */ void newColorChan(int, int) const; + /* 80333A10 */ void newTexGenNum(int) const; + /* 80333A48 */ void newTexCoord(int, int) const; + /* 80333AA8 */ void newTexMtx(int, int) const; + /* 80333B30 */ void newCullMode(int) const; + /* 80333B70 */ void newTexNo(int, int) const; + /* 80333BB8 */ void newTevOrder(int, int) const; + /* 80333C04 */ void newTevColor(int, int) const; + /* 80333C74 */ void newTevKColor(int, int) const; + /* 80333CD0 */ void newTevStageNum(int) const; + /* 80333D08 */ void newTevStage(int, int) const; + /* 80333D68 */ void newTevSwapModeTable(int, int) const; + /* 80333E04 */ void newFog(int) const; + /* 80333EE0 */ void newAlphaComp(int) const; + /* 80333F60 */ void newBlend(int) const; + /* 80333FA4 */ void newZMode(int) const; + /* 80334004 */ void newZCompLoc(int) const; + /* 8033403C */ void newDither(int) const; + /* 80334074 */ void newNBTScale(int) const; + + u16 getMaterialID(u16 idx) { return mpMaterialID[idx]; } + + /* 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 */ diff --git a/include/JSystem/J3DGraphLoader/J3DModelLoader.h b/include/JSystem/J3DGraphLoader/J3DModelLoader.h index deff8ed978..6913516d93 100644 --- a/include/JSystem/J3DGraphLoader/J3DModelLoader.h +++ b/include/JSystem/J3DGraphLoader/J3DModelLoader.h @@ -2,10 +2,226 @@ #define J3DMODELLOADER_H #include "dolphin/types.h" +#include "dolphin/mtx/mtx.h" + +class J3DModelData; +class J3DMaterialTable; +class J3DModelHierarchy; + +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 J3DEnvelopeBlock : 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 : public J3DModelBlock { + /* 0x08 */ u16 mJointNum; + /* 0x0C */ void* mpJointInitData; + /* 0x10 */ void* mpIndexTable; + /* 0x14 */ void* mpNameTable; +}; // size 0x18 + +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 : public J3DModelBlock { + /* 0x08 */ u16 mShapeNum; + /* 0x0C */ void* mpShapeInitData; + /* 0x10 */ void* mpIndexTable; + /* 0x14 */ void* mpNameTable; + /* 0x18 */ void* mpVtxDescList; + /* 0x1C */ void* mpMtxTable; + /* 0x20 */ void* mpDisplayListData; + /* 0x24 */ void* mpMtxInitData; + /* 0x28 */ void* mpDrawInitData; +}; // size 0x2C + +struct J3DTextureBlock : public J3DModelBlock { + /* 0x08 */ u16 mTextureNum; + /* 0x0C */ void* mpTextureRes; + /* 0x10 */ void* mpNameTable; +}; + +class J3DModelLoader { +public: + /* 8033468C */ J3DModelLoader(); + /* 80335048 */ void readInformation(J3DModelInfoBlock const*, u32); + /* 803351D0 */ void readVertex(J3DVertexBlock const*); + /* 803353F0 */ void readEnvelop(J3DEnvelopeBlock const*); + /* 80335480 */ void readDraw(J3DDrawBlock const*); + /* 80335530 */ void readJoint(J3DJointBlock const*); + /* 80335AF4 */ void readShape(J3DShapeBlock const*, u32); + /* 80335C18 */ void readTexture(J3DTextureBlock const*); + /* 80335F5C */ void readTextureTable(J3DTextureBlock const*); + /* 80336028 */ void readPatchedMaterial(J3DMaterialBlock const*, u32); + /* 80336168 */ void readMaterialDL(J3DMaterialDLBlock const*, u32); + /* 8033631C */ void modifyMaterial(u32); + + /* 80336CD8 */ u32 calcSizeInformation(J3DModelInfoBlock const*, u32); + /* 80336D64 */ u32 calcSizeJoint(J3DJointBlock const*); + /* 80336D90 */ u32 calcSizeEnvelope(J3DEnvelopeBlock const*); + /* 80336DA0 */ u32 calcSizeDraw(J3DDrawBlock const*); + /* 80336EA0 */ u32 calcSizeShape(J3DShapeBlock const*, u32); + /* 80336F44 */ u32 calcSizeTexture(J3DTextureBlock const*); + /* 80336FF0 */ u32 calcSizeTextureTable(J3DTextureBlock const*); + /* 80337010 */ u32 calcSizePatchedMaterial(J3DMaterialBlock const*, u32); + /* 803370A0 */ u32 calcSizeMaterialDL(J3DMaterialDLBlock const*, u32); + + // virtuals + /* 803347E0 */ J3DModelData* load(void const*, u32); + /* 80334ABC */ J3DMaterialTable* loadMaterialTable(void const*); + /* 80334C20 */ J3DModelData* loadBinaryDisplayList(void const*, u32); + /* 803367D4 */ u32 calcLoadSize(void const*, u32); + /* 803369A0 */ u32 calcLoadMaterialTableSize(void const*); + /* 80336A98 */ u32 calcLoadBinaryDisplayListSize(void const*, u32); + /* 80336794 */ u16 countMaterialNum(void const*); + /* 80334EE0 */ void setupBBoardInfo(); + /* 80336450 */ ~J3DModelLoader(); + /* 8033649C */ void readMaterial(J3DMaterialBlock const*, u32); + /* 80336498 */ void readMaterial_v21(J3DMaterialBlock_v21 const*, u32); + /* 803364A4 */ void readMaterialTable(J3DMaterialBlock const*, u32); + /* 803364A0 */ void readMaterialTable_v21(J3DMaterialBlock_v21 const*, u32); + /* 803364A8 */ u32 calcSizeMaterial(J3DMaterialBlock const*, u32); + /* 803364B0 */ u32 calcSizeMaterialTable(J3DMaterialBlock const*, u32); + + /* 0x00 */ void* _vtable; + /* 0x04 */ J3DModelData* mpModelData; + /* 0x08 */ J3DMaterialTable* mpMaterialTable; + /* 0x0C */ J3DShapeBlock const* mpShapeBlock; + /* 0x10 */ J3DMaterialBlock const* mpMaterialBlock; + /* 0x14 */ J3DModelHierarchy* mpModelHierarchy; + /* 0x18 */ u8 field_0x18; + /* 0x19 */ u8 field_0x19; + /* 0x1A */ u16 mEnvelopeSize; +}; + +class J3DModelLoader_v21 { // : public J3DModelLoader { +public: + /* 803363F4 */ ~J3DModelLoader_v21() {} + /* 80335890 */ void readMaterial_v21(J3DMaterialBlock_v21 const*, u32); + /* 80335E20 */ void readMaterialTable_v21(J3DMaterialBlock_v21 const*, u32); + + /* 0x00 */ void* _vtable; + /* 0x04 */ J3DModelData* mpModelData; + /* 0x08 */ J3DMaterialTable* mpMaterialTable; + /* 0x0C */ J3DShapeBlock const* mpShapeBlock; + /* 0x10 */ J3DMaterialBlock const* mpMaterialBlock; + /* 0x14 */ J3DModelHierarchy* mpModelHierarchy; + /* 0x18 */ u8 field_0x18; + /* 0x19 */ u8 field_0x19; + /* 0x1A */ u16 mEnvelopeSize; +}; + +class J3DModelLoader_v26 { // : public J3DModelLoader { +public: + /* 80336398 */ ~J3DModelLoader_v26() {} + /* 80335614 */ void readMaterial(J3DMaterialBlock const*, u32); + /* 80335CE4 */ void readMaterialTable(J3DMaterialBlock const*, u32); + /* 80336DB4 */ u32 calcSizeMaterial(J3DMaterialBlock const*, u32); + /* 80336F60 */ u32 calcSizeMaterialTable(J3DMaterialBlock const*, u32); + + /* 0x00 */ void* _vtable; + /* 0x04 */ J3DModelData* mpModelData; + /* 0x08 */ J3DMaterialTable* mpMaterialTable; + /* 0x0C */ J3DShapeBlock const* mpShapeBlock; + /* 0x10 */ J3DMaterialBlock const* mpMaterialBlock; + /* 0x14 */ J3DModelHierarchy* mpModelHierarchy; + /* 0x18 */ u8 field_0x18; + /* 0x19 */ u8 field_0x19; + /* 0x1A */ u16 mEnvelopeSize; +}; class J3DModelLoaderDataBase { public: - /* 803346BC */ static void* load(void const*, u32); + /* 803346BC */ static J3DModelData* load(void const* i_data, u32 i_flags); }; #endif /* J3DMODELLOADER_H */ diff --git a/include/JSystem/J3DGraphLoader/J3DShapeFactory.h b/include/JSystem/J3DGraphLoader/J3DShapeFactory.h index 63df909238..16afb48488 100644 --- a/include/JSystem/J3DGraphLoader/J3DShapeFactory.h +++ b/include/JSystem/J3DGraphLoader/J3DShapeFactory.h @@ -1,6 +1,7 @@ #ifndef J3DSHAPEFACTORY_H #define J3DSHAPEFACTORY_H +#include "JSystem/J3DGraphLoader/J3DModelLoader.h" #include "dolphin/gx/GXAttr.h" #include "dolphin/mtx/vec.h" @@ -31,23 +32,6 @@ struct J3DShapeDrawInitData { /* 0x04 */ u32 mDisplayListIndex; }; -struct J3DShapeBlock { - /* 0x00 */ u8 mMagic[4]; - /* 0x04 */ u32 mSize; - - /* 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; -}; - struct J3DShapeFactory { /* 80337350 */ J3DShapeFactory(J3DShapeBlock const&); /* 80337400 */ J3DShape* create(int, u32, GXVtxDescList*); |
