mirror of
https://github.com/zeldaret/tww.git
synced 2026-08-21 22:10:59 -04:00
J3DMaterialFactory, J3DShapeFactory
mostly pulled from tp
This commit is contained in:
+1
-1
@@ -892,7 +892,7 @@ config.libs = [
|
||||
Object(Matching, "JSystem/J3DGraphLoader/J3DModelLoader.cpp"),
|
||||
Object(NonMatching, "JSystem/J3DGraphLoader/J3DModelLoaderCalcSize.cpp"),
|
||||
Object(Matching, "JSystem/J3DGraphLoader/J3DJointFactory.cpp"),
|
||||
Object(NonMatching, "JSystem/J3DGraphLoader/J3DShapeFactory.cpp"),
|
||||
Object(Matching, "JSystem/J3DGraphLoader/J3DShapeFactory.cpp"),
|
||||
Object(NonMatching, "JSystem/J3DGraphLoader/J3DAnmLoader.cpp"),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
|
||||
struct J3DGXColorS10 {
|
||||
J3DGXColorS10() {}
|
||||
J3DGXColorS10(J3DGXColorS10& other) { mColor = other.mColor; }
|
||||
J3DGXColorS10(const GXColorS10& other) { mColor = other; }
|
||||
J3DGXColorS10(const J3DGXColorS10& other) { mColor = other.mColor; }
|
||||
J3DGXColorS10& operator=(const J3DGXColorS10& other) {
|
||||
mColor = other.mColor;
|
||||
return *this;
|
||||
@@ -24,7 +25,8 @@ struct J3DGXColorS10 {
|
||||
|
||||
struct J3DGXColor {
|
||||
J3DGXColor() {}
|
||||
J3DGXColor(J3DGXColor& other) { mColor = other.mColor; }
|
||||
J3DGXColor(const GXColor& other) { mColor = other; }
|
||||
J3DGXColor(const J3DGXColor& other) { mColor = other.mColor; }
|
||||
J3DGXColor& operator=(const J3DGXColor& other) {
|
||||
mColor = other.mColor;
|
||||
return *this;
|
||||
@@ -271,6 +273,7 @@ private:
|
||||
|
||||
class J3DTevBlockNull : public J3DTevBlock {
|
||||
public:
|
||||
J3DTevBlockNull() { initialize(); }
|
||||
virtual void reset(J3DTevBlock*) {}
|
||||
virtual void ptrToIndex() {}
|
||||
virtual void indexToPtr() {}
|
||||
@@ -561,6 +564,7 @@ extern J3DZModeInfo j3dZModeTable[0x20];
|
||||
|
||||
struct J3DZMode {
|
||||
J3DZMode() { mZModeID = j3dDefaultZModeID; }
|
||||
explicit J3DZMode(const J3DZModeInfo& info) { setZModeInfo(info); }
|
||||
|
||||
u8 getCompareEnaable() const { return j3dZModeTable[mZModeID].mCompareEnable; }
|
||||
u8 getFunc() const { return j3dZModeTable[mZModeID].mFunc; }
|
||||
@@ -588,6 +592,7 @@ struct J3DZMode {
|
||||
|
||||
struct J3DBlend : public J3DBlendInfo {
|
||||
J3DBlend() { *(J3DBlendInfo*)this = j3dDefaultBlendInfo; }
|
||||
explicit J3DBlend(const J3DBlendInfo& info) { *(J3DBlendInfo*)this = info; }
|
||||
|
||||
GXBlendMode getBlendMode() const { return (GXBlendMode)mBlendMode; }
|
||||
GXBlendFactor getSrcFactor() const { return (GXBlendFactor)mSrcFactor; }
|
||||
@@ -616,6 +621,7 @@ extern const J3DFogInfo j3dDefaultFogInfo;
|
||||
struct J3DFog : public J3DFogInfo {
|
||||
// J3DFog() { *getFogInfo() = j3dDefaultFogInfo; } // Produces the wrong codegen for mDoExt_backupMatBlock_c's constructor
|
||||
J3DFog() { J3DFogInfo::operator=(j3dDefaultFogInfo); }
|
||||
explicit J3DFog(const J3DFogInfo& info) { J3DFogInfo::operator=(info); }
|
||||
J3DFogInfo* getFogInfo() { return (J3DFogInfo*)this; }
|
||||
|
||||
void load() {
|
||||
@@ -625,18 +631,18 @@ struct J3DFog : public J3DFogInfo {
|
||||
};
|
||||
|
||||
struct J3DAlphaCompInfo {
|
||||
/* 0x0 */ u8 field_0x0;
|
||||
/* 0x1 */ u8 field_0x1;
|
||||
/* 0x2 */ u8 mRef0;
|
||||
/* 0x3 */ u8 mRef1;
|
||||
/* 0x4 */ u8 field_0x4;
|
||||
/* 0x0 */ u8 mComp0;
|
||||
/* 0x1 */ u8 mRef0;
|
||||
/* 0x2 */ u8 mOp;
|
||||
/* 0x3 */ u8 mComp1;
|
||||
/* 0x4 */ u8 mRef1;
|
||||
/* 0x5 */ u8 field_0x5;
|
||||
/* 0x6 */ u8 field_0x6;
|
||||
/* 0x7 */ u8 field_0x7;
|
||||
};
|
||||
|
||||
inline u32 calcAlphaCmpID(u32 param_1, u32 param_2, u32 param_3) {
|
||||
return ((param_1 & 0xff) << 5) + ((param_2 & 0xff) << 3) + (param_3 & 0xff);
|
||||
inline u16 calcAlphaCmpID(u32 comp0, u32 op, u32 comp1) {
|
||||
return (comp0 << 5) + ((op & 0xff) << 3) + (comp1 & 0xff);
|
||||
}
|
||||
|
||||
extern u8 j3dAlphaCmpTable[768];
|
||||
@@ -648,6 +654,8 @@ struct J3DAlphaComp {
|
||||
mRef1 = 0;
|
||||
}
|
||||
|
||||
explicit J3DAlphaComp(const J3DAlphaCompInfo& info) { setAlphaCompInfo(info); }
|
||||
|
||||
GXCompare getComp0() const { return GXCompare(j3dAlphaCmpTable[mAlphaCmpID * 3]); }
|
||||
GXAlphaOp getOp() const { return GXAlphaOp(j3dAlphaCmpTable[mAlphaCmpID * 3 + 1]); }
|
||||
GXCompare getComp1() const { return GXCompare(j3dAlphaCmpTable[mAlphaCmpID * 3 + 2]); }
|
||||
@@ -655,7 +663,9 @@ struct J3DAlphaComp {
|
||||
u8 getRef1() const { return mRef1; }
|
||||
|
||||
void setAlphaCompInfo(const J3DAlphaCompInfo& info) {
|
||||
// mAlphaCmpID = calcAlphaCmpID(param_1, param_1.mRef0, param_1.mRef1);
|
||||
mAlphaCmpID = calcAlphaCmpID(info.mComp0, info.mOp, info.mComp1);
|
||||
mRef0 = info.mRef0;
|
||||
mRef1 = info.mRef1;
|
||||
}
|
||||
|
||||
void load() {
|
||||
@@ -815,6 +825,7 @@ public:
|
||||
|
||||
struct J3DIndTexCoordScale : public J3DIndTexCoordScaleInfo {
|
||||
J3DIndTexCoordScale() { *(J3DIndTexCoordScaleInfo*)this = j3dDefaultIndTexCoordScaleInfo; }
|
||||
explicit J3DIndTexCoordScale(const J3DIndTexCoordScaleInfo& info) {*(J3DIndTexCoordScaleInfo*)this = info; }
|
||||
~J3DIndTexCoordScale() {}
|
||||
|
||||
u8 getScaleS() { return mScaleS; }
|
||||
@@ -823,6 +834,7 @@ struct J3DIndTexCoordScale : public J3DIndTexCoordScaleInfo {
|
||||
|
||||
struct J3DIndTexMtx : public J3DIndTexMtxInfo {
|
||||
J3DIndTexMtx() {*(J3DIndTexMtxInfo*)this = j3dDefaultIndTexMtxInfo; }
|
||||
explicit J3DIndTexMtx(const J3DIndTexMtxInfo& info) {*(J3DIndTexMtxInfo*)this = info; }
|
||||
~J3DIndTexMtx() {}
|
||||
|
||||
void load(u32 param_1) {
|
||||
@@ -839,7 +851,8 @@ struct J3DIndTexMtx : public J3DIndTexMtxInfo {
|
||||
}; // Size: 0x1C
|
||||
|
||||
struct J3DIndTexOrder : public J3DIndTexOrderInfo {
|
||||
J3DIndTexOrder() { *(J3DIndTexOrderInfo*) this = j3dDefaultIndTexOrderNull; }
|
||||
J3DIndTexOrder() { *(J3DIndTexOrderInfo*)this = j3dDefaultIndTexOrderNull; }
|
||||
explicit J3DIndTexOrder(const J3DIndTexOrderInfo& info) { *(J3DIndTexOrderInfo*)this = info; }
|
||||
|
||||
u8 getCoord() const { return mCoord; }
|
||||
u8 getMap() const { return mMap; }
|
||||
@@ -938,6 +951,7 @@ inline u32 setChanCtrlMacro(u8 enable, GXColorSrc ambSrc, GXColorSrc matSrc, u32
|
||||
|
||||
struct J3DColorChan {
|
||||
J3DColorChan() { setColorChanInfo(j3dDefaultColorChanInfo); }
|
||||
J3DColorChan(const J3DColorChanInfo & info) { setColorChanInfo(info); }
|
||||
GXAttnFn getAttnFn();
|
||||
GXDiffuseFn getDiffuseFn() { return GXDiffuseFn(mChanCtrl >> 7 & 3); }
|
||||
u8 getLightMask() { return ((mChanCtrl >> 2 & 0x0f) | (mChanCtrl >> 11 & 0x0f) << 4); }
|
||||
|
||||
@@ -109,6 +109,7 @@ public:
|
||||
|
||||
class J3DPatchedMaterial : public J3DMaterial {
|
||||
public:
|
||||
J3DPatchedMaterial() { initialize(); }
|
||||
void initialize();
|
||||
|
||||
virtual void calc(const Mtx);
|
||||
@@ -122,6 +123,7 @@ public:
|
||||
|
||||
class J3DLockedMaterial : public J3DMaterial {
|
||||
public:
|
||||
J3DLockedMaterial() { initialize(); }
|
||||
void initialize();
|
||||
|
||||
virtual void calc(const Mtx);
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
class J3DCurrentMtxInfo {
|
||||
public:
|
||||
u32 mMtxIdxRegA;
|
||||
u32 mMtxIdxRegB;
|
||||
/* 0x00 */ u32 mMtxIdxRegA;
|
||||
/* 0x04 */ u32 mMtxIdxRegB;
|
||||
};
|
||||
|
||||
static inline void J3DFifoWriteCPCmd(u8 cmd, u32 param) {
|
||||
@@ -31,6 +31,11 @@ public:
|
||||
mMtxIdxRegB = 0x00f3cf3c;
|
||||
}
|
||||
|
||||
explicit J3DCurrentMtx(const J3DCurrentMtxInfo& info) {
|
||||
mMtxIdxRegA = info.mMtxIdxRegA;
|
||||
mMtxIdxRegB = info.mMtxIdxRegB;
|
||||
}
|
||||
|
||||
u32 getMtxIdxRegA() const { return mMtxIdxRegA; }
|
||||
u32 getMtxIdxRegB() const { return mMtxIdxRegB; }
|
||||
|
||||
|
||||
@@ -78,7 +78,8 @@ public:
|
||||
|
||||
class J3DShapeMtxMultiImm : public J3DShapeMtxImm {
|
||||
public:
|
||||
J3DShapeMtxMultiImm(u16 useMtxIndex) : J3DShapeMtxImm(useMtxIndex) {}
|
||||
J3DShapeMtxMultiImm(u16 useMtxIndex, u16 useMtxNum, u16* useMtxIndexTable)
|
||||
: J3DShapeMtxImm(useMtxIndex), mUseMtxNum(useMtxNum), mUseMtxIndexTable(useMtxIndexTable) {}
|
||||
|
||||
virtual ~J3DShapeMtxMultiImm() {}
|
||||
virtual u32 getType() const { return 'SMMI'; }
|
||||
|
||||
@@ -145,8 +145,8 @@ struct J3DIndTexOrderInfo {
|
||||
};
|
||||
|
||||
struct J3DTevSwapModeInfo {
|
||||
/* 0x0 */ u8 field_0x0 ALIGN_DECL(4);
|
||||
/* 0x1 */ u8 field_0x1;
|
||||
/* 0x0 */ u8 mRasSel ALIGN_DECL(4);
|
||||
/* 0x1 */ u8 mTexSel;
|
||||
};
|
||||
|
||||
struct J3DTevSwapModeTableInfo {
|
||||
|
||||
@@ -36,7 +36,7 @@ struct J3DTevStage {
|
||||
setTevStageInfo(j3dDefaultTevStageInfo);
|
||||
setTevSwapModeInfo(j3dDefaultTevSwapMode);
|
||||
}
|
||||
J3DTevStage(const J3DTevStageInfo& info) {
|
||||
explicit J3DTevStage(const J3DTevStageInfo& info) {
|
||||
setTevStageInfo(info);
|
||||
setTevSwapModeInfo(j3dDefaultTevSwapMode);
|
||||
}
|
||||
@@ -100,8 +100,8 @@ struct J3DTevStage {
|
||||
void setTexSel(u8 param_0) { mTevSwapModeInfo = mTevSwapModeInfo & ~0x0C | param_0 << 2; }
|
||||
void setRasSel(u8 param_0) { mTevSwapModeInfo = mTevSwapModeInfo & ~0x03 | param_0; }
|
||||
void setTevSwapModeInfo(const J3DTevSwapModeInfo& info) {
|
||||
setTexSel(info.field_0x1);
|
||||
setRasSel(info.field_0x0);
|
||||
setTexSel(info.mTexSel);
|
||||
setRasSel(info.mRasSel);
|
||||
}
|
||||
|
||||
void load(u32) const {
|
||||
@@ -125,6 +125,11 @@ struct J3DIndTevStage {
|
||||
setIndTevStageInfo(j3dDefaultIndTevStageInfo);
|
||||
}
|
||||
|
||||
explicit J3DIndTevStage(const J3DIndTevStageInfo& info) {
|
||||
mInfo = 0;
|
||||
setIndTevStageInfo(info);
|
||||
}
|
||||
|
||||
void setIndStage(u8 stage) { mInfo = mInfo & ~0x03 | stage; }
|
||||
void setIndFormat(u8 format) { mInfo = mInfo & ~0x0C | format << 2; }
|
||||
void setBiasSel(u8 sel) { mInfo = mInfo & ~0x70 | sel << 4; }
|
||||
@@ -156,20 +161,26 @@ struct J3DIndTevStage {
|
||||
|
||||
struct J3DTevOrder : public J3DTevOrderInfo {
|
||||
J3DTevOrder() { *(J3DTevOrderInfo*)this = j3dDefaultTevOrderInfoNull; }
|
||||
explicit J3DTevOrder(const J3DTevOrderInfo& info) { *(J3DTevOrderInfo*)this = info; }
|
||||
|
||||
J3DTevOrderInfo& getTevOrderInfo() { return *this; }
|
||||
u8 getTexMap() { return mTexMap; }
|
||||
};
|
||||
|
||||
static inline u8 calcTevSwapTableID(u8 r, u8 g, u8 b, u8 a) {
|
||||
return r * 64 + g * 16 + b * 4 + a;
|
||||
}
|
||||
|
||||
struct J3DTevSwapModeTable {
|
||||
J3DTevSwapModeTable() { field_0x0 = j3dDefaultTevSwapTableID; }
|
||||
J3DTevSwapModeTable() { mIdx = j3dDefaultTevSwapTableID; }
|
||||
explicit J3DTevSwapModeTable(const J3DTevSwapModeTableInfo& info) { mIdx = calcTevSwapTableID(info.field_0x0, info.field_0x1, info.field_0x2, info.field_0x3); }
|
||||
|
||||
u8 getR() { return j3dTevSwapTableTable[field_0x0 * 4]; }
|
||||
u8 getG() { return j3dTevSwapTableTable[field_0x0 * 4 + 1]; }
|
||||
u8 getB() { return j3dTevSwapTableTable[field_0x0 * 4 + 2]; }
|
||||
u8 getA() { return j3dTevSwapTableTable[field_0x0 * 4 + 3]; }
|
||||
u8 getR() { return j3dTevSwapTableTable[mIdx * 4]; }
|
||||
u8 getG() { return j3dTevSwapTableTable[mIdx * 4 + 1]; }
|
||||
u8 getB() { return j3dTevSwapTableTable[mIdx * 4 + 2]; }
|
||||
u8 getA() { return j3dTevSwapTableTable[mIdx * 4 + 3]; }
|
||||
|
||||
/* 0x0 */ u8 field_0x0;
|
||||
/* 0x0 */ u8 mIdx;
|
||||
}; // Size: 0x1
|
||||
|
||||
class J3DLightObj {
|
||||
@@ -188,11 +199,8 @@ public:
|
||||
}; // Size = 0x74
|
||||
|
||||
struct J3DNBTScale : public J3DNBTScaleInfo {
|
||||
J3DNBTScale() {}
|
||||
J3DNBTScale(J3DNBTScaleInfo const& info) {
|
||||
mbHasScale = info.mbHasScale;
|
||||
mScale = info.mScale;
|
||||
}
|
||||
J3DNBTScale() { *(J3DNBTScaleInfo*)this = j3dDefaultNBTScaleInfo; }
|
||||
explicit J3DNBTScale(const J3DNBTScaleInfo& info) { *(J3DNBTScaleInfo*)this = info; }
|
||||
Vec* getScale() { return &mScale; }
|
||||
};
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ private:
|
||||
|
||||
struct J3DTexCoord : public J3DTexCoordInfo {
|
||||
J3DTexCoord() { *(J3DTexCoordInfo*)this = j3dDefaultTexCoordInfo[0]; }
|
||||
J3DTexCoord(const J3DTexCoordInfo& info) { *(J3DTexCoordInfo*)this = info; }
|
||||
|
||||
u8 getTexGenType() { return mTexGenType; }
|
||||
u8 getTexGenSrc() { return mTexGenSrc; }
|
||||
|
||||
@@ -2,10 +2,108 @@
|
||||
#define J3DMATERIALFACTORY_H
|
||||
|
||||
#include "dolphin/types.h"
|
||||
#include "dolphin/gx/GX.h"
|
||||
#include "JSystem/J3DGraphBase/J3DStruct.h"
|
||||
|
||||
class J3DMaterial;
|
||||
struct J3DMaterialBlock;
|
||||
struct J3DMaterialDLBlock;
|
||||
struct J3DMaterialInitData;
|
||||
struct J3DIndInitData;
|
||||
struct J3DColorChanInfo;
|
||||
struct J3DLightInfo;
|
||||
struct J3DTexCoordInfo;
|
||||
struct J3DTexCoord2Info;
|
||||
struct J3DTexMtxInfo;
|
||||
struct J3DTevOrderInfo;
|
||||
struct J3DTevStageInfo;
|
||||
struct J3DTevSwapModeInfo;
|
||||
struct J3DTevSwapModeTableInfo;
|
||||
struct J3DFogInfo;
|
||||
struct J3DAlphaCompInfo;
|
||||
struct J3DBlendInfo;
|
||||
struct J3DZModeInfo;
|
||||
struct J3DNBTScaleInfo;
|
||||
struct J3DCurrentMtxInfo;
|
||||
|
||||
struct J3DColorChan;
|
||||
struct J3DGXColor;
|
||||
struct J3DGXColorS10;
|
||||
struct J3DTexCoord;
|
||||
struct J3DTexMtx;
|
||||
struct J3DTevOrder;
|
||||
struct J3DTevStage;
|
||||
struct J3DTevSwapMode;
|
||||
struct J3DTevSwapModeTable;
|
||||
struct J3DIndTexOrder;
|
||||
struct J3DIndTexMtx;
|
||||
struct J3DIndTevStage;
|
||||
struct J3DIndTexCoordScale;
|
||||
struct J3DFog;
|
||||
struct J3DAlphaComp;
|
||||
struct J3DBlend;
|
||||
struct J3DZMode;
|
||||
struct J3DNBTScale;
|
||||
|
||||
struct J3DMaterialInitData {
|
||||
/* 0x000 */ u8 mMaterialMode;
|
||||
/* 0x001 */ u8 mCullModeIdx;
|
||||
/* 0x002 */ u8 mColorChanNumIdx;
|
||||
/* 0x003 */ u8 mTexGenNumIdx;
|
||||
/* 0x004 */ u8 mTevStageNumIdx;
|
||||
/* 0x005 */ u8 mZCompLocIdx;
|
||||
/* 0x006 */ u8 mZModeIdx;
|
||||
/* 0x007 */ u8 mDitherIdx;
|
||||
/* 0x008 */ u16 mMatColorIdx[2];
|
||||
/* 0x00C */ u16 mColorChanIdx[4];
|
||||
/* 0x014 */ u16 mAmbColorIdx[2];
|
||||
/* 0x018 */ u8 field_0x018[16];
|
||||
/* 0x028 */ u16 mTexCoordIdx[8];
|
||||
/* 0x038 */ u8 field_0x038[16];
|
||||
/* 0x048 */ u16 mTexMtxIdx[8];
|
||||
/* 0x058 */ u8 field_0x058[44];
|
||||
/* 0x084 */ u16 mTexNoIdx[8];
|
||||
/* 0x094 */ u16 mTevKColorIdx[4];
|
||||
/* 0x09C */ u8 mTevKColorSel[16];
|
||||
/* 0x0AC */ u8 mTevKAlphaSel[16];
|
||||
/* 0x0BC */ u16 mTevOrderIdx[16];
|
||||
/* 0x0DC */ u16 mTevColorIdx[4];
|
||||
/* 0x0E4 */ u16 mTevStageIdx[16];
|
||||
/* 0x104 */ u16 mTevSwapModeIdx[16];
|
||||
/* 0x124 */ u16 mTevSwapModeTableIdx[4];
|
||||
/* 0x12C */ u8 field_0x12c[24];
|
||||
/* 0x144 */ u16 mFogIdx;
|
||||
/* 0x146 */ u16 mAlphaCompIdx;
|
||||
/* 0x148 */ u16 mBlendIdx;
|
||||
/* 0x14A */ u16 mNBTScaleIdx;
|
||||
};
|
||||
|
||||
struct J3DIndInitData {
|
||||
/* 0x000 */ bool mEnabled;
|
||||
/* 0x001 */ u8 mIndTexStageNum;
|
||||
/* 0x002 */ u8 field_0x002[2];
|
||||
/* 0x004 */ J3DIndTexOrderInfo mIndTexOrderInfo[3];
|
||||
/* 0x010 */ u8 field_0x010[4];
|
||||
/* 0x014 */ J3DIndTexMtxInfo mIndTexMtxInfo[3];
|
||||
/* 0x068 */ J3DIndTexCoordScaleInfo mIndTexCoordScaleInfo[3];
|
||||
/* 0x074 */ u8 field_0x074[4];
|
||||
/* 0x078 */ J3DIndTevStageInfo mIndTevStageInfo[16];
|
||||
};
|
||||
|
||||
struct J3DPatchingInfo {
|
||||
/* 0x0 */ u16 mMatColorOffset;
|
||||
/* 0x2 */ u16 mColorChanOffset;
|
||||
/* 0x4 */ u16 mTexMtxOffset;
|
||||
/* 0x6 */ u16 mTexNoOffset;
|
||||
/* 0x8 */ u16 mTevRegOffset;
|
||||
/* 0xA */ u16 mFogOffset;
|
||||
/* 0xC */ u8 field_0xc[4];
|
||||
};
|
||||
|
||||
struct J3DDisplayListInit {
|
||||
/* 0x0 */ u32 mOffset;
|
||||
/* 0x4 */ u32 mSize;
|
||||
};
|
||||
|
||||
class J3DMaterialFactory {
|
||||
public:
|
||||
@@ -18,52 +116,84 @@ public:
|
||||
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;
|
||||
u32 countTexGens(int) const;
|
||||
u32 countStages(int) const;
|
||||
J3DMaterial* create(J3DMaterial*, MaterialType, int, u32) const;
|
||||
J3DMaterial* createNormalMaterial(J3DMaterial*, int, u32) const;
|
||||
J3DMaterial* createPatchedMaterial(J3DMaterial*, int, u32) const;
|
||||
void modifyPatchedCurrentMtx(J3DMaterial*, int) const;
|
||||
void createLockedMaterial(J3DMaterial*, int, unsigned long) const;
|
||||
u32 calcSize(J3DMaterial*, MaterialType, int, unsigned long) const;
|
||||
u32 calcSizeNormalMaterial(J3DMaterial*, int, unsigned long) const;
|
||||
u32 calcSizePatchedMaterial(J3DMaterial*, int, unsigned long) const;
|
||||
u32 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;
|
||||
J3DMaterial* createLockedMaterial(J3DMaterial*, int, u32) const;
|
||||
u32 calcSize(J3DMaterial*, MaterialType, int, u32) const;
|
||||
u32 calcSizeNormalMaterial(J3DMaterial*, int, u32) const;
|
||||
u32 calcSizePatchedMaterial(J3DMaterial*, int, u32) const;
|
||||
u32 calcSizeLockedMaterial(J3DMaterial*, int, u32) const;
|
||||
J3DGXColor newMatColor(int, int) const;
|
||||
u8 newColorChanNum(int) const;
|
||||
J3DColorChan newColorChan(int, int) const;
|
||||
J3DGXColor newAmbColor(int, int) const;
|
||||
u32 newTexGenNum(int) const;
|
||||
J3DTexCoord newTexCoord(int, int) const;
|
||||
J3DTexMtx* newTexMtx(int, int) const;
|
||||
u8 newCullMode(int) const;
|
||||
u16 newTexNo(int, int) const;
|
||||
J3DTevOrder newTevOrder(int, int) const;
|
||||
J3DGXColorS10 newTevColor(int, int) const;
|
||||
J3DGXColor newTevKColor(int, int) const;
|
||||
u8 newTevStageNum(int) const;
|
||||
J3DTevStage newTevStage(int, int) const;
|
||||
J3DTevSwapModeTable newTevSwapModeTable(int, int) const;
|
||||
u8 newIndTexStageNum(int) const;
|
||||
J3DIndTexOrder newIndTexOrder(int, int) const;
|
||||
J3DIndTexMtx newIndTexMtx(int, int) const;
|
||||
J3DIndTevStage newIndTevStage(int, int) const;
|
||||
J3DIndTexCoordScale newIndTexCoordScale(int, int) const;
|
||||
J3DFog* newFog(int) const;
|
||||
J3DAlphaComp newAlphaComp(int) const;
|
||||
J3DBlend newBlend(int) const;
|
||||
J3DZMode newZMode(int) const;
|
||||
u8 newZCompLoc(int) const;
|
||||
u8 newDither(int) const;
|
||||
J3DNBTScale newNBTScale(int) const;
|
||||
|
||||
u16 getMaterialID(int i_idx) const { return mpMaterialID[i_idx]; }
|
||||
void getMaterialMode(int) const {}
|
||||
u16 getMaterialID(int idx) const { return mpMaterialID[idx]; }
|
||||
u8 getMaterialMode(int idx) const { return mpMaterialInitData[getMaterialID(idx)].mMaterialMode; }
|
||||
|
||||
private:
|
||||
/* 0x00 */ u8 field_0x00[8];
|
||||
/* 0x00 */ u16 mMaterialNum;
|
||||
/* 0x02 */
|
||||
/* 0x04 */ J3DMaterialInitData* mpMaterialInitData;
|
||||
/* 0x08 */ u16* mpMaterialID;
|
||||
/* 0x0C */ u8 field_0x0c[0x7C];
|
||||
/* 0x0C */ J3DIndInitData* mpIndInitData;
|
||||
/* 0x10 */ GXColor* mpMatColor;
|
||||
/* 0x14 */ u8* mpColorChanNum;
|
||||
/* 0x18 */ J3DColorChanInfo* mpColorChanInfo;
|
||||
/* 0x1C */ GXColor* mpAmbColor;
|
||||
/* 0x20 */ J3DLightInfo* mpLightInfo;
|
||||
/* 0x24 */ u8* mpTexGenNum;
|
||||
/* 0x28 */ J3DTexCoordInfo* mpTexCoordInfo;
|
||||
/* 0x2C */ J3DTexCoord2Info* mpTexCoord2Info;
|
||||
/* 0x30 */ J3DTexMtxInfo* mpTexMtxInfo;
|
||||
/* 0x34 */ J3DTexMtxInfo* field_0x44;
|
||||
/* 0x38 */ u16* mpTexNo;
|
||||
/* 0x3C */ GXCullMode* mpCullMode;
|
||||
/* 0x40 */ J3DTevOrderInfo* mpTevOrderInfo;
|
||||
/* 0x44 */ GXColorS10* mpTevColor;
|
||||
/* 0x48 */ GXColor* mpTevKColor;
|
||||
/* 0x4C */ u8* mpTevStageNum;
|
||||
/* 0x50 */ J3DTevStageInfo* mpTevStageInfo;
|
||||
/* 0x54 */ J3DTevSwapModeInfo* mpTevSwapModeInfo;
|
||||
/* 0x58 */ J3DTevSwapModeTableInfo* mpTevSwapModeTableInfo;
|
||||
/* 0x5C */ J3DFogInfo* mpFogInfo;
|
||||
/* 0x60 */ J3DAlphaCompInfo* mpAlphaCompInfo;
|
||||
/* 0x64 */ J3DBlendInfo* mpBlendInfo;
|
||||
/* 0x68 */ J3DZModeInfo* mpZModeInfo;
|
||||
/* 0x6C */ u8* mpZCompLoc;
|
||||
/* 0x70 */ u8* mpDither;
|
||||
/* 0x74 */ J3DNBTScaleInfo* mpNBTScaleInfo;
|
||||
/* 0x78 */ J3DDisplayListInit* mpDisplayListInit;
|
||||
/* 0x7C */ J3DPatchingInfo* mpPatchingInfo;
|
||||
/* 0x80 */ J3DCurrentMtxInfo* mpCurrentMtxInfo;
|
||||
/* 0x84 */ u8* field_0x84;
|
||||
};
|
||||
|
||||
#endif /* J3DMATERIALFACTORY_H */
|
||||
|
||||
@@ -30,8 +30,8 @@ class J3DMaterialFactory_v21 {
|
||||
public:
|
||||
J3DMaterialFactory_v21(const J3DMaterialBlock_v21&);
|
||||
u16 countUniqueMaterials();
|
||||
void countTexGens(int) const;
|
||||
void countStages(int) const;
|
||||
u32 countTexGens(int) const;
|
||||
u32 countStages(int) const;
|
||||
J3DMaterial* create(J3DMaterial*, int, unsigned long) const;
|
||||
void newMatColor(int, int) const;
|
||||
void newColorChanNum(int) const;
|
||||
|
||||
@@ -102,9 +102,9 @@ struct J3DMaterialBlock_v21 : public J3DModelBlock {
|
||||
|
||||
struct J3DMaterialDLBlock : public J3DModelBlock {
|
||||
/* 0x08 */ u16 mMaterialNum;
|
||||
/* 0x0C */ void* field_0x0c;
|
||||
/* 0x10 */ void* field_0x10;
|
||||
/* 0x14 */ void* field_0x14;
|
||||
/* 0x0C */ void* mpDisplayListInit;
|
||||
/* 0x10 */ void* mpPatchingInfo;
|
||||
/* 0x14 */ void* mpCurrentMtxInfo;
|
||||
/* 0x18 */ void* field_0x18;
|
||||
/* 0x1C */ void* field_0x1c;
|
||||
/* 0x20 */ void* mpNameTable;
|
||||
|
||||
@@ -4,209 +4,637 @@
|
||||
//
|
||||
|
||||
#include "JSystem/J3DGraphLoader/J3DMaterialFactory.h"
|
||||
#include "JSystem/J3DGraphLoader/J3DModelLoader.h"
|
||||
#include "JSystem/J3DGraphBase/J3DMatBlock.h"
|
||||
#include "JSystem/JSupport/JSupport.h"
|
||||
|
||||
/* 802F68F0-802F6B38 .text __ct__18J3DMaterialFactoryFRC16J3DMaterialBlock */
|
||||
J3DMaterialFactory::J3DMaterialFactory(const J3DMaterialBlock&) {
|
||||
/* Nonmatching */
|
||||
J3DMaterialFactory::J3DMaterialFactory(const J3DMaterialBlock& block) {
|
||||
mMaterialNum = block.mMaterialNum;
|
||||
mpMaterialInitData = JSUConvertOffsetToPtr<J3DMaterialInitData>(&block, block.mpMaterialInitData);
|
||||
mpMaterialID = JSUConvertOffsetToPtr<u16>(&block, block.mpMaterialID);
|
||||
|
||||
if (block.mpIndInitData != NULL && ((u32)block.mpIndInitData - (u32)block.mpNameTable) > 4)
|
||||
mpIndInitData = JSUConvertOffsetToPtr<J3DIndInitData>(&block, block.mpIndInitData);
|
||||
else
|
||||
mpIndInitData = NULL;
|
||||
|
||||
mpCullMode = JSUConvertOffsetToPtr<GXCullMode>(&block, block.mpCullMode);
|
||||
mpMatColor = JSUConvertOffsetToPtr<GXColor>(&block, block.mpMatColor);
|
||||
mpColorChanNum = JSUConvertOffsetToPtr<u8>(&block, block.mpColorChanNum);
|
||||
mpColorChanInfo = JSUConvertOffsetToPtr<J3DColorChanInfo>(&block, block.mpColorChanInfo);
|
||||
mpAmbColor = JSUConvertOffsetToPtr<GXColor>(&block, block.mpAmbColor);
|
||||
mpLightInfo = JSUConvertOffsetToPtr<J3DLightInfo>(&block, block.mpLightInfo);
|
||||
mpTexGenNum = JSUConvertOffsetToPtr<u8>(&block, block.mpTexGenNum);
|
||||
mpTexCoordInfo = JSUConvertOffsetToPtr<J3DTexCoordInfo>(&block, block.mpTexCoordInfo);
|
||||
mpTexCoord2Info = JSUConvertOffsetToPtr<J3DTexCoord2Info>(&block, block.mpTexCoord2Info);
|
||||
mpTexMtxInfo = JSUConvertOffsetToPtr<J3DTexMtxInfo>(&block, block.mpTexMtxInfo);
|
||||
field_0x44 = JSUConvertOffsetToPtr<J3DTexMtxInfo>(&block, block.field_0x44);
|
||||
mpTexNo = JSUConvertOffsetToPtr<u16>(&block, block.mpTexNo);
|
||||
mpTevOrderInfo = JSUConvertOffsetToPtr<J3DTevOrderInfo>(&block, block.mpTevOrderInfo);
|
||||
mpTevColor = JSUConvertOffsetToPtr<GXColorS10>(&block, block.mpTevColor);
|
||||
mpTevKColor = JSUConvertOffsetToPtr<GXColor>(&block, block.mpTevKColor);
|
||||
mpTevStageNum = JSUConvertOffsetToPtr<u8>(&block, block.mpTevStageNum);
|
||||
mpTevStageInfo = JSUConvertOffsetToPtr<J3DTevStageInfo>(&block, block.mpTevStageInfo);
|
||||
mpTevSwapModeInfo = JSUConvertOffsetToPtr<J3DTevSwapModeInfo>(&block, block.mpTevSwapModeInfo);
|
||||
mpTevSwapModeTableInfo = JSUConvertOffsetToPtr<J3DTevSwapModeTableInfo>(&block, block.mpTevSwapModeTableInfo);
|
||||
mpFogInfo = JSUConvertOffsetToPtr<J3DFogInfo>(&block, block.mpFogInfo);
|
||||
mpAlphaCompInfo = JSUConvertOffsetToPtr<J3DAlphaCompInfo>(&block, block.mpAlphaCompInfo);
|
||||
mpBlendInfo = JSUConvertOffsetToPtr<J3DBlendInfo>(&block, block.mpBlendInfo);
|
||||
mpZModeInfo = JSUConvertOffsetToPtr<J3DZModeInfo>(&block, block.mpZModeInfo);
|
||||
mpZCompLoc = JSUConvertOffsetToPtr<u8>(&block, block.mpZCompLoc);
|
||||
mpDither = JSUConvertOffsetToPtr<u8>(&block, block.mpDither);
|
||||
mpNBTScaleInfo = JSUConvertOffsetToPtr<J3DNBTScaleInfo>(&block, block.mpNBTScaleInfo);
|
||||
mpDisplayListInit = NULL;
|
||||
mpPatchingInfo = NULL;
|
||||
mpCurrentMtxInfo = NULL;
|
||||
field_0x84 = NULL;
|
||||
}
|
||||
|
||||
/* 802F6B38-802F6BC0 .text __ct__18J3DMaterialFactoryFRC18J3DMaterialDLBlock */
|
||||
J3DMaterialFactory::J3DMaterialFactory(const J3DMaterialDLBlock&) {
|
||||
J3DMaterialFactory::J3DMaterialFactory(const J3DMaterialDLBlock& block) {
|
||||
/* Nonmatching */
|
||||
mMaterialNum = block.mMaterialNum;
|
||||
mpMaterialInitData = NULL;
|
||||
mpDisplayListInit = JSUConvertOffsetToPtr<J3DDisplayListInit>(&block, block.mpDisplayListInit);
|
||||
mpPatchingInfo = JSUConvertOffsetToPtr<J3DPatchingInfo>(&block, block.mpPatchingInfo);
|
||||
mpCurrentMtxInfo = JSUConvertOffsetToPtr<J3DCurrentMtxInfo>(&block, block.mpCurrentMtxInfo);
|
||||
field_0x84 = JSUConvertOffsetToPtr<u8>(&block, block.field_0x18);
|
||||
}
|
||||
|
||||
/* 802F6BC0-802F6C08 .text countUniqueMaterials__18J3DMaterialFactoryFv */
|
||||
u16 J3DMaterialFactory::countUniqueMaterials() {
|
||||
/* Nonmatching */
|
||||
u16 num = 0;
|
||||
s32 maxID = -1;
|
||||
for (u16 i = 0; i < mMaterialNum; i++) {
|
||||
if (maxID < mpMaterialID[i]) {
|
||||
num++;
|
||||
maxID = mpMaterialID[i];
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
/* 802F6C08-802F6C40 .text countTexGens__18J3DMaterialFactoryCFi */
|
||||
void J3DMaterialFactory::countTexGens(int) const {
|
||||
/* Nonmatching */
|
||||
u32 J3DMaterialFactory::countTexGens(int idx) const {
|
||||
u8 no = mpMaterialInitData[mpMaterialID[idx]].mTexGenNumIdx;
|
||||
if (no != 0xFF)
|
||||
return mpTexGenNum[no];
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 802F6C40-802F6CC8 .text countStages__18J3DMaterialFactoryCFi */
|
||||
void J3DMaterialFactory::countStages(int) const {
|
||||
/* Nonmatching */
|
||||
u32 J3DMaterialFactory::countStages(int idx) const {
|
||||
J3DMaterialInitData* initData = &mpMaterialInitData[mpMaterialID[idx]];
|
||||
|
||||
u32 texGenNum = 0;
|
||||
u32 tevStageNum = 0;
|
||||
|
||||
u8 no = initData->mTevStageNumIdx;
|
||||
if (no != 0xFF)
|
||||
tevStageNum = mpTevStageNum[no];
|
||||
|
||||
for (s32 i = 0; i < 8; i++)
|
||||
if (initData->mTexNoIdx[i] != 0xFFFF)
|
||||
texGenNum++;
|
||||
|
||||
if (tevStageNum != texGenNum && texGenNum != 0) {
|
||||
return tevStageNum > texGenNum ? tevStageNum : texGenNum;
|
||||
} else {
|
||||
return tevStageNum;
|
||||
}
|
||||
}
|
||||
|
||||
/* 802F6CC8-802F6D44 .text create__18J3DMaterialFactoryCFP11J3DMaterialQ218J3DMaterialFactory12MaterialTypeiUl */
|
||||
J3DMaterial* J3DMaterialFactory::create(J3DMaterial*, J3DMaterialFactory::MaterialType, int, unsigned long) const {
|
||||
J3DMaterial* J3DMaterialFactory::create(J3DMaterial* mat, J3DMaterialFactory::MaterialType type, int idx, u32 flag) const {
|
||||
/* Nonmatching */
|
||||
switch (type) {
|
||||
case MATERIAL_TYPE_NORMAL:
|
||||
return createNormalMaterial(mat, idx, flag);
|
||||
case MATERIAL_TYPE_LOCKED:
|
||||
return createLockedMaterial(mat, idx, flag);
|
||||
case MATERIAL_TYPE_PATCHED:
|
||||
return createPatchedMaterial(mat, idx, flag);
|
||||
}
|
||||
}
|
||||
|
||||
static inline u32 getMdlDataFlag_TevStageNum(u32 flag) { return (flag >> 16) & 0x1F; }
|
||||
static inline u32 getMdlDataFlag_TexGenFlag(u32 flag) { return flag & 0x0C000000; }
|
||||
static inline u32 getMdlDataFlag_PEFlag(u32 flag) { return flag & 0x30000000; }
|
||||
static inline u32 getMdlDataFlag_ColorFlag(u32 flag) { return flag & 0xC0000000; }
|
||||
|
||||
/* 802F6D44-802F768C .text createNormalMaterial__18J3DMaterialFactoryCFP11J3DMaterialiUl */
|
||||
void J3DMaterialFactory::createNormalMaterial(J3DMaterial*, int, unsigned long) const {
|
||||
J3DMaterial* J3DMaterialFactory::createNormalMaterial(J3DMaterial* mat, int idx, u32 flag) const {
|
||||
/* Nonmatching */
|
||||
if (mpDisplayListInit != NULL)
|
||||
return createLockedMaterial(mat, idx, flag);
|
||||
|
||||
u32 stageNum = countStages(idx);
|
||||
u32 tevStageNum = getMdlDataFlag_TevStageNum(flag);
|
||||
|
||||
if (stageNum > tevStageNum)
|
||||
tevStageNum = stageNum;
|
||||
|
||||
u32 texGenNum = countTexGens(idx);
|
||||
u32 texGenFlag = texGenNum > 4 ? 0 : getMdlDataFlag_TexGenFlag(flag);
|
||||
u32 colorFlag = getMdlDataFlag_ColorFlag(flag);
|
||||
u32 peFlag = getMdlDataFlag_PEFlag(flag);
|
||||
u32 indFlag = !!(flag & 0x01000000);
|
||||
|
||||
if (mat == NULL)
|
||||
mat = new J3DMaterial();
|
||||
|
||||
mat->mColorBlock = J3DMaterial::createColorBlock(colorFlag);
|
||||
mat->mTexGenBlock = J3DMaterial::createTexGenBlock(texGenFlag);
|
||||
mat->mTevBlock = J3DMaterial::createTevBlock(tevStageNum);
|
||||
mat->mIndBlock = J3DMaterial::createIndBlock(indFlag);
|
||||
mat->mPEBlock = J3DMaterial::createPEBlock(peFlag, getMaterialMode(idx));
|
||||
mat->mIndex = idx;
|
||||
mat->mMaterialMode = getMaterialMode(idx);
|
||||
mat->mColorBlock->setColorChanNum(newColorChanNum(idx));
|
||||
mat->mColorBlock->setCullMode(newCullMode(idx));
|
||||
mat->mTexGenBlock->setTexGenNum(newTexGenNum(idx));
|
||||
mat->mTexGenBlock->setNBTScale(newNBTScale(idx));
|
||||
mat->mPEBlock->setFog(newFog(idx));
|
||||
mat->mPEBlock->setAlphaComp(newAlphaComp(idx));
|
||||
mat->mPEBlock->setBlend(newBlend(idx));
|
||||
mat->mPEBlock->setZMode(newZMode(idx));
|
||||
mat->mPEBlock->setZCompLoc(newZCompLoc(idx));
|
||||
mat->mPEBlock->setDither(newDither(idx));
|
||||
mat->mTevBlock->setTevStageNum(newTevStageNum(idx));
|
||||
|
||||
for (u8 i = 0; i < tevStageNum; i++)
|
||||
mat->mTevBlock->setTexNo(i, newTexNo(idx, i));
|
||||
for (u8 i = 0; i < tevStageNum; i++)
|
||||
mat->mTevBlock->setTevOrder(i, newTevOrder(idx, i));
|
||||
for (u8 i = 0; i < tevStageNum; i++) {
|
||||
J3DMaterialInitData* initData = &mpMaterialInitData[mpMaterialID[idx]];
|
||||
mat->mTevBlock->setTevStage(i, newTevStage(idx, i));
|
||||
if (initData->mTevSwapModeIdx[i] != 0xFFFF) {
|
||||
mat->mTevBlock->getTevStage(i)->setTexSel(mpTevSwapModeInfo[initData->mTevSwapModeIdx[i]].mTexSel);
|
||||
mat->mTevBlock->getTevStage(i)->setRasSel(mpTevSwapModeInfo[initData->mTevSwapModeIdx[i]].mRasSel);
|
||||
}
|
||||
}
|
||||
for (u8 i = 0; i < 4; i++)
|
||||
mat->mTevBlock->setTevKColor(i, newTevKColor(idx, i));
|
||||
for (u8 i = 0; i < 4; i++)
|
||||
mat->mTevBlock->setTevColor(i, newTevColor(idx, i));
|
||||
for (u8 i = 0; i < 4; i++)
|
||||
mat->mTevBlock->setTevSwapModeTable(i, newTevSwapModeTable(idx, i));
|
||||
for (u8 i = 0; i < 2; i++)
|
||||
mat->mColorBlock->setAmbColor(i, newAmbColor(idx, i));
|
||||
for (u8 i = 0; i < 2; i++)
|
||||
mat->mColorBlock->setMatColor(i, newMatColor(idx, i));
|
||||
for (u8 i = 0; i < 4; i++)
|
||||
mat->mColorBlock->setColorChan(i, newColorChan(idx, i));
|
||||
for (u8 i = 0; i < texGenNum; i++) {
|
||||
J3DTexCoord texCoord = newTexCoord(idx, i);
|
||||
mat->mTexGenBlock->setTexCoord(i, &texCoord);
|
||||
}
|
||||
for (u8 i = 0; i < 8; i++) {
|
||||
mat->mTexGenBlock->setTexMtx(i, newTexMtx(idx, i));
|
||||
}
|
||||
J3DMaterialInitData* initData = &mpMaterialInitData[mpMaterialID[idx]];
|
||||
for (u8 i = 0; i < tevStageNum; i++) {
|
||||
if (initData->mTevKColorSel[i] != 0xff) {
|
||||
mat->mTevBlock->setTevKColorSel(i, initData->mTevKColorSel[i]);
|
||||
} else {
|
||||
mat->mTevBlock->setTevKColorSel(i, 0xc);
|
||||
}
|
||||
}
|
||||
for (u8 i = 0; i < tevStageNum; i++) {
|
||||
if (initData->mTevKAlphaSel[i] != 0xff) {
|
||||
mat->mTevBlock->setTevKAlphaSel(i, initData->mTevKAlphaSel[i]);
|
||||
} else {
|
||||
mat->mTevBlock->setTevKAlphaSel(i, 0x1c);
|
||||
}
|
||||
}
|
||||
if (mpIndInitData != NULL) {
|
||||
u8 indTexStageNum = newIndTexStageNum(idx);
|
||||
mat->mIndBlock->setIndTexStageNum(newIndTexStageNum(idx));
|
||||
for (u8 i = 0; i < indTexStageNum; i++)
|
||||
mat->mIndBlock->setIndTexMtx(i, newIndTexMtx(idx, i));
|
||||
for (u8 i = 0; i < indTexStageNum; i++)
|
||||
mat->mIndBlock->setIndTexOrder(i, newIndTexOrder(idx, i));
|
||||
for (u8 i = 0; i < indTexStageNum; i++)
|
||||
mat->mIndBlock->setIndTexCoordScale(i, newIndTexCoordScale(idx, i));
|
||||
for (u8 i = 0; i < tevStageNum; i++)
|
||||
mat->mTevBlock->setIndTevStage(i, newIndTevStage(idx, i));
|
||||
}
|
||||
return mat;
|
||||
}
|
||||
|
||||
/* 802F768C-802F7F98 .text createPatchedMaterial__18J3DMaterialFactoryCFP11J3DMaterialiUl */
|
||||
void J3DMaterialFactory::createPatchedMaterial(J3DMaterial*, int, unsigned long) const {
|
||||
J3DMaterial* J3DMaterialFactory::createPatchedMaterial(J3DMaterial* mat, int idx, u32 flag) const {
|
||||
/* Nonmatching */
|
||||
if (mat == NULL)
|
||||
mat = new J3DPatchedMaterial();
|
||||
|
||||
u32 indFlag = (flag & 0x03000000) ? 1 : 0;
|
||||
mat->mColorBlock = J3DMaterial::createColorBlock(0x40000000);
|
||||
|
||||
mat->mTexGenBlock = new J3DTexGenBlockPatched();
|
||||
mat->mTevBlock = new J3DTevBlockPatched();
|
||||
mat->mIndBlock = J3DMaterial::createIndBlock(indFlag);
|
||||
mat->mPEBlock = J3DMaterial::createPEBlock(0x10000000, getMaterialMode(idx));
|
||||
mat->mIndex = idx;
|
||||
mat->mMaterialMode = getMaterialMode(idx);
|
||||
mat->mTevBlock->setTevStageNum(newTevStageNum(idx));
|
||||
mat->mColorBlock->setColorChanNum(newColorChanNum(idx));
|
||||
mat->mColorBlock->setCullMode(newCullMode(idx));
|
||||
mat->mPEBlock->setFog(newFog(idx));
|
||||
mat->mPEBlock->setAlphaComp(newAlphaComp(idx));
|
||||
mat->mPEBlock->setBlend(newBlend(idx));
|
||||
mat->mPEBlock->setZMode(newZMode(idx));
|
||||
mat->mPEBlock->setZCompLoc(newZCompLoc(idx));
|
||||
mat->mPEBlock->setDither(newDither(idx));
|
||||
|
||||
u8 tevStageNum = mat->mTevBlock->getTevStageNum();
|
||||
for (u8 i = 0; i < 8; i++)
|
||||
mat->mTevBlock->setTexNo(i, newTexNo(idx, i));
|
||||
for (u8 i = 0; i < tevStageNum; i++)
|
||||
mat->mTevBlock->setTevOrder(i, newTevOrder(idx, i));
|
||||
for (u8 i = 0; i < 4; i++)
|
||||
mat->mTevBlock->setTevKColor(i, newTevKColor(idx, i));
|
||||
for (u8 i = 0; i < 4; i++)
|
||||
mat->mTevBlock->setTevColor(i, newTevColor(idx, i));
|
||||
for (u8 i = 0; i < tevStageNum; i++) {
|
||||
J3DMaterialInitData* initData = &mpMaterialInitData[mpMaterialID[idx]];
|
||||
mat->mTevBlock->setTevStage(i, newTevStage(idx, i));
|
||||
if (initData->mTevSwapModeIdx[i] != 0xFFFF) {
|
||||
mat->mTevBlock->getTevStage(i)->setTexSel(mpTevSwapModeInfo[initData->mTevSwapModeIdx[i]].mTexSel);
|
||||
mat->mTevBlock->getTevStage(i)->setRasSel(mpTevSwapModeInfo[initData->mTevSwapModeIdx[i]].mRasSel);
|
||||
}
|
||||
}
|
||||
J3DMaterialInitData* initData = &mpMaterialInitData[mpMaterialID[idx]];
|
||||
for (u8 i = 0; i < tevStageNum; i++) {
|
||||
if (initData->mTevKColorSel[i] != 0xff) {
|
||||
mat->mTevBlock->setTevKColorSel(i, initData->mTevKColorSel[i]);
|
||||
} else {
|
||||
mat->mTevBlock->setTevKColorSel(i, 0xc);
|
||||
}
|
||||
}
|
||||
for (u8 i = 0; i < 2; i++)
|
||||
mat->mColorBlock->setMatColor(i, newMatColor(idx, i));
|
||||
for (u8 i = 0; i < 4; i++)
|
||||
mat->mColorBlock->setColorChan(i, newColorChan(idx, i));
|
||||
|
||||
u32 texGenNum = countTexGens(idx);
|
||||
mat->mTexGenBlock->setTexGenNum(newTexGenNum(idx));
|
||||
for (u8 i = 0; i < 8; i++)
|
||||
mat->mTexGenBlock->setTexMtx(i, newTexMtx(idx, i));
|
||||
for (u8 i = 0; i < texGenNum; i++) {
|
||||
J3DTexCoord texCoord = newTexCoord(idx, i);
|
||||
mat->mTexGenBlock->setTexCoord(i, &texCoord);
|
||||
}
|
||||
if (mpIndInitData != NULL) {
|
||||
u8 indTexStageNum = newIndTexStageNum(idx);
|
||||
mat->mIndBlock->setIndTexStageNum(newIndTexStageNum(idx));
|
||||
for (u8 i = 0; i < indTexStageNum; i++)
|
||||
mat->mIndBlock->setIndTexMtx(i, newIndTexMtx(idx, i));
|
||||
for (u8 i = 0; i < indTexStageNum; i++)
|
||||
mat->mIndBlock->setIndTexOrder(i, newIndTexOrder(idx, i));
|
||||
for (u8 i = 0; i < indTexStageNum; i++)
|
||||
mat->mIndBlock->setIndTexCoordScale(i, newIndTexCoordScale(idx, i));
|
||||
for (u8 i = 0; i < tevStageNum; i++)
|
||||
mat->mTevBlock->setIndTevStage(i, newIndTevStage(idx, i));
|
||||
}
|
||||
return mat;
|
||||
}
|
||||
|
||||
/* 802F7F98-802F80F8 .text modifyPatchedCurrentMtx__18J3DMaterialFactoryCFP11J3DMateriali */
|
||||
void J3DMaterialFactory::modifyPatchedCurrentMtx(J3DMaterial*, int) const {
|
||||
void J3DMaterialFactory::modifyPatchedCurrentMtx(J3DMaterial* mat, int idx) const {
|
||||
/* Nonmatching */
|
||||
J3DTexCoord coord[8];
|
||||
u32 texGenNum = countTexGens(idx);
|
||||
for (u8 i = 0; i < texGenNum; i++)
|
||||
coord[i] = newTexCoord(idx, i);
|
||||
mat->mCurrentMtx.setCurrentTexMtx(
|
||||
coord[0].getTexGenMtx(),
|
||||
coord[1].getTexGenMtx(),
|
||||
coord[2].getTexGenMtx(),
|
||||
coord[3].getTexGenMtx(),
|
||||
coord[4].getTexGenMtx(),
|
||||
coord[5].getTexGenMtx(),
|
||||
coord[6].getTexGenMtx(),
|
||||
coord[7].getTexGenMtx()
|
||||
);
|
||||
}
|
||||
|
||||
/* 802F80F8-802F83A0 .text createLockedMaterial__18J3DMaterialFactoryCFP11J3DMaterialiUl */
|
||||
void J3DMaterialFactory::createLockedMaterial(J3DMaterial*, int, unsigned long) const {
|
||||
/* Nonmatching */
|
||||
J3DMaterial* J3DMaterialFactory::createLockedMaterial(J3DMaterial* mat, int idx, u32 flag) const {
|
||||
/* Nonmatching - J3DCurrentMtx constructor */
|
||||
if (mat == NULL) {
|
||||
mat = new J3DLockedMaterial();
|
||||
mat->mColorBlock = new J3DColorBlockNull();
|
||||
mat->mTexGenBlock = new J3DTexGenBlockNull();
|
||||
mat->mTevBlock = new J3DTevBlockNull();
|
||||
mat->mIndBlock = new J3DIndBlockNull();
|
||||
mat->mPEBlock = new J3DPEBlockNull();
|
||||
mat->mIndex = idx;
|
||||
mat->mMaterialMode = field_0x84[idx];
|
||||
}
|
||||
|
||||
mat->mCurrentMtx = J3DCurrentMtx(mpCurrentMtxInfo[idx]);
|
||||
mat->mColorBlock->setMatColorOffset(mpPatchingInfo[idx].mMatColorOffset);
|
||||
mat->mColorBlock->setColorChanOffset(mpPatchingInfo[idx].mColorChanOffset);
|
||||
mat->mTexGenBlock->setTexMtxOffset(mpPatchingInfo[idx].mTexMtxOffset);
|
||||
mat->mTevBlock->setTexNoOffset(mpPatchingInfo[idx].mTexNoOffset);
|
||||
mat->mTevBlock->setTevRegOffset(mpPatchingInfo[idx].mTevRegOffset);
|
||||
mat->mPEBlock->setFogOffset(mpPatchingInfo[idx].mFogOffset);
|
||||
if (mat->mSharedDLObj == NULL) {
|
||||
mat->mSharedDLObj = new J3DDisplayListObj();
|
||||
mat->mSharedDLObj->setSingleDisplayList((void*)(mpDisplayListInit[idx].mOffset + (u32)&mpDisplayListInit[idx]), mpDisplayListInit[idx].mSize);
|
||||
}
|
||||
return mat;
|
||||
}
|
||||
|
||||
/* 802F83A0-802F8420 .text calcSize__18J3DMaterialFactoryCFP11J3DMaterialQ218J3DMaterialFactory12MaterialTypeiUl */
|
||||
u32 J3DMaterialFactory::calcSize(J3DMaterial*, J3DMaterialFactory::MaterialType, int, unsigned long) const {
|
||||
/* Nonmatching */
|
||||
u32 J3DMaterialFactory::calcSize(J3DMaterial* mat, J3DMaterialFactory::MaterialType type, int idx, u32 flag) const {
|
||||
u32 ret = 0;
|
||||
switch (type) {
|
||||
case MATERIAL_TYPE_NORMAL:
|
||||
ret = calcSizeNormalMaterial(mat, idx, flag);
|
||||
break;
|
||||
case MATERIAL_TYPE_LOCKED:
|
||||
ret = calcSizeLockedMaterial(mat, idx, flag);
|
||||
break;
|
||||
case MATERIAL_TYPE_PATCHED:
|
||||
ret = calcSizePatchedMaterial(mat, idx, flag);
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 802F8420-802F8554 .text calcSizeNormalMaterial__18J3DMaterialFactoryCFP11J3DMaterialiUl */
|
||||
u32 J3DMaterialFactory::calcSizeNormalMaterial(J3DMaterial*, int, unsigned long) const {
|
||||
u32 J3DMaterialFactory::calcSizeNormalMaterial(J3DMaterial*, int, u32) const {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F8554-802F8624 .text calcSizePatchedMaterial__18J3DMaterialFactoryCFP11J3DMaterialiUl */
|
||||
u32 J3DMaterialFactory::calcSizePatchedMaterial(J3DMaterial*, int, unsigned long) const {
|
||||
u32 J3DMaterialFactory::calcSizePatchedMaterial(J3DMaterial*, int, u32) const {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F8624-802F863C .text calcSizeLockedMaterial__18J3DMaterialFactoryCFP11J3DMaterialiUl */
|
||||
u32 J3DMaterialFactory::calcSizeLockedMaterial(J3DMaterial*, int, unsigned long) const {
|
||||
u32 J3DMaterialFactory::calcSizeLockedMaterial(J3DMaterial*, int, u32) const {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802F863C-802F86CC .text newMatColor__18J3DMaterialFactoryCFii */
|
||||
void J3DMaterialFactory::newMatColor(int, int) const {
|
||||
/* Nonmatching */
|
||||
J3DGXColor J3DMaterialFactory::newMatColor(int idx, int stage) const {
|
||||
GXColor _ret = { 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
J3DGXColor ret(_ret);
|
||||
J3DMaterialInitData* initData = &mpMaterialInitData[mpMaterialID[idx]];
|
||||
u16 no = mpMaterialInitData[mpMaterialID[idx]].mMatColorIdx[stage];
|
||||
if (no != 0xFFFF)
|
||||
return mpMatColor[no];
|
||||
else
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 802F86CC-802F8704 .text newColorChanNum__18J3DMaterialFactoryCFi */
|
||||
void J3DMaterialFactory::newColorChanNum(int) const {
|
||||
/* Nonmatching */
|
||||
u8 J3DMaterialFactory::newColorChanNum(int idx) const {
|
||||
u8 no = mpMaterialInitData[mpMaterialID[idx]].mColorChanNumIdx;
|
||||
if (no != 0xFF)
|
||||
return mpColorChanNum[no];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 802F8704-802F88A8 .text newColorChan__18J3DMaterialFactoryCFii */
|
||||
void J3DMaterialFactory::newColorChan(int, int) const {
|
||||
J3DColorChan J3DMaterialFactory::newColorChan(int idx, int stage) const {
|
||||
/* Nonmatching */
|
||||
u16 no = mpMaterialInitData[mpMaterialID[idx]].mColorChanIdx[stage];
|
||||
if (no != 0xFFFF)
|
||||
return J3DColorChan(mpColorChanInfo[no]);
|
||||
else
|
||||
return J3DColorChan();
|
||||
}
|
||||
|
||||
/* 802F88A8-802F8938 .text newAmbColor__18J3DMaterialFactoryCFii */
|
||||
void J3DMaterialFactory::newAmbColor(int, int) const {
|
||||
/* Nonmatching */
|
||||
J3DGXColor J3DMaterialFactory::newAmbColor(int idx, int stage) const {
|
||||
GXColor _ret = { 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
J3DGXColor ret(_ret);
|
||||
J3DMaterialInitData* initData = &mpMaterialInitData[mpMaterialID[idx]];
|
||||
u16 no = mpMaterialInitData[mpMaterialID[idx]].mAmbColorIdx[stage];
|
||||
if (no != 0xFFFF)
|
||||
return mpAmbColor[no];
|
||||
else
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 802F8938-802F8970 .text newTexGenNum__18J3DMaterialFactoryCFi */
|
||||
void J3DMaterialFactory::newTexGenNum(int) const {
|
||||
/* Nonmatching */
|
||||
u32 J3DMaterialFactory::newTexGenNum(int idx) const {
|
||||
u8 no = mpMaterialInitData[mpMaterialID[idx]].mTexGenNumIdx;
|
||||
if (no != 0xFF)
|
||||
return mpTexGenNum[no];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 802F8970-802F89E4 .text newTexCoord__18J3DMaterialFactoryCFii */
|
||||
void J3DMaterialFactory::newTexCoord(int, int) const {
|
||||
/* Nonmatching */
|
||||
J3DTexCoord J3DMaterialFactory::newTexCoord(int idx, int stage) const {
|
||||
u16 no = mpMaterialInitData[mpMaterialID[idx]].mTexCoordIdx[stage];
|
||||
if (no != 0xFFFF)
|
||||
return J3DTexCoord(mpTexCoordInfo[no]);
|
||||
else
|
||||
return J3DTexCoord();
|
||||
}
|
||||
|
||||
/* 802F89E4-802F8AF4 .text newTexMtx__18J3DMaterialFactoryCFii */
|
||||
void J3DMaterialFactory::newTexMtx(int, int) const {
|
||||
/* Nonmatching */
|
||||
J3DTexMtx* J3DMaterialFactory::newTexMtx(int idx, int stage) const {
|
||||
J3DTexMtx* ret = NULL;
|
||||
J3DMaterialInitData* initData = &mpMaterialInitData[mpMaterialID[idx]];
|
||||
if (initData->mTexMtxIdx[stage] != 0xFFFF)
|
||||
ret = new J3DTexMtx(mpTexMtxInfo[initData->mTexMtxIdx[stage]]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 802F8AF4-802F8B34 .text newCullMode__18J3DMaterialFactoryCFi */
|
||||
void J3DMaterialFactory::newCullMode(int) const {
|
||||
/* Nonmatching */
|
||||
u8 J3DMaterialFactory::newCullMode(int idx) const {
|
||||
u8 no = mpMaterialInitData[mpMaterialID[idx]].mCullModeIdx;
|
||||
if (no != 0xFF)
|
||||
return mpCullMode[no];
|
||||
else
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
/* 802F8B34-802F8B7C .text newTexNo__18J3DMaterialFactoryCFii */
|
||||
void J3DMaterialFactory::newTexNo(int, int) const {
|
||||
/* Nonmatching */
|
||||
u16 J3DMaterialFactory::newTexNo(int idx, int stage) const {
|
||||
u16 no = mpMaterialInitData[mpMaterialID[idx]].mTexNoIdx[stage];
|
||||
if (no != 0xFFFF)
|
||||
return mpTexNo[no];
|
||||
else
|
||||
return 0xFFFF;
|
||||
}
|
||||
|
||||
/* 802F8B7C-802F8BF0 .text newTevOrder__18J3DMaterialFactoryCFii */
|
||||
void J3DMaterialFactory::newTevOrder(int, int) const {
|
||||
/* Nonmatching */
|
||||
J3DTevOrder J3DMaterialFactory::newTevOrder(int idx, int stage) const {
|
||||
u16 no = mpMaterialInitData[mpMaterialID[idx]].mTevOrderIdx[stage];
|
||||
if (no != 0xFFFF)
|
||||
return J3DTevOrder(mpTevOrderInfo[no]);
|
||||
else
|
||||
return J3DTevOrder();
|
||||
}
|
||||
|
||||
/* 802F8BF0-802F8C88 .text newTevColor__18J3DMaterialFactoryCFii */
|
||||
void J3DMaterialFactory::newTevColor(int, int) const {
|
||||
/* Nonmatching */
|
||||
J3DGXColorS10 J3DMaterialFactory::newTevColor(int idx, int stage) const {
|
||||
GXColorS10 _ret = { 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
J3DGXColorS10 ret(_ret);
|
||||
J3DMaterialInitData* initData = &mpMaterialInitData[mpMaterialID[idx]];
|
||||
u16 no = mpMaterialInitData[mpMaterialID[idx]].mTevColorIdx[stage];
|
||||
if (no != 0xFFFF)
|
||||
return mpTevColor[no];
|
||||
else
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 802F8C88-802F8D18 .text newTevKColor__18J3DMaterialFactoryCFii */
|
||||
void J3DMaterialFactory::newTevKColor(int, int) const {
|
||||
/* Nonmatching */
|
||||
J3DGXColor J3DMaterialFactory::newTevKColor(int idx, int stage) const {
|
||||
GXColor _ret = { 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
J3DGXColor ret(_ret);
|
||||
J3DMaterialInitData* initData = &mpMaterialInitData[mpMaterialID[idx]];
|
||||
u16 no = mpMaterialInitData[mpMaterialID[idx]].mTevKColorIdx[stage];
|
||||
if (no != 0xFFFF)
|
||||
return mpTevKColor[no];
|
||||
else
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 802F8D18-802F8D50 .text newTevStageNum__18J3DMaterialFactoryCFi */
|
||||
void J3DMaterialFactory::newTevStageNum(int) const {
|
||||
/* Nonmatching */
|
||||
u8 J3DMaterialFactory::newTevStageNum(int idx) const {
|
||||
u8 no = mpMaterialInitData[mpMaterialID[idx]].mTevStageNumIdx;
|
||||
if (no != 0xFF)
|
||||
return mpTevStageNum[no];
|
||||
else
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
/* 802F8D50-802F8DB0 .text newTevStage__18J3DMaterialFactoryCFii */
|
||||
void J3DMaterialFactory::newTevStage(int, int) const {
|
||||
/* Nonmatching */
|
||||
J3DTevStage J3DMaterialFactory::newTevStage(int idx, int stage) const {
|
||||
u16 no = mpMaterialInitData[mpMaterialID[idx]].mTevStageIdx[stage];
|
||||
if (no != 0xFFFF)
|
||||
return J3DTevStage(mpTevStageInfo[no]);
|
||||
else
|
||||
return J3DTevStage();
|
||||
}
|
||||
|
||||
/* 802F8DB0-802F8E4C .text newTevSwapModeTable__18J3DMaterialFactoryCFii */
|
||||
void J3DMaterialFactory::newTevSwapModeTable(int, int) const {
|
||||
/* Nonmatching */
|
||||
J3DTevSwapModeTable J3DMaterialFactory::newTevSwapModeTable(int idx, int stage) const {
|
||||
u16 no = mpMaterialInitData[mpMaterialID[idx]].mTevSwapModeTableIdx[stage];
|
||||
if (no != 0xFFFF)
|
||||
return J3DTevSwapModeTable(mpTevSwapModeTableInfo[no]);
|
||||
else
|
||||
return J3DTevSwapModeTable(j3dDefaultTevSwapModeTable);
|
||||
}
|
||||
|
||||
/* 802F8E4C-802F8E74 .text newIndTexStageNum__18J3DMaterialFactoryCFi */
|
||||
void J3DMaterialFactory::newIndTexStageNum(int) const {
|
||||
/* Nonmatching */
|
||||
u8 J3DMaterialFactory::newIndTexStageNum(int idx) const {
|
||||
if (mpIndInitData[idx].mEnabled == true)
|
||||
return mpIndInitData[idx].mIndTexStageNum;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 802F8E74-802F8ED4 .text newIndTexOrder__18J3DMaterialFactoryCFii */
|
||||
void J3DMaterialFactory::newIndTexOrder(int, int) const {
|
||||
/* Nonmatching */
|
||||
J3DIndTexOrder J3DMaterialFactory::newIndTexOrder(int idx, int stage) const {
|
||||
J3DIndTexOrder ret;
|
||||
if (mpIndInitData[idx].mEnabled == true)
|
||||
return J3DIndTexOrder(mpIndInitData[idx].mIndTexOrderInfo[stage]);
|
||||
else
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 802F8ED4-802F8FD0 .text newIndTexMtx__18J3DMaterialFactoryCFii */
|
||||
void J3DMaterialFactory::newIndTexMtx(int, int) const {
|
||||
/* Nonmatching */
|
||||
J3DIndTexMtx J3DMaterialFactory::newIndTexMtx(int idx, int stage) const {
|
||||
J3DIndTexMtx ret;
|
||||
if (mpIndInitData[idx].mEnabled == true)
|
||||
return J3DIndTexMtx(mpIndInitData[idx].mIndTexMtxInfo[stage]);
|
||||
else
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 802F8FD0-802F9164 .text newIndTevStage__18J3DMaterialFactoryCFii */
|
||||
void J3DMaterialFactory::newIndTevStage(int, int) const {
|
||||
/* Nonmatching */
|
||||
J3DIndTevStage J3DMaterialFactory::newIndTevStage(int idx, int stage) const {
|
||||
J3DIndTevStage ret;
|
||||
if (mpIndInitData[idx].mEnabled == true)
|
||||
return J3DIndTevStage(mpIndInitData[idx].mIndTevStageInfo[stage]);
|
||||
else
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 802F9164-802F91C4 .text newIndTexCoordScale__18J3DMaterialFactoryCFii */
|
||||
void J3DMaterialFactory::newIndTexCoordScale(int, int) const {
|
||||
/* Nonmatching */
|
||||
J3DIndTexCoordScale J3DMaterialFactory::newIndTexCoordScale(int idx, int stage) const {
|
||||
J3DIndTexCoordScale ret;
|
||||
if (mpIndInitData[idx].mEnabled == true)
|
||||
return J3DIndTexCoordScale(mpIndInitData[idx].mIndTexCoordScaleInfo[stage]);
|
||||
else
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 802F91C4-802F9348 .text newFog__18J3DMaterialFactoryCFi */
|
||||
void J3DMaterialFactory::newFog(int) const {
|
||||
/* Nonmatching */
|
||||
J3DFog* J3DMaterialFactory::newFog(int idx) const {
|
||||
J3DMaterialInitData* initData = &mpMaterialInitData[mpMaterialID[idx]];
|
||||
if (initData->mFogIdx != 0xFFFF)
|
||||
return new J3DFog(mpFogInfo[initData->mFogIdx]);
|
||||
else
|
||||
return new J3DFog();
|
||||
}
|
||||
|
||||
/* 802F9348-802F93C8 .text newAlphaComp__18J3DMaterialFactoryCFi */
|
||||
void J3DMaterialFactory::newAlphaComp(int) const {
|
||||
/* Nonmatching */
|
||||
J3DAlphaComp J3DMaterialFactory::newAlphaComp(int idx) const {
|
||||
/* Nonmatching - default constructor loads id 0xFFFF rather than j3dDefaultAlphaCompInfo */
|
||||
u16 no = mpMaterialInitData[mpMaterialID[idx]].mAlphaCompIdx;
|
||||
if (no != 0xFFFF)
|
||||
return J3DAlphaComp(mpAlphaCompInfo[no]);
|
||||
else
|
||||
return J3DAlphaComp();
|
||||
}
|
||||
|
||||
/* 802F93C8-802F9444 .text newBlend__18J3DMaterialFactoryCFi */
|
||||
void J3DMaterialFactory::newBlend(int) const {
|
||||
/* Nonmatching */
|
||||
J3DBlend J3DMaterialFactory::newBlend(int idx) const {
|
||||
u16 no = mpMaterialInitData[mpMaterialID[idx]].mBlendIdx;
|
||||
if (no != 0xFFFF)
|
||||
return J3DBlend(mpBlendInfo[no]);
|
||||
else
|
||||
return J3DBlend();
|
||||
}
|
||||
|
||||
/* 802F9444-802F94A4 .text newZMode__18J3DMaterialFactoryCFi */
|
||||
void J3DMaterialFactory::newZMode(int) const {
|
||||
/* Nonmatching */
|
||||
J3DZMode J3DMaterialFactory::newZMode(int idx) const {
|
||||
/* Nonmatching - J3DZModeInfo array seems to be 0x04-sized */
|
||||
u8 no = mpMaterialInitData[mpMaterialID[idx]].mZModeIdx;
|
||||
if (no != 0xFF)
|
||||
return J3DZMode(mpZModeInfo[no]);
|
||||
else
|
||||
return J3DZMode();
|
||||
}
|
||||
|
||||
/* 802F94A4-802F94DC .text newZCompLoc__18J3DMaterialFactoryCFi */
|
||||
void J3DMaterialFactory::newZCompLoc(int) const {
|
||||
/* Nonmatching */
|
||||
u8 J3DMaterialFactory::newZCompLoc(int idx) const {
|
||||
u8 no = mpMaterialInitData[mpMaterialID[idx]].mZCompLocIdx;
|
||||
if (no != 0xFF)
|
||||
return mpZCompLoc[no];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 802F94DC-802F9514 .text newDither__18J3DMaterialFactoryCFi */
|
||||
void J3DMaterialFactory::newDither(int) const {
|
||||
/* Nonmatching */
|
||||
u8 J3DMaterialFactory::newDither(int idx) const {
|
||||
u8 no = mpMaterialInitData[mpMaterialID[idx]].mDitherIdx;
|
||||
if (no != 0xFF)
|
||||
return mpDither[no];
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* 802F9514-802F95B8 .text newNBTScale__18J3DMaterialFactoryCFi */
|
||||
void J3DMaterialFactory::newNBTScale(int) const {
|
||||
/* Nonmatching */
|
||||
J3DNBTScale J3DMaterialFactory::newNBTScale(int idx) const {
|
||||
J3DNBTScale ret;
|
||||
u16 no = mpMaterialInitData[mpMaterialID[idx]].mNBTScaleIdx;
|
||||
if (no != 0xFFFF)
|
||||
return J3DNBTScale(mpNBTScaleInfo[no]);
|
||||
else
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -4,44 +4,228 @@
|
||||
//
|
||||
|
||||
#include "JSystem/J3DGraphLoader/J3DShapeFactory.h"
|
||||
#include "JSystem/J3DGraphBase/J3DShape.h"
|
||||
#include "JSystem/J3DGraphBase/J3DShapeDraw.h"
|
||||
#include "JSystem/J3DGraphBase/J3DShapeMtx.h"
|
||||
#include "JSystem/JSupport/JSupport.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "dolphin/gx/GXAttr.h"
|
||||
#include "dolphin/os/OS.h"
|
||||
|
||||
/* 802FE3A8-802FE458 .text __ct__15J3DShapeFactoryFRC13J3DShapeBlock */
|
||||
J3DShapeFactory::J3DShapeFactory(const J3DShapeBlock&) {
|
||||
/* Nonmatching */
|
||||
J3DShapeFactory::J3DShapeFactory(const J3DShapeBlock& block) {
|
||||
mpShapeInitData = JSUConvertOffsetToPtr<J3DShapeInitData>(&block, (u32)block.mpShapeInitData);
|
||||
mpIndexTable = JSUConvertOffsetToPtr<u16>(&block, (u32)block.mpIndexTable);
|
||||
mpVtxDescList = JSUConvertOffsetToPtr<GXVtxDescList>(&block, (u32)block.mpVtxDescList);
|
||||
mpMtxTable = JSUConvertOffsetToPtr<u16>(&block, (u32)block.mpMtxTable);
|
||||
mpDisplayListData = JSUConvertOffsetToPtr<u8>(&block, (u32)block.mpDisplayListData);
|
||||
mpMtxInitData = JSUConvertOffsetToPtr<J3DShapeMtxInitData>(&block, (u32)block.mpMtxInitData);
|
||||
mpDrawInitData = JSUConvertOffsetToPtr<J3DShapeDrawInitData>(&block, (u32)block.mpDrawInitData);
|
||||
mpVcdVatCmdBuffer = NULL;
|
||||
}
|
||||
|
||||
/* 802FE458-802FE614 .text create__15J3DShapeFactoryFiUlP14_GXVtxDescList */
|
||||
J3DShape* J3DShapeFactory::create(int, u32, GXVtxDescList*) {
|
||||
/* Nonmatching */
|
||||
J3DShape* J3DShapeFactory::create(int no, u32 flag, GXVtxDescList* vtxDesc) {
|
||||
J3DShape* shape = new J3DShape();
|
||||
shape->mMtxGroupNum = getMtxGroupNum(no);
|
||||
shape->mRadius = getRadius(no);
|
||||
shape->mVtxDesc = getVtxDescList(no);
|
||||
shape->mShapeMtx = new J3DShapeMtx*[shape->mMtxGroupNum];
|
||||
shape->mShapeDraw = new J3DShapeDraw*[shape->mMtxGroupNum];
|
||||
shape->mMin = getMin(no);
|
||||
shape->mMax = getMax(no);
|
||||
shape->mVcdVatCmd = mpVcdVatCmdBuffer + no * J3DShape::kVcdVatDLSize;
|
||||
|
||||
for (s32 i = 0; i < shape->mMtxGroupNum; i++) {
|
||||
shape->mShapeMtx[i] = newShapeMtx(flag, no, i);
|
||||
shape->mShapeDraw[i] = newShapeDraw(no, i);
|
||||
}
|
||||
|
||||
shape->mIndex = no;
|
||||
return shape;
|
||||
}
|
||||
|
||||
static inline u32 getMdlDataFlag_MtxLoadType(u32 flag) {
|
||||
return flag & 0xF0;
|
||||
}
|
||||
|
||||
enum {
|
||||
J3DMdlDataFlag_Imm = 0x10,
|
||||
J3DMdlDataFlag_ConcatView = 0x20,
|
||||
};
|
||||
|
||||
enum {
|
||||
J3DShapeMtxType_Mtx = 0x00,
|
||||
J3DShapeMtxType_BBoard = 0x01,
|
||||
J3DShapeMtxType_YBBoard = 0x02,
|
||||
J3DShapeMtxType_Multi = 0x03,
|
||||
};
|
||||
|
||||
/* 802FE614-802FEA40 .text newShapeMtx__15J3DShapeFactoryCFUlii */
|
||||
J3DShapeMtx* J3DShapeFactory::newShapeMtx(u32, int, int) const {
|
||||
/* Nonmatching */
|
||||
J3DShapeMtx* J3DShapeFactory::newShapeMtx(u32 flag, int shapeNo, int mtxGroupNo) const {
|
||||
J3DShapeMtx* ret = NULL;
|
||||
const J3DShapeInitData& shapeInitData = mpShapeInitData[mpIndexTable[shapeNo]];
|
||||
const J3DShapeMtxInitData& mtxInitData = (&mpMtxInitData[shapeInitData.mMtxInitDataIndex])[mtxGroupNo];
|
||||
|
||||
switch (getMdlDataFlag_MtxLoadType(flag)) {
|
||||
case J3DMdlDataFlag_Imm:
|
||||
switch (shapeInitData.mShapeMtxType) {
|
||||
case J3DShapeMtxType_Mtx:
|
||||
ret = new J3DShapeMtxImm(mtxInitData.mUseMtxIndex);
|
||||
break;
|
||||
case J3DShapeMtxType_BBoard:
|
||||
ret = new J3DShapeMtxBBoardImm(mtxInitData.mUseMtxIndex);
|
||||
break;
|
||||
case J3DShapeMtxType_YBBoard:
|
||||
ret = new J3DShapeMtxYBBoardImm(mtxInitData.mUseMtxIndex);
|
||||
break;
|
||||
case J3DShapeMtxType_Multi:
|
||||
ret = new J3DShapeMtxMultiImm(mtxInitData.mUseMtxIndex, mtxInitData.mUseMtxCount, &mpMtxTable[mtxInitData.mFirstUseMtxIndex]);
|
||||
break;
|
||||
default:
|
||||
OSReport("WRONG SHAPE MATRIX TYPE (J3DModelInit.cpp)\n");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case J3DMdlDataFlag_ConcatView:
|
||||
switch (shapeInitData.mShapeMtxType) {
|
||||
case J3DShapeMtxType_Mtx:
|
||||
ret = new J3DShapeMtxConcatView(mtxInitData.mUseMtxIndex);
|
||||
break;
|
||||
case J3DShapeMtxType_BBoard:
|
||||
ret = new J3DShapeMtxBBoardConcatView(mtxInitData.mUseMtxIndex);
|
||||
break;
|
||||
case J3DShapeMtxType_YBBoard:
|
||||
ret = new J3DShapeMtxYBBoardConcatView(mtxInitData.mUseMtxIndex);
|
||||
break;
|
||||
case J3DShapeMtxType_Multi:
|
||||
ret = new J3DShapeMtxMultiConcatView(mtxInitData.mUseMtxIndex, mtxInitData.mUseMtxCount, &mpMtxTable[mtxInitData.mFirstUseMtxIndex]);
|
||||
break;
|
||||
default:
|
||||
OSReport("WRONG SHAPE MATRIX TYPE (J3DModelInit.cpp)\n");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0:
|
||||
default:
|
||||
switch (shapeInitData.mShapeMtxType) {
|
||||
case J3DShapeMtxType_Mtx:
|
||||
case J3DShapeMtxType_BBoard:
|
||||
case J3DShapeMtxType_YBBoard:
|
||||
ret = new J3DShapeMtx(mtxInitData.mUseMtxIndex);
|
||||
break;
|
||||
case J3DShapeMtxType_Multi:
|
||||
ret = new J3DShapeMtxMulti(mtxInitData.mUseMtxIndex, mtxInitData.mUseMtxCount, &mpMtxTable[mtxInitData.mFirstUseMtxIndex]);
|
||||
break;
|
||||
default:
|
||||
OSReport("WRONG SHAPE MATRIX TYPE (J3DModelInit.cpp)\n");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 802FEA40-802FEACC .text newShapeDraw__15J3DShapeFactoryCFii */
|
||||
J3DShapeDraw* J3DShapeFactory::newShapeDraw(int, int) const {
|
||||
/* Nonmatching */
|
||||
J3DShapeDraw* J3DShapeFactory::newShapeDraw(int shapeNo, int mtxGroupNo) const {
|
||||
const J3DShapeInitData& shapeInitData = mpShapeInitData[mpIndexTable[shapeNo]];
|
||||
const J3DShapeDrawInitData& drawInitData = (&mpDrawInitData[shapeInitData.mDrawInitDataIndex])[mtxGroupNo];
|
||||
return new J3DShapeDraw(&mpDisplayListData[drawInitData.mDisplayListIndex], drawInitData.mDisplayListSize);
|
||||
}
|
||||
|
||||
/* 802FEACC-802FEB38 .text allocVcdVatCmdBuffer__15J3DShapeFactoryFUl */
|
||||
void J3DShapeFactory::allocVcdVatCmdBuffer(u32) {
|
||||
/* Nonmatching */
|
||||
void J3DShapeFactory::allocVcdVatCmdBuffer(u32 count) {
|
||||
mpVcdVatCmdBuffer = new (0x20) u8[J3DShape::kVcdVatDLSize * count];
|
||||
for (u32 i = 0; i < (J3DShape::kVcdVatDLSize * count) / 4; i++)
|
||||
((u32*)mpVcdVatCmdBuffer)[i] = 0;
|
||||
}
|
||||
|
||||
/* 802FEB38-802FEBCC .text calcSize__15J3DShapeFactoryFiUl */
|
||||
s32 J3DShapeFactory::calcSize(int, u32) {
|
||||
/* Nonmatching */
|
||||
s32 J3DShapeFactory::calcSize(int shapeNo, u32 flag) {
|
||||
s32 size = 0x68;
|
||||
|
||||
s32 mtxGroupNo = getMtxGroupNum(shapeNo);
|
||||
size += mtxGroupNo * 4;
|
||||
size += mtxGroupNo * 4;
|
||||
|
||||
for (u32 i = 0; i < mtxGroupNo; i++) {
|
||||
s32 shapeMtxSize = calcSizeShapeMtx(flag, shapeNo, i);
|
||||
size += shapeMtxSize;
|
||||
size += 0x0C;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/* 802FEBCC-802FEBDC .text calcSizeVcdVatCmdBuffer__15J3DShapeFactoryFUl */
|
||||
s32 J3DShapeFactory::calcSizeVcdVatCmdBuffer(u32) {
|
||||
/* Nonmatching */
|
||||
s32 J3DShapeFactory::calcSizeVcdVatCmdBuffer(u32 count) {
|
||||
return ALIGN_NEXT(count * J3DShape::kVcdVatDLSize, 0x20);
|
||||
}
|
||||
|
||||
/* 802FEBDC-802FED40 .text calcSizeShapeMtx__15J3DShapeFactoryCFUlii */
|
||||
s32 J3DShapeFactory::calcSizeShapeMtx(u32, int, int) const {
|
||||
/* Nonmatching */
|
||||
s32 J3DShapeFactory::calcSizeShapeMtx(u32 flag, int shapeNo, int mtxGrouNo) const {
|
||||
const J3DShapeInitData& shapeInitData = mpShapeInitData[mpIndexTable[shapeNo]];
|
||||
u32 ret = 0;
|
||||
|
||||
u32 mtxLoadType = getMdlDataFlag_MtxLoadType(flag);
|
||||
switch (mtxLoadType) {
|
||||
case J3DMdlDataFlag_Imm:
|
||||
switch (shapeInitData.mShapeMtxType) {
|
||||
case J3DShapeMtxType_Mtx:
|
||||
ret = 0x08;
|
||||
break;
|
||||
case J3DShapeMtxType_BBoard:
|
||||
ret = 0x08;
|
||||
break;
|
||||
case J3DShapeMtxType_YBBoard:
|
||||
ret = 0x08;
|
||||
break;
|
||||
case J3DShapeMtxType_Multi:
|
||||
ret = 0x10;
|
||||
break;
|
||||
default:
|
||||
OSReport("WRONG SHAPE MATRIX TYPE (J3DModelInit.cpp)\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case J3DMdlDataFlag_ConcatView:
|
||||
switch (shapeInitData.mShapeMtxType) {
|
||||
case J3DShapeMtxType_Mtx:
|
||||
ret = 0x08;
|
||||
break;
|
||||
case J3DShapeMtxType_BBoard:
|
||||
ret = 0x08;
|
||||
break;
|
||||
case J3DShapeMtxType_YBBoard:
|
||||
ret = 0x08;
|
||||
break;
|
||||
case J3DShapeMtxType_Multi:
|
||||
ret = 0x10;
|
||||
break;
|
||||
default:
|
||||
OSReport("WRONG SHAPE MATRIX TYPE (J3DModelInit.cpp)\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case 0:
|
||||
default:
|
||||
switch (shapeInitData.mShapeMtxType) {
|
||||
case J3DShapeMtxType_Mtx:
|
||||
case J3DShapeMtxType_BBoard:
|
||||
case J3DShapeMtxType_YBBoard:
|
||||
ret = 0x08;
|
||||
break;
|
||||
case J3DShapeMtxType_Multi:
|
||||
ret = 0x10;
|
||||
break;
|
||||
default:
|
||||
OSReport("WRONG SHAPE MATRIX TYPE (J3DModelInit.cpp)\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user