mirror of
https://github.com/zeldaret/tww.git
synced 2026-08-14 20:30:18 -04:00
J3DModelLoader 99%
mostly copied from TP decomp
This commit is contained in:
@@ -137,6 +137,7 @@ public:
|
||||
void setOldMtxCalc(J3DMtxCalc* i_mtxCalc) { mOldMtxCalc = i_mtxCalc; }
|
||||
J3DMtxCalc* getOldMtxCalc() { return mOldMtxCalc; }
|
||||
J3DMtxCalc* getCurrentMtxCalc() { return mCurrentMtxCalc; };
|
||||
void setMtxType(u8 type) { mKind = (mKind & ~0xf0) | (type << 4); }
|
||||
|
||||
static J3DMtxCalc* mCurrentMtxCalc;
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ public:
|
||||
J3DJointTree() { clear(); }
|
||||
void clear();
|
||||
void makeHierarchy(J3DNode*, const J3DModelHierarchy**, J3DMaterialTable*, J3DShape**);
|
||||
void findImportantMtxIndex();
|
||||
|
||||
virtual ~J3DJointTree() {}
|
||||
|
||||
@@ -42,21 +41,31 @@ public:
|
||||
u16 getWEvlpMtxNum() const { return mWEvlpMtxNum; }
|
||||
u8 getWEvlpMixMtxNum(u16 idx) const { return mWEvlpMixMtxNum[idx]; }
|
||||
u16 * getWEvlpMixIndex() const { return mWEvlpMixIndex; }
|
||||
f32 * getWEvlpMixWeight() const { return mWEvlpMixWeight; }
|
||||
f32 * getWEvlpMixWeight() { return mWEvlpMixWeight; }
|
||||
u16 getDrawFullWgtMtxNum() const { return mDrawMtxData.mDrawFullWgtMtxNum; }
|
||||
u16 getJointNum() const { return mJointNum; }
|
||||
u16 getDrawMtxNum() const { return mDrawMtxData.mEntryNum; }
|
||||
u8 getDrawMtxFlag(u16 idx) const { return mDrawMtxData.mDrawMtxFlag[idx]; }
|
||||
u16 getDrawMtxIndex(u16 idx) const { return mDrawMtxData.mDrawMtxIndex[idx]; }
|
||||
JUTNameTab* getJointName() const { return mJointName; }
|
||||
const J3DModelHierarchy* getHierarchy() const { return mHierarchy; }
|
||||
void setHierarchy(J3DModelHierarchy* hierarchy) { mHierarchy = hierarchy; }
|
||||
void setBasicMtxCalc(J3DMtxCalc* calc) { mBasicMtxCalc = calc; }
|
||||
J3DJoint* getRootNode() { return mRootNode; }
|
||||
J3DJoint* getJointNodePointer(u16 idx) const { return mJointNodePointer[idx]; }
|
||||
J3DMtxCalc* getBasicMtxCalc() const { return mBasicMtxCalc; }
|
||||
Mtx& getInvJointMtx(s32 idx) const { return mInvJointMtx[idx]; }
|
||||
J3DMtxCalc* getBasicMtxCalc() { return mBasicMtxCalc; }
|
||||
Mtx& getInvJointMtx(int idx) { return mInvJointMtx[idx]; }
|
||||
u32 getModelDataType() const { return mModelDataType; }
|
||||
void setModelDataType(u32 type) { mModelDataType = type; }
|
||||
bool checkFlag(u32 flag) { return mFlags & flag; }
|
||||
void setFlag(u32 flag) { mFlags = flag; }
|
||||
|
||||
// TODO
|
||||
void getWEvlpMixMtxIndex() {}
|
||||
|
||||
private:
|
||||
friend class J3DModelLoader;
|
||||
|
||||
/* 0x04 */ J3DModelHierarchy* mHierarchy;
|
||||
/* 0x08 */ u32 mFlags;
|
||||
/* 0x0C */ u32 mModelDataType;
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
|
||||
virtual ~J3DMaterialTable();
|
||||
|
||||
J3DMaterial* getMaterialNodePointer(const u16 idx) const { return mMaterialNodePointer[idx]; }
|
||||
J3DMaterial* getMaterialNodePointer(u16 idx) const { return mMaterialNodePointer[idx]; }
|
||||
|
||||
J3DTexture* getTexture() const { return mTexture; }
|
||||
JUTNameTab* getTextureName() const { return mTextureName; }
|
||||
@@ -45,17 +45,19 @@ public:
|
||||
JUTNameTab* getMaterialName() const { return mMaterialName; }
|
||||
|
||||
u16 getMaterialNum() const { return mMaterialNum; }
|
||||
bool isLocked() const { return field_0x20 == 1; }
|
||||
bool isLocked() { return field_0x20 == 1; }
|
||||
|
||||
private:
|
||||
friend class J3DJointTree;
|
||||
friend class J3DModelLoader;
|
||||
friend class J3DModelLoader_v26;
|
||||
friend class J3DModelLoader_v21;
|
||||
|
||||
/* 0x04 */ u16 mMaterialNum;
|
||||
/* 0x06 */ u16 mUniqueMatNum;
|
||||
/* 0x08 */ J3DMaterial** mMaterialNodePointer;
|
||||
/* 0x0C */ JUTNameTab* mMaterialName;
|
||||
/* 0x10 */ u16 field_0x10;
|
||||
/* 0x14 */ u32 field_0x14;
|
||||
/* 0x10 */ u16 mUniqueMatNum;
|
||||
/* 0x14 */ J3DMaterial* field_0x14;
|
||||
/* 0x18 */ J3DTexture* mTexture;
|
||||
/* 0x1C */ JUTNameTab* mTextureName;
|
||||
/* 0x20 */ u16 field_0x20;
|
||||
|
||||
@@ -17,6 +17,12 @@ enum J3DMaterialCopyFlag {
|
||||
J3DMatCopyFlag_All = 0x03,
|
||||
};
|
||||
|
||||
enum {
|
||||
J3DMdlDataFlag_ConcatView = 0x10,
|
||||
J3DMdlDataFlag_NoUseDrawMtx = 0x20,
|
||||
J3DMdlDataFlag_NoAnimation = 0x100,
|
||||
};
|
||||
|
||||
class J3DModelData {
|
||||
public:
|
||||
void clear();
|
||||
@@ -63,6 +69,10 @@ public:
|
||||
f32* getWEvlpMixWeight() { return mJointTree.getWEvlpMixWeight(); }
|
||||
u8 getWEvlpMixMtxNum(u16 idx) const { return mJointTree.getWEvlpMixMtxNum(idx); }
|
||||
u32 getModelDataType() const { return mJointTree.getModelDataType(); }
|
||||
const J3DModelHierarchy* getHierarchy() const { return mJointTree.getHierarchy(); }
|
||||
void setHierarchy(J3DModelHierarchy* hierarchy) { mJointTree.setHierarchy(hierarchy); }
|
||||
void setBasicMtxCalc(J3DMtxCalc* calc) { mJointTree.setBasicMtxCalc(calc); }
|
||||
void setModelDataType(u32 type) { mJointTree.setModelDataType(type); }
|
||||
GXColor* getVtxColorArray(u8 idx) const { return mVertexData.getVtxColorArray(idx); }
|
||||
bool checkFlag(u32 flag) const { return (mFlags & flag) ? true : false; }
|
||||
u32 getFlag() const { return mFlags; }
|
||||
@@ -83,23 +93,24 @@ public:
|
||||
int removeMatColorAnimator(J3DAnmColor* anm) {
|
||||
return mMaterialTable.removeMatColorAnimator(anm);
|
||||
}
|
||||
void makeHierarchy(J3DNode* joint, const J3DModelHierarchy** hierarchy) {
|
||||
mJointTree.makeHierarchy(joint, hierarchy, &mMaterialTable, mShapeTable.mShapeNodePointer);
|
||||
initShapeNodes();
|
||||
}
|
||||
|
||||
// TODO
|
||||
void entryMatColorAnimator(J3DAnmColor*) {}
|
||||
void getBasicMtxCalc() {}
|
||||
void getBinary() {}
|
||||
void getHierarchy() const {}
|
||||
void getRootNode() {}
|
||||
void makeHierarchy(J3DNode*, const J3DModelHierarchy**) {}
|
||||
void setBasicMtxCalc(J3DMtxCalc*) {}
|
||||
void setHierarchy(J3DModelHierarchy*) {}
|
||||
void setMatColorAnimator(J3DAnmColor*, J3DMatColorAnm*) {}
|
||||
void setModelDataType(u32) {}
|
||||
void setTexMtxAnimator(J3DAnmTextureSRTKey*, J3DTexMtxAnm*, J3DTexMtxAnm*) {}
|
||||
void setTexNoAnimator(J3DAnmTexPattern*, J3DTexNoAnm*) {}
|
||||
|
||||
private:
|
||||
/* 0x04 */ void* mpRawData;
|
||||
friend class J3DModelLoader;
|
||||
|
||||
/* 0x04 */ const void* mpRawData;
|
||||
/* 0x08 */ u32 mFlags;
|
||||
/* 0x0C */ u16 mbHasBumpArray;
|
||||
/* 0x0E */ u16 mbHasBillboard;
|
||||
|
||||
@@ -17,6 +17,9 @@ public:
|
||||
J3DShape* getShapeNodePointer(u16 idx) const { return mShapeNodePointer[idx]; }
|
||||
|
||||
private:
|
||||
friend class J3DModelLoader;
|
||||
friend class J3DModelData;
|
||||
|
||||
/* 0x0 */ u16 mShapeNum;
|
||||
/* 0x4 */ J3DShape** mShapeNodePointer;
|
||||
}; // Size: 0x08
|
||||
|
||||
@@ -41,6 +41,9 @@ public:
|
||||
virtual void reset();
|
||||
virtual void change();
|
||||
|
||||
J3DMaterial() { initialize(); }
|
||||
~J3DMaterial() {}
|
||||
|
||||
J3DMaterial* getNext() const { return mNext; }
|
||||
void setNext(J3DMaterial* material) {mNext = material; }
|
||||
J3DShape* getShape() const { return mShape; }
|
||||
|
||||
@@ -34,10 +34,12 @@ private:
|
||||
/* 0x4 */ ResTIMG* mpRes;
|
||||
|
||||
public:
|
||||
J3DTexture(u16 num, ResTIMG* res) : mNum(num), mpRes(res) {}
|
||||
virtual ~J3DTexture() {}
|
||||
|
||||
void loadGX(u16, _GXTexMapID) const;
|
||||
void entryNum(u16);
|
||||
void addResTIMG(u16, ResTIMG const*);
|
||||
virtual ~J3DTexture();
|
||||
|
||||
u16 getNum() const { return mNum; }
|
||||
ResTIMG* getResTIMG(u16 entry) const { return &mpRes[entry]; }
|
||||
|
||||
@@ -26,18 +26,18 @@ public:
|
||||
|
||||
inline void clear() { mPacketNum = 0; }
|
||||
|
||||
void* getVtxPosArray() const { return mVtxPosArray; }
|
||||
void* getVtxNrmArray() const { return mVtxNrmArray; }
|
||||
void* getVtxPosArray() { return mVtxPosArray; }
|
||||
void* getVtxNrmArray() { return mVtxNrmArray; }
|
||||
GXColor* getVtxColorArray(u8 idx) const { return mVtxColorArray[idx]; }
|
||||
void* getVtxTexCoordArray(u8 idx) const { return mVtxTexCoordArray[idx]; }
|
||||
void* getVtxNBTArray() const { return mVtxNBTArray; }
|
||||
void* getVtxTexCoordArray(u8 idx) { return mVtxTexCoordArray[idx]; }
|
||||
void* getVtxNBTArray() { return mVtxNBTArray; }
|
||||
u32 getNrmNum() const { return mNrmNum; }
|
||||
u32 getVtxNum() const { return mVtxNum; }
|
||||
GXVtxAttrFmtList* getVtxAttrFmtList() { return mVtxAttrFmtList; }
|
||||
u8 getVtxPosFrac() { return mVtxPosFrac; }
|
||||
u8 getVtxNrmFrac() { return mVtxNrmFrac; }
|
||||
int getVtxPosType() { return mVtxPosType; }
|
||||
int getVtxNrmType() { return mVtxNrmType; }
|
||||
u8 getVtxPosFrac() const { return mVtxPosFrac; }
|
||||
u8 getVtxNrmFrac() const { return mVtxNrmFrac; }
|
||||
int getVtxPosType() const { return mVtxPosType; }
|
||||
int getVtxNrmType() const { return mVtxNrmType; }
|
||||
|
||||
void setVtxPosFrac(u8 frac) { mVtxPosFrac = frac; }
|
||||
void setVtxPosType(GXCompType type) { mVtxPosType = type; }
|
||||
@@ -45,6 +45,8 @@ public:
|
||||
void setVtxNrmType(GXCompType type) { mVtxNrmType = type; }
|
||||
|
||||
private:
|
||||
friend class J3DModelLoader;
|
||||
|
||||
/* 0x00 */ u32 mVtxNum;
|
||||
/* 0x04 */ u32 mNrmNum;
|
||||
/* 0x08 */ u32 mColNum;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -12,7 +12,7 @@ void J3DMaterialTable::clear() {
|
||||
mMaterialNum = 0;
|
||||
mMaterialNodePointer = NULL;
|
||||
mMaterialName = NULL;
|
||||
field_0x10 = NULL;
|
||||
mUniqueMatNum = 0;
|
||||
field_0x14 = NULL;
|
||||
mTexture = NULL;
|
||||
mTextureName = NULL;
|
||||
|
||||
@@ -60,12 +60,6 @@ void J3DModel::initialize() {
|
||||
mpVisibilityManager = NULL;
|
||||
}
|
||||
|
||||
enum {
|
||||
J3DMdlDataFlag_ConcatView = 0x10,
|
||||
J3DMdlDataFlag_NoUseDrawMtx = 0x20,
|
||||
J3DMdlDataFlag_NoAnimation = 0x100,
|
||||
};
|
||||
|
||||
static inline u32 getMdlDataFlag_MtxLoadType(u32 flag) {
|
||||
return flag & 0xF0;
|
||||
}
|
||||
@@ -453,7 +447,7 @@ s32 J3DModel::setSkinDeform(J3DSkinDeform* pSkinDeform, u32 flags) {
|
||||
} else {
|
||||
mpSkinDeform->initMtxIndexArray(mModelData);
|
||||
|
||||
ret = mModelData->checkFlag(0x100);
|
||||
ret = mModelData->checkFlag(J3DMdlDataFlag_NoAnimation);
|
||||
if (ret != J3DErrType_Success) {
|
||||
mpSkinDeform->changeFastSkinDL(mModelData);
|
||||
flags &= ~2;
|
||||
@@ -643,7 +637,7 @@ void J3DModel::viewCalc() {
|
||||
swapDrawMtx();
|
||||
swapNrmMtx();
|
||||
|
||||
if (mModelData->checkFlag(0x20)) {
|
||||
if (mModelData->checkFlag(J3DMdlDataFlag_NoUseDrawMtx)) {
|
||||
if (getMtxCalcMode() == 2)
|
||||
calcViewBaseMtx(j3dSys.getViewMtx(), mBaseScale, mBaseTransformMtx, (MtxP)&mViewBaseMtx);
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
/* 802FE1A4-802FE1FC .text __ct__15J3DJointFactoryFRC13J3DJointBlock */
|
||||
J3DJointFactory::J3DJointFactory(const J3DJointBlock& jointBlock) {
|
||||
/* Nonmatching */
|
||||
mJointInitData = JSUConvertOffsetToPtr<J3DJointInitData>(&jointBlock, jointBlock.mJointInitData);
|
||||
mIndexTable = JSUConvertOffsetToPtr<u16>(&jointBlock, jointBlock.mIndexTable);
|
||||
mJointInitData = JSUConvertOffsetToPtr<J3DJointInitData>(&jointBlock, jointBlock.mpJointInitData);
|
||||
mIndexTable = JSUConvertOffsetToPtr<u16>(&jointBlock, jointBlock.mpIndexTable);
|
||||
}
|
||||
|
||||
/* 802FE1FC-802FE390 .text create__15J3DJointFactoryFi */
|
||||
|
||||
@@ -17,7 +17,7 @@ J3DMaterialFactory::J3DMaterialFactory(const J3DMaterialDLBlock&) {
|
||||
}
|
||||
|
||||
/* 802F6BC0-802F6C08 .text countUniqueMaterials__18J3DMaterialFactoryFv */
|
||||
void J3DMaterialFactory::countUniqueMaterials() {
|
||||
u16 J3DMaterialFactory::countUniqueMaterials() {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ void J3DMaterialFactory::countStages(int) const {
|
||||
}
|
||||
|
||||
/* 802F6CC8-802F6D44 .text create__18J3DMaterialFactoryCFP11J3DMaterialQ218J3DMaterialFactory12MaterialTypeiUl */
|
||||
void J3DMaterialFactory::create(J3DMaterial*, J3DMaterialFactory::MaterialType, int, unsigned long) const {
|
||||
J3DMaterial* J3DMaterialFactory::create(J3DMaterial*, J3DMaterialFactory::MaterialType, int, unsigned long) const {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
@@ -310,123 +310,3 @@ J3DTevStage::J3DTevStage(const J3DTevStageInfo&) {
|
||||
J3DMaterial::~J3DMaterial() {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F9848-802F9860 .text JSUConvertOffsetToPtr<17J3DCurrentMtxInfo>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DCurrentMtxInfo>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F9860-802F9878 .text JSUConvertOffsetToPtr<15J3DPatchingInfo>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DPatchingInfo>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F9878-802F9890 .text JSUConvertOffsetToPtr<18J3DDisplayListInit>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DDisplayListInit>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F9890-802F98A8 .text JSUConvertOffsetToPtr<15J3DNBTScaleInfo>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DNBTScaleInfo>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F98A8-802F98C0 .text JSUConvertOffsetToPtr<12J3DZModeInfo>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DZModeInfo>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F98C0-802F98D8 .text JSUConvertOffsetToPtr<12J3DBlendInfo>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DBlendInfo>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F98D8-802F98F0 .text JSUConvertOffsetToPtr<16J3DAlphaCompInfo>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DAlphaCompInfo>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F98F0-802F9908 .text JSUConvertOffsetToPtr<10J3DFogInfo>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DFogInfo>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F9908-802F9920 .text JSUConvertOffsetToPtr<23J3DTevSwapModeTableInfo>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DTevSwapModeTableInfo>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F9920-802F9938 .text JSUConvertOffsetToPtr<18J3DTevSwapModeInfo>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DTevSwapModeInfo>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F9938-802F9950 .text JSUConvertOffsetToPtr<15J3DTevStageInfo>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DTevStageInfo>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F9950-802F9968 .text JSUConvertOffsetToPtr<11_GXColorS10>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<_GXColorS10>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F9968-802F9980 .text JSUConvertOffsetToPtr<15J3DTevOrderInfo>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DTevOrderInfo>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F9980-802F9998 .text JSUConvertOffsetToPtr<13J3DTexMtxInfo>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DTexMtxInfo>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F9998-802F99B0 .text JSUConvertOffsetToPtr<16J3DTexCoord2Info>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DTexCoord2Info>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F99B0-802F99C8 .text JSUConvertOffsetToPtr<15J3DTexCoordInfo>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DTexCoordInfo>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F99C8-802F99E0 .text JSUConvertOffsetToPtr<12J3DLightInfo>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DLightInfo>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F99E0-802F99F8 .text JSUConvertOffsetToPtr<16J3DColorChanInfo>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DColorChanInfo>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F99F8-802F9A10 .text JSUConvertOffsetToPtr<Uc>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<unsigned char>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F9A10-802F9A28 .text JSUConvertOffsetToPtr<8_GXColor>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<_GXColor>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F9A28-802F9A40 .text JSUConvertOffsetToPtr<11_GXCullMode>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<_GXCullMode>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F9A40-802F9A58 .text JSUConvertOffsetToPtr<14J3DIndInitData>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DIndInitData>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F9A58-802F9A70 .text JSUConvertOffsetToPtr<Us>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<unsigned short>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F9A70-802F9A88 .text JSUConvertOffsetToPtr<19J3DMaterialInitData>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DMaterialInitData>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ J3DMaterialFactory_v21::J3DMaterialFactory_v21(const J3DMaterialBlock_v21&) {
|
||||
}
|
||||
|
||||
/* 802F9C68-802F9C8C .text countUniqueMaterials__22J3DMaterialFactory_v21Fv */
|
||||
void J3DMaterialFactory_v21::countUniqueMaterials() {
|
||||
u16 J3DMaterialFactory_v21::countUniqueMaterials() {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ void J3DMaterialFactory_v21::countStages(int) const {
|
||||
}
|
||||
|
||||
/* 802F9D4C-802FA4C0 .text create__22J3DMaterialFactory_v21CFP11J3DMaterialiUl */
|
||||
void J3DMaterialFactory_v21::create(J3DMaterial*, int, unsigned long) const {
|
||||
J3DMaterial* J3DMaterialFactory_v21::create(J3DMaterial*, int, unsigned long) const {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
@@ -135,8 +135,3 @@ void J3DMaterialFactory_v21::newDither(int) const {
|
||||
void J3DMaterialFactory_v21::newNBTScale(int) const {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802FB034-802FB04C .text JSUConvertOffsetToPtr<23J3DMaterialInitData_v21>__FPCvPCv */
|
||||
void JSUConvertOffsetToPtr<J3DMaterialInitData_v21>(const void*, const void*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
@@ -4,119 +4,612 @@
|
||||
//
|
||||
|
||||
#include "JSystem/J3DGraphLoader/J3DModelLoader.h"
|
||||
#include "dolphin/types.h"
|
||||
#include "JSystem/J3DGraphLoader/J3DMaterialFactory.h"
|
||||
#include "JSystem/J3DGraphLoader/J3DMaterialFactory_v21.h"
|
||||
#include "JSystem/J3DGraphLoader/J3DShapeFactory.h"
|
||||
#include "JSystem/J3DGraphLoader/J3DJointFactory.h"
|
||||
#include "JSystem/JUtility/JUTNameTab.h"
|
||||
#include "JSystem/JSupport/JSupport.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "dolphin/os/OS.h"
|
||||
|
||||
/* 802FB758-802FB8A4 .text load__22J3DModelLoaderDataBaseFPCvUl */
|
||||
J3DModelData* J3DModelLoaderDataBase::load(const void*, u32) {
|
||||
/* Nonmatching */
|
||||
J3DModelData* J3DModelLoaderDataBase::load(const void* i_data, u32 i_flags) {
|
||||
if (i_data == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (*(u32*)i_data == 'J3D1' && *(u32*)((u32)i_data + 4) == 'bmd1') {
|
||||
return NULL;
|
||||
}
|
||||
if (*(u32*)i_data == 'J3D2' && *(u32*)((u32)i_data + 4) == 'bmd2') {
|
||||
J3DModelLoader_v21 loader;
|
||||
return loader.load(i_data, i_flags);
|
||||
}
|
||||
if (*(u32*)i_data == 'J3D2' && *(u32*)((u32)i_data + 4) == 'bmd3') {
|
||||
J3DModelLoader_v26 loader;
|
||||
return loader.load(i_data, i_flags);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 802FB8A4-802FB94C .text loadMaterialTable__22J3DModelLoaderDataBaseFPCv */
|
||||
J3DMaterialTable* J3DModelLoaderDataBase::loadMaterialTable(const void*) {
|
||||
/* Nonmatching */
|
||||
J3DMaterialTable* J3DModelLoaderDataBase::loadMaterialTable(const void* i_data) {
|
||||
if (!i_data) {
|
||||
return NULL;
|
||||
}
|
||||
if (*(u32*)i_data == 'J3D2' && *(u32*)((u32)i_data + 4) == 'bmt3') {
|
||||
J3DModelLoader_v26 loader;
|
||||
return loader.loadMaterialTable(i_data);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 802FB94C-802FBA04 .text loadBinaryDisplayList__22J3DModelLoaderDataBaseFPCvUl */
|
||||
J3DModelData* J3DModelLoaderDataBase::loadBinaryDisplayList(const void*, u32) {
|
||||
/* Nonmatching */
|
||||
J3DModelData* J3DModelLoaderDataBase::loadBinaryDisplayList(const void* i_data, u32 i_flags) {
|
||||
if (!i_data) {
|
||||
return NULL;
|
||||
}
|
||||
if (*(u32*)i_data == 'J3D2') {
|
||||
u32 file_type = *(u32*)((u32)i_data + 4);
|
||||
if (file_type == 'bdl3' || file_type == 'bdl4') {
|
||||
J3DModelLoader_v26 loader;
|
||||
return loader.loadBinaryDisplayList(i_data, i_flags);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 802FBA04-802FBCC4 .text load__14J3DModelLoaderFPCvUl */
|
||||
void J3DModelLoader::load(const void*, u32) {
|
||||
/* Nonmatching */
|
||||
J3DModelData* J3DModelLoader::load(const void* i_data, u32 i_flags) {
|
||||
JKRGetCurrentHeap()->getTotalFreeSize();
|
||||
mpModelData = new J3DModelData();
|
||||
mpModelData->clear();
|
||||
mpModelData->mpRawData = i_data;
|
||||
mpModelData->setModelDataType(0);
|
||||
mpMaterialTable = &mpModelData->mMaterialTable;
|
||||
const J3DModelFileData* data = (J3DModelFileData*)i_data;
|
||||
const J3DModelBlock* block = data->mBlocks;
|
||||
for (u32 block_no = 0; block_no < data->mBlockNum; block_no++) {
|
||||
switch (block->mBlockType) {
|
||||
case 'INF1':
|
||||
readInformation((J3DModelInfoBlock*)block, (u32)i_flags); // cast fixes regalloc
|
||||
break;
|
||||
case 'VTX1':
|
||||
readVertex((J3DVertexBlock*)block);
|
||||
break;
|
||||
case 'EVP1':
|
||||
readEnvelop((J3DEnvelopBlock*)block);
|
||||
break;
|
||||
case 'DRW1':
|
||||
readDraw((J3DDrawBlock*)block);
|
||||
break;
|
||||
case 'JNT1':
|
||||
readJoint((J3DJointBlock*)block);
|
||||
break;
|
||||
case 'MAT3':
|
||||
readMaterial((J3DMaterialBlock*)block, i_flags);
|
||||
break;
|
||||
case 'MAT2':
|
||||
readMaterial_v21((J3DMaterialBlock_v21*)block, i_flags);
|
||||
break;
|
||||
case 'SHP1':
|
||||
readShape((J3DShapeBlock*)block, i_flags);
|
||||
break;
|
||||
case 'TEX1':
|
||||
readTexture((J3DTextureBlock*)block);
|
||||
break;
|
||||
default:
|
||||
OSReport("Unknown data block\n");
|
||||
break;
|
||||
}
|
||||
block = (J3DModelBlock*)((u32)block + block->mBlockSize);
|
||||
}
|
||||
const J3DModelHierarchy* hierarchy = mpModelData->getHierarchy();
|
||||
mpModelData->makeHierarchy(NULL, &hierarchy);
|
||||
mpModelData->sortVcdVatCmd();
|
||||
setupBBoardInfo();
|
||||
if (mpModelData->getFlag() & 0x100) {
|
||||
for (u16 shape_no = 0; shape_no < mpModelData->getShapeNum(); shape_no++) {
|
||||
mpModelData->getShapeNodePointer(shape_no)->onFlag(0x200);
|
||||
}
|
||||
}
|
||||
return mpModelData;
|
||||
}
|
||||
|
||||
/* 802FBCC4-802FBE24 .text loadMaterialTable__14J3DModelLoaderFPCv */
|
||||
void J3DModelLoader::loadMaterialTable(const void*) {
|
||||
/* Nonmatching */
|
||||
J3DMaterialTable* J3DModelLoader::loadMaterialTable(const void* i_data) {
|
||||
mpMaterialTable = new J3DMaterialTable();
|
||||
mpMaterialTable->clear();
|
||||
const J3DModelFileData* data = (J3DModelFileData*)i_data;
|
||||
const J3DModelBlock* block = data->mBlocks;
|
||||
for (u32 block_no = 0; block_no < data->mBlockNum; block_no++) {
|
||||
switch (block->mBlockType) {
|
||||
case 'MAT3':
|
||||
readMaterialTable((J3DMaterialBlock*)block, 0x51100000);
|
||||
break;
|
||||
case 'MAT2':
|
||||
readMaterialTable_v21((J3DMaterialBlock_v21*)block, 0x51100000);
|
||||
break;
|
||||
case 'TEX1':
|
||||
readTextureTable((J3DTextureBlock*)block);
|
||||
break;
|
||||
default:
|
||||
OSReport("Unknown data block\n");
|
||||
break;
|
||||
}
|
||||
block = (J3DModelBlock*)((u32)block + block->mBlockSize);
|
||||
}
|
||||
if (mpMaterialTable->getTexture() == NULL) {
|
||||
mpMaterialTable->setTexture(new J3DTexture(0, NULL));
|
||||
}
|
||||
return mpMaterialTable;
|
||||
}
|
||||
|
||||
/* 802FBE24-802FC0CC .text loadBinaryDisplayList__14J3DModelLoaderFPCvUl */
|
||||
void J3DModelLoader::loadBinaryDisplayList(const void*, u32) {
|
||||
/* Nonmatching */
|
||||
J3DModelData* J3DModelLoader::loadBinaryDisplayList(const void* i_data, u32 i_flags) {
|
||||
/* Nonmatching - strange loop optimization of (i_flags & 0x03000000) | 0x50100000 */
|
||||
mpModelData = new J3DModelData();
|
||||
mpModelData->clear();
|
||||
mpModelData->mpRawData = i_data;
|
||||
mpModelData->setModelDataType(1);
|
||||
mpMaterialTable = &mpModelData->mMaterialTable;
|
||||
const J3DModelFileData* data = (J3DModelFileData*)i_data;
|
||||
const J3DModelBlock* block = data->mBlocks;
|
||||
for (u32 block_no = 0; block_no < data->mBlockNum; block_no++) {
|
||||
switch (block->mBlockType) {
|
||||
case 'INF1':
|
||||
readInformation((J3DModelInfoBlock*)block, (u32)i_flags); // cast fixes regalloc
|
||||
break;
|
||||
case 'VTX1':
|
||||
readVertex((J3DVertexBlock*)block);
|
||||
break;
|
||||
case 'EVP1':
|
||||
readEnvelop((J3DEnvelopBlock*)block);
|
||||
break;
|
||||
case 'DRW1':
|
||||
readDraw((J3DDrawBlock*)block);
|
||||
break;
|
||||
case 'JNT1':
|
||||
readJoint((J3DJointBlock*)block);
|
||||
break;
|
||||
case 'SHP1':
|
||||
readShape((J3DShapeBlock*)block, i_flags);
|
||||
break;
|
||||
case 'TEX1':
|
||||
readTexture((J3DTextureBlock*)block);
|
||||
break;
|
||||
case 'MDL3':
|
||||
readMaterialDL((J3DMaterialDLBlock*)block, i_flags);
|
||||
modifyMaterial(i_flags);
|
||||
break;
|
||||
case 'MAT3':
|
||||
mpMaterialBlock = (J3DMaterialBlock*)block;
|
||||
u32 matType = getBdlFlag_MaterialType(i_flags);
|
||||
if (matType == 0) {
|
||||
readMaterial((J3DMaterialBlock*)block, (i_flags & 0x03000000) | 0x50100000);
|
||||
} else if (matType == 0x2000) {
|
||||
readPatchedMaterial((J3DMaterialBlock*)block, (i_flags & 0x03000000) | 0x50100000);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
OSReport("Unknown data block\n");
|
||||
break;
|
||||
}
|
||||
block = (J3DModelBlock*)((u32)block + block->mBlockSize);
|
||||
}
|
||||
J3DModelHierarchy const* hierarchy = mpModelData->getHierarchy();
|
||||
mpModelData->makeHierarchy(NULL, &hierarchy);
|
||||
mpModelData->sortVcdVatCmd();
|
||||
setupBBoardInfo();
|
||||
mpModelData->indexToPtr();
|
||||
return mpModelData;
|
||||
}
|
||||
|
||||
/* 802FC0CC-802FC234 .text setupBBoardInfo__14J3DModelLoaderFv */
|
||||
void J3DModelLoader::setupBBoardInfo() {
|
||||
/* Nonmatching */
|
||||
for (u16 i = 0; i < mpModelData->getJointNum(); i++) {
|
||||
J3DMaterial* mesh = mpModelData->getJointNodePointer(i)->getMesh();
|
||||
if (mesh != NULL) {
|
||||
u16 shape_index = mesh->getShape()->getIndex();
|
||||
u16* index_table = JSUConvertOffsetToPtr<u16>(mpShapeBlock, mpShapeBlock->mpIndexTable);
|
||||
J3DShapeInitData* shape_init_data =
|
||||
JSUConvertOffsetToPtr<J3DShapeInitData>(mpShapeBlock, mpShapeBlock->mpShapeInitData);
|
||||
J3DJoint* joint;
|
||||
switch (shape_init_data[index_table[shape_index]].mShapeMtxType) {
|
||||
case 0:
|
||||
joint = mpModelData->getJointNodePointer(i);
|
||||
joint->setMtxType(0);
|
||||
break;
|
||||
case 1:
|
||||
joint = mpModelData->getJointNodePointer(i);
|
||||
joint->setMtxType(1);
|
||||
mpModelData->mbHasBillboard = true;
|
||||
break;
|
||||
case 2:
|
||||
joint = mpModelData->getJointNodePointer(i);
|
||||
joint->setMtxType(2);
|
||||
mpModelData->mbHasBillboard = true;
|
||||
break;
|
||||
case 3:
|
||||
joint = mpModelData->getJointNodePointer(i);
|
||||
joint->setMtxType(0);
|
||||
break;
|
||||
default:
|
||||
OSReport("WRONG SHAPE MATRIX TYPE (__FILE__)\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 802FC234-802FC3E4 .text readInformation__14J3DModelLoaderFPC17J3DModelInfoBlockUl */
|
||||
void J3DModelLoader::readInformation(const J3DModelInfoBlock*, u32) {
|
||||
/* Nonmatching */
|
||||
void J3DModelLoader::readInformation(const J3DModelInfoBlock* i_block, u32 i_flags) {
|
||||
mpModelData->mFlags = i_flags | i_block->mFlags;
|
||||
mpModelData->getJointTree().setFlag(mpModelData->mFlags);
|
||||
J3DMtxCalc* mtx_calc = NULL;
|
||||
switch (mpModelData->mFlags & 0xf) {
|
||||
case 0:
|
||||
mtx_calc = new J3DMtxCalcBasic();
|
||||
break;
|
||||
case 1:
|
||||
mtx_calc = new J3DMtxCalcSoftimage();
|
||||
break;
|
||||
case 2:
|
||||
mtx_calc = new J3DMtxCalcMaya();
|
||||
break;
|
||||
}
|
||||
mpModelData->setBasicMtxCalc(mtx_calc);
|
||||
mpModelData->mVertexData.mPacketNum = i_block->mPacketNum;
|
||||
mpModelData->getVertexData().mVtxNum = i_block->mVtxNum;
|
||||
mpModelData->setHierarchy(JSUConvertOffsetToPtr<J3DModelHierarchy>(i_block, i_block->mpHierarchy));
|
||||
}
|
||||
|
||||
/* 802FC3E4-802FC410 .text getFmtType__FP17_GXVtxAttrFmtList7_GXAttr */
|
||||
void getFmtType(GXVtxAttrFmtList*, GXAttr) {
|
||||
/* Nonmatching */
|
||||
static GXCompType getFmtType(GXVtxAttrFmtList* i_fmtList, GXAttr i_attr) {
|
||||
for (; i_fmtList->mAttrib != GX_VA_NULL; i_fmtList++) {
|
||||
if (i_fmtList->mAttrib == i_attr) {
|
||||
return i_fmtList->mCompType;
|
||||
}
|
||||
}
|
||||
return GX_F32;
|
||||
}
|
||||
|
||||
/* 802FC410-802FC630 .text readVertex__14J3DModelLoaderFPC14J3DVertexBlock */
|
||||
void J3DModelLoader::readVertex(const J3DVertexBlock*) {
|
||||
/* Nonmatching */
|
||||
void J3DModelLoader::readVertex(const J3DVertexBlock* i_block) {
|
||||
J3DVertexData& vertex_data = mpModelData->getVertexData();
|
||||
vertex_data.mVtxAttrFmtList =
|
||||
JSUConvertOffsetToPtr<GXVtxAttrFmtList>(i_block, i_block->mpVtxAttrFmtList);
|
||||
vertex_data.mVtxPosArray = JSUConvertOffsetToPtr<void>(i_block, i_block->mpVtxPosArray);
|
||||
vertex_data.mVtxNrmArray = JSUConvertOffsetToPtr<void>(i_block, i_block->mpVtxNrmArray);
|
||||
vertex_data.mVtxNBTArray = JSUConvertOffsetToPtr<void>(i_block, i_block->mpVtxNBTArray);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
vertex_data.mVtxColorArray[i] =
|
||||
(GXColor*)JSUConvertOffsetToPtr<void>(i_block, i_block->mpVtxColorArray[i]);
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
vertex_data.mVtxTexCoordArray[i] =
|
||||
JSUConvertOffsetToPtr<void>(i_block, i_block->mpVtxTexCoordArray[i]);
|
||||
}
|
||||
|
||||
_GXCompType nrm_type = getFmtType(vertex_data.mVtxAttrFmtList, GX_VA_NRM);
|
||||
u32 nrm_size = nrm_type == GX_F32 ? 12 : 6;
|
||||
|
||||
void* nrm_end = NULL;
|
||||
if (vertex_data.mVtxNBTArray != NULL) {
|
||||
nrm_end = vertex_data.mVtxNBTArray;
|
||||
} else if (vertex_data.mVtxColorArray[0] != NULL) {
|
||||
nrm_end = vertex_data.mVtxColorArray[0];
|
||||
} else if (vertex_data.mVtxTexCoordArray[0] != NULL) {
|
||||
nrm_end = vertex_data.mVtxTexCoordArray[0];
|
||||
}
|
||||
|
||||
if (vertex_data.mVtxNrmArray == NULL) {
|
||||
vertex_data.mNrmNum = 0;
|
||||
} else if (nrm_end != NULL) {
|
||||
vertex_data.mNrmNum = ((u32)nrm_end - (u32)vertex_data.mVtxNrmArray) / nrm_size + 1;
|
||||
} else {
|
||||
vertex_data.mNrmNum = (i_block->mBlockSize - (u32)i_block->mpVtxNrmArray) / nrm_size + 1;
|
||||
}
|
||||
|
||||
void* color0_end = NULL;
|
||||
if (vertex_data.mVtxColorArray[1] != NULL) {
|
||||
color0_end = vertex_data.mVtxColorArray[1];
|
||||
} else if (vertex_data.mVtxTexCoordArray[0] != NULL) {
|
||||
color0_end = vertex_data.mVtxTexCoordArray[0];
|
||||
}
|
||||
|
||||
if (vertex_data.mVtxColorArray[0] == NULL) {
|
||||
vertex_data.mColNum = 0;
|
||||
} else if (color0_end != NULL) {
|
||||
vertex_data.mColNum = ((u32)color0_end - (u32)vertex_data.mVtxColorArray[0]) / 4 + 1;
|
||||
} else {
|
||||
vertex_data.mColNum = (i_block->mBlockSize - (u32)i_block->mpVtxColorArray[0]) / 4 + 1;
|
||||
}
|
||||
|
||||
if (vertex_data.mVtxTexCoordArray[0] == NULL) {
|
||||
vertex_data.mTexCoordNum = 0;
|
||||
} else {
|
||||
vertex_data.mTexCoordNum = (i_block->mBlockSize - (u32)i_block->mpVtxTexCoordArray[0]) / 8 + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* 802FC630-802FC6C0 .text readEnvelop__14J3DModelLoaderFPC15J3DEnvelopBlock */
|
||||
void J3DModelLoader::readEnvelop(const J3DEnvelopBlock*) {
|
||||
/* Nonmatching */
|
||||
void J3DModelLoader::readEnvelop(const J3DEnvelopBlock* i_block) {
|
||||
mpModelData->getJointTree().mWEvlpMtxNum = i_block->mWEvlpMtxNum;
|
||||
mpModelData->getJointTree().mWEvlpMixMtxNum =
|
||||
JSUConvertOffsetToPtr<u8>(i_block, i_block->mpWEvlpMixMtxNum);
|
||||
mpModelData->getJointTree().mWEvlpMixIndex =
|
||||
JSUConvertOffsetToPtr<u16>(i_block, i_block->mpWEvlpMixIndex);
|
||||
mpModelData->getJointTree().mWEvlpMixWeight =
|
||||
JSUConvertOffsetToPtr<f32>(i_block, i_block->mpWEvlpMixWeight);
|
||||
mpModelData->getJointTree().mInvJointMtx =
|
||||
JSUConvertOffsetToPtr<Mtx>(i_block, i_block->mpInvJointMtx);
|
||||
}
|
||||
|
||||
/* 802FC6C0-802FC750 .text readDraw__14J3DModelLoaderFPC12J3DDrawBlock */
|
||||
void J3DModelLoader::readDraw(const J3DDrawBlock*) {
|
||||
/* Nonmatching */
|
||||
void J3DModelLoader::readDraw(const J3DDrawBlock* i_block) {
|
||||
J3DJointTree& joint_tree = mpModelData->getJointTree();
|
||||
joint_tree.mDrawMtxData.mEntryNum = i_block->mMtxNum;
|
||||
joint_tree.mDrawMtxData.mDrawMtxFlag = JSUConvertOffsetToPtr<u8>(i_block, i_block->mpDrawMtxFlag);
|
||||
joint_tree.mDrawMtxData.mDrawMtxIndex = JSUConvertOffsetToPtr<u16>(i_block, i_block->mpDrawMtxIndex);
|
||||
u16 i;
|
||||
for (i = 0; i < joint_tree.mDrawMtxData.mEntryNum; i++) {
|
||||
if (joint_tree.mDrawMtxData.mDrawMtxFlag[i] == 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
joint_tree.mDrawMtxData.mDrawFullWgtMtxNum = i;
|
||||
}
|
||||
|
||||
/* 802FC750-802FC834 .text readJoint__14J3DModelLoaderFPC13J3DJointBlock */
|
||||
void J3DModelLoader::readJoint(const J3DJointBlock*) {
|
||||
/* Nonmatching */
|
||||
void J3DModelLoader::readJoint(const J3DJointBlock* i_block) {
|
||||
J3DJointFactory factory(*i_block);
|
||||
mpModelData->getJointTree().mJointNum = i_block->mJointNum;
|
||||
if (i_block->mpNameTable != NULL) {
|
||||
mpModelData->getJointTree().mJointName =
|
||||
new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
|
||||
} else {
|
||||
mpModelData->getJointTree().mJointName = NULL;
|
||||
}
|
||||
mpModelData->getJointTree().mJointNodePointer =
|
||||
new J3DJoint*[mpModelData->getJointTree().mJointNum];
|
||||
for (u16 i = 0; i < mpModelData->getJointTree().getJointNum(); i++) {
|
||||
mpModelData->getJointTree().mJointNodePointer[i] = factory.create(i);
|
||||
}
|
||||
}
|
||||
|
||||
/* 802FC834-802FCAB0 .text readMaterial__18J3DModelLoader_v26FPC16J3DMaterialBlockUl */
|
||||
void J3DModelLoader_v26::readMaterial(const J3DMaterialBlock*, u32) {
|
||||
/* Nonmatching */
|
||||
void J3DModelLoader_v26::readMaterial(const J3DMaterialBlock* i_block, u32 i_flags) {
|
||||
J3DMaterialFactory factory(*i_block);
|
||||
mpMaterialTable->mMaterialNum = i_block->mMaterialNum;
|
||||
mpMaterialTable->mUniqueMatNum = factory.countUniqueMaterials();
|
||||
if (i_block->mpNameTable != NULL) {
|
||||
mpMaterialTable->mMaterialName =
|
||||
new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
|
||||
} else {
|
||||
mpMaterialTable->mMaterialName = NULL;
|
||||
}
|
||||
mpMaterialTable->mMaterialNodePointer = new J3DMaterial*[mpMaterialTable->mMaterialNum];
|
||||
if (i_flags & 0x200000) {
|
||||
mpMaterialTable->field_0x14 = new (0x20) J3DMaterial[mpMaterialTable->mUniqueMatNum];
|
||||
} else {
|
||||
mpMaterialTable->field_0x14 = NULL;
|
||||
}
|
||||
if (i_flags & 0x200000) {
|
||||
for (u16 i = 0; i < mpMaterialTable->mUniqueMatNum; i++) {
|
||||
factory.create(&mpMaterialTable->field_0x14[i],
|
||||
J3DMaterialFactory::MATERIAL_TYPE_NORMAL, i, i_flags);
|
||||
mpMaterialTable->field_0x14[i].mDiffFlag = (u32)&mpMaterialTable->field_0x14[i] >> 4;
|
||||
}
|
||||
}
|
||||
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
|
||||
mpMaterialTable->mMaterialNodePointer[i] =
|
||||
factory.create(NULL, J3DMaterialFactory::MATERIAL_TYPE_NORMAL, i, i_flags);
|
||||
}
|
||||
if (i_flags & 0x200000) {
|
||||
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
|
||||
mpMaterialTable->mMaterialNodePointer[i]->mDiffFlag =
|
||||
(u32)&mpMaterialTable->field_0x14[factory.getMaterialID(i)] >> 4;
|
||||
mpMaterialTable->mMaterialNodePointer[i]->mpOrigMaterial =
|
||||
&mpMaterialTable->field_0x14[factory.getMaterialID(i)];
|
||||
}
|
||||
} else {
|
||||
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
|
||||
mpMaterialTable->mMaterialNodePointer[i]->mDiffFlag =
|
||||
((u32)mpMaterialTable->mMaterialNodePointer >> 4) + factory.getMaterialID(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 802FCAB0-802FCD14 .text readMaterial_v21__18J3DModelLoader_v21FPC20J3DMaterialBlock_v21Ul */
|
||||
void J3DModelLoader_v21::readMaterial_v21(const J3DMaterialBlock_v21*, u32) {
|
||||
/* Nonmatching */
|
||||
void J3DModelLoader_v21::readMaterial_v21(const J3DMaterialBlock_v21* i_block, u32 i_flags) {
|
||||
J3DMaterialFactory_v21 factory(*i_block);
|
||||
mpMaterialTable->mMaterialNum = i_block->mMaterialNum;
|
||||
mpMaterialTable->mUniqueMatNum = factory.countUniqueMaterials();
|
||||
if (i_block->mpNameTable != NULL) {
|
||||
mpMaterialTable->mMaterialName =
|
||||
new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
|
||||
} else {
|
||||
mpMaterialTable->mMaterialName = NULL;
|
||||
}
|
||||
mpMaterialTable->mMaterialNodePointer = new J3DMaterial*[mpMaterialTable->mMaterialNum];
|
||||
if (i_flags & 0x200000) {
|
||||
mpMaterialTable->field_0x14 = new (0x20) J3DMaterial[mpMaterialTable->mUniqueMatNum];
|
||||
} else {
|
||||
mpMaterialTable->field_0x14 = NULL;
|
||||
}
|
||||
if (i_flags & 0x200000) {
|
||||
for (u16 i = 0; i < mpMaterialTable->mUniqueMatNum; i++) {
|
||||
factory.create(&mpMaterialTable->field_0x14[i], i, i_flags);
|
||||
mpMaterialTable->field_0x14[i].mDiffFlag = (u32)&mpMaterialTable->field_0x14[i] >> 4;
|
||||
}
|
||||
}
|
||||
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
|
||||
mpMaterialTable->mMaterialNodePointer[i] = factory.create(NULL, i, i_flags);
|
||||
}
|
||||
if (i_flags & 0x200000) {
|
||||
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
|
||||
mpMaterialTable->mMaterialNodePointer[i]->mDiffFlag =
|
||||
(u32)&mpMaterialTable->field_0x14[factory.getMaterialID(i)] >> 4;
|
||||
mpMaterialTable->mMaterialNodePointer[i]->mpOrigMaterial =
|
||||
&mpMaterialTable->field_0x14[factory.getMaterialID(i)];
|
||||
}
|
||||
} else {
|
||||
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
|
||||
mpMaterialTable->mMaterialNodePointer[i]->mDiffFlag = 0xc0000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 802FCD14-802FCE50 .text readShape__14J3DModelLoaderFPC13J3DShapeBlockUl */
|
||||
void J3DModelLoader::readShape(const J3DShapeBlock*, u32) {
|
||||
/* Nonmatching */
|
||||
void J3DModelLoader::readShape(const J3DShapeBlock* i_block, u32 i_flags) {
|
||||
mpShapeBlock = i_block;
|
||||
J3DShapeFactory factory(*i_block);
|
||||
mpModelData->mShapeTable.mShapeNum = i_block->mShapeNum;
|
||||
if (i_block->mpNameTable != NULL) {
|
||||
mpModelData->mName = new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
|
||||
} else {
|
||||
mpModelData->mName = NULL;
|
||||
}
|
||||
mpModelData->mShapeTable.mShapeNodePointer = new J3DShape*[mpModelData->mShapeTable.mShapeNum];
|
||||
factory.allocVcdVatCmdBuffer(mpModelData->mShapeTable.mShapeNum);
|
||||
J3DModelHierarchy const* hierarchy_entry = mpModelData->getHierarchy();
|
||||
GXVtxDescList* vtx_desc_list = NULL;
|
||||
for (; hierarchy_entry->mType != 0; hierarchy_entry++) {
|
||||
if (hierarchy_entry->mType == 0x12) {
|
||||
mpModelData->mShapeTable.mShapeNodePointer[hierarchy_entry->mValue] =
|
||||
factory.create(hierarchy_entry->mValue, i_flags, vtx_desc_list);
|
||||
vtx_desc_list = factory.getVtxDescList(hierarchy_entry->mValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 802FCE50-802FCF14 .text readTexture__14J3DModelLoaderFPC15J3DTextureBlock */
|
||||
void J3DModelLoader::readTexture(const J3DTextureBlock*) {
|
||||
/* Nonmatching */
|
||||
void J3DModelLoader::readTexture(const J3DTextureBlock* i_block) {
|
||||
u16 texture_num = i_block->mTextureNum;
|
||||
ResTIMG* texture_res = JSUConvertOffsetToPtr<ResTIMG>(i_block, i_block->mpTextureRes);
|
||||
if (i_block->mpNameTable != NULL) {
|
||||
mpMaterialTable->mTextureName = new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
|
||||
} else {
|
||||
mpMaterialTable->mTextureName = NULL;
|
||||
}
|
||||
mpMaterialTable->mTexture = new J3DTexture(texture_num, texture_res);
|
||||
}
|
||||
|
||||
/* 802FCF14-802FD050 .text readMaterialTable__18J3DModelLoader_v26FPC16J3DMaterialBlockUl */
|
||||
void J3DModelLoader_v26::readMaterialTable(const J3DMaterialBlock*, u32) {
|
||||
/* Nonmatching */
|
||||
void J3DModelLoader_v26::readMaterialTable(const J3DMaterialBlock* i_block, u32 i_flags) {
|
||||
J3DMaterialFactory factory(*i_block);
|
||||
mpMaterialTable->mMaterialNum = i_block->mMaterialNum;
|
||||
if (i_block->mpNameTable != NULL) {
|
||||
mpMaterialTable->mMaterialName =
|
||||
new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
|
||||
} else {
|
||||
mpMaterialTable->mMaterialName = NULL;
|
||||
}
|
||||
mpMaterialTable->mMaterialNodePointer = new J3DMaterial*[mpMaterialTable->mMaterialNum];
|
||||
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
|
||||
mpMaterialTable->mMaterialNodePointer[i] =
|
||||
factory.create(NULL, J3DMaterialFactory::MATERIAL_TYPE_NORMAL, i, i_flags);
|
||||
}
|
||||
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
|
||||
mpMaterialTable->mMaterialNodePointer[i]->mDiffFlag =
|
||||
(u32)mpMaterialTable->mMaterialNodePointer + factory.getMaterialID(i);
|
||||
}
|
||||
}
|
||||
|
||||
/* 802FD050-802FD18C .text readMaterialTable_v21__18J3DModelLoader_v21FPC20J3DMaterialBlock_v21Ul */
|
||||
void J3DModelLoader_v21::readMaterialTable_v21(const J3DMaterialBlock_v21*, u32) {
|
||||
/* Nonmatching */
|
||||
void J3DModelLoader_v21::readMaterialTable_v21(const J3DMaterialBlock_v21* i_block, u32 i_flags) {
|
||||
J3DMaterialFactory_v21 factory(*i_block);
|
||||
mpMaterialTable->mMaterialNum = i_block->mMaterialNum;
|
||||
if (i_block->mpNameTable != NULL) {
|
||||
mpMaterialTable->mMaterialName =
|
||||
new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
|
||||
} else {
|
||||
mpMaterialTable->mMaterialName = NULL;
|
||||
}
|
||||
mpMaterialTable->mMaterialNodePointer = new J3DMaterial*[mpMaterialTable->mMaterialNum];
|
||||
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
|
||||
mpMaterialTable->mMaterialNodePointer[i] =
|
||||
factory.create(NULL, i, i_flags);
|
||||
}
|
||||
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
|
||||
mpMaterialTable->mMaterialNodePointer[i]->mDiffFlag =
|
||||
((u32)mpMaterialTable->mMaterialNodePointer >> 4) + factory.getMaterialID(i);
|
||||
}
|
||||
}
|
||||
|
||||
/* 802FD18C-802FD250 .text readTextureTable__14J3DModelLoaderFPC15J3DTextureBlock */
|
||||
void J3DModelLoader::readTextureTable(const J3DTextureBlock*) {
|
||||
/* Nonmatching */
|
||||
void J3DModelLoader::readTextureTable(const J3DTextureBlock* i_block) {
|
||||
u16 texture_num = i_block->mTextureNum;
|
||||
ResTIMG* texture_res = JSUConvertOffsetToPtr<ResTIMG>(i_block, i_block->mpTextureRes);
|
||||
if (i_block->mpNameTable != NULL) {
|
||||
mpMaterialTable->mTextureName = new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
|
||||
} else {
|
||||
mpMaterialTable->mTextureName = NULL;
|
||||
}
|
||||
mpMaterialTable->mTexture = new J3DTexture(texture_num, texture_res);
|
||||
}
|
||||
|
||||
/* 802FD250-802FD390 .text readPatchedMaterial__14J3DModelLoaderFPC16J3DMaterialBlockUl */
|
||||
void J3DModelLoader::readPatchedMaterial(const J3DMaterialBlock*, u32) {
|
||||
/* Nonmatching */
|
||||
void J3DModelLoader::readPatchedMaterial(const J3DMaterialBlock* i_block, u32 i_flags) {
|
||||
J3DMaterialFactory factory(*i_block);
|
||||
mpMaterialTable->mMaterialNum = i_block->mMaterialNum;
|
||||
mpMaterialTable->mUniqueMatNum = factory.countUniqueMaterials();
|
||||
if (i_block->mpNameTable != NULL) {
|
||||
mpMaterialTable->mMaterialName =
|
||||
new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
|
||||
} else {
|
||||
mpMaterialTable->mMaterialName = NULL;
|
||||
}
|
||||
mpMaterialTable->mMaterialNodePointer = new J3DMaterial*[mpMaterialTable->mMaterialNum];
|
||||
mpMaterialTable->field_0x14 = NULL;
|
||||
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
|
||||
mpMaterialTable->mMaterialNodePointer[i] =
|
||||
factory.create(NULL, J3DMaterialFactory::MATERIAL_TYPE_PATCHED, i, i_flags);
|
||||
mpMaterialTable->mMaterialNodePointer[i]->mDiffFlag =
|
||||
((u32)mpMaterialTable->mMaterialNodePointer >> 4) + factory.getMaterialID(i);
|
||||
}
|
||||
}
|
||||
|
||||
/* 802FD390-802FD548 .text readMaterialDL__14J3DModelLoaderFPC18J3DMaterialDLBlockUl */
|
||||
void J3DModelLoader::readMaterialDL(const J3DMaterialDLBlock*, u32) {
|
||||
/* Nonmatching */
|
||||
void J3DModelLoader::readMaterialDL(const J3DMaterialDLBlock* i_block, u32 i_flags) {
|
||||
J3DMaterialFactory factory(*i_block);
|
||||
if (mpMaterialTable->mMaterialNum == 0) {
|
||||
mpMaterialTable->field_0x20 = 1;
|
||||
mpMaterialTable->mMaterialNum = i_block->mMaterialNum;
|
||||
mpMaterialTable->mUniqueMatNum = i_block->mMaterialNum;
|
||||
if (i_block->mpNameTable != NULL) {
|
||||
mpMaterialTable->mMaterialName =
|
||||
new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
|
||||
} else {
|
||||
mpMaterialTable->mMaterialName = NULL;
|
||||
}
|
||||
mpMaterialTable->mMaterialNodePointer = new J3DMaterial*[mpMaterialTable->mMaterialNum];
|
||||
mpMaterialTable->field_0x14 = NULL;
|
||||
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
|
||||
mpMaterialTable->mMaterialNodePointer[i] = factory.create(
|
||||
NULL, J3DMaterialFactory::MATERIAL_TYPE_LOCKED, i, (u32)i_flags // cast fixes regalloc
|
||||
);
|
||||
}
|
||||
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
|
||||
mpMaterialTable->mMaterialNodePointer[i]->mDiffFlag = 0xc0000000;
|
||||
}
|
||||
} else {
|
||||
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
|
||||
mpMaterialTable->mMaterialNodePointer[i] = factory.create(
|
||||
mpMaterialTable->mMaterialNodePointer[i],
|
||||
J3DMaterialFactory::MATERIAL_TYPE_LOCKED, i, (u32)i_flags // cast fixes regalloc
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 802FD548-802FD5C4 .text modifyMaterial__14J3DModelLoaderFUl */
|
||||
void J3DModelLoader::modifyMaterial(u32) {
|
||||
/* Nonmatching */
|
||||
void J3DModelLoader::modifyMaterial(u32 i_flags) {
|
||||
if (i_flags & 0x2000) {
|
||||
J3DMaterialFactory factory(*mpMaterialBlock);
|
||||
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
|
||||
factory.modifyPatchedCurrentMtx(mpMaterialTable->mMaterialNodePointer[i], i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user