mirror of
https://github.com/zeldaret/tww.git
synced 2026-07-07 13:23:27 -04:00
J3DMaterialFactory and J3DMaterialFactory_v21 OK
This commit is contained in:
+2
-2
@@ -1001,8 +1001,8 @@ config.libs = [
|
||||
JSystemLib(
|
||||
"J3DGraphLoader",
|
||||
[
|
||||
Object(NonMatching, "JSystem/J3DGraphLoader/J3DMaterialFactory.cpp"),
|
||||
Object(NonMatching, "JSystem/J3DGraphLoader/J3DMaterialFactory_v21.cpp"),
|
||||
Object(Matching, "JSystem/J3DGraphLoader/J3DMaterialFactory.cpp"),
|
||||
Object(Matching, "JSystem/J3DGraphLoader/J3DMaterialFactory_v21.cpp"),
|
||||
Object(Matching, "JSystem/J3DGraphLoader/J3DClusterLoader.cpp"),
|
||||
Object(Matching, "JSystem/J3DGraphLoader/J3DModelLoader.cpp"),
|
||||
Object(Matching, "JSystem/J3DGraphLoader/J3DModelLoaderCalcSize.cpp"),
|
||||
|
||||
@@ -646,8 +646,8 @@ struct J3DAlphaCompInfo {
|
||||
/* 0x7 */ u8 field_0x7;
|
||||
};
|
||||
|
||||
inline u16 calcAlphaCmpID(u32 comp0, u32 op, u32 comp1) {
|
||||
return (comp0 << 5) + ((op & 0xff) << 3) + (comp1 & 0xff);
|
||||
inline u16 calcAlphaCmpID(u8 comp0, u8 op, u8 comp1) {
|
||||
return (comp0 << 5) + (op << 3) + (comp1);
|
||||
}
|
||||
|
||||
extern u8 j3dAlphaCmpTable[768];
|
||||
@@ -661,7 +661,11 @@ struct J3DAlphaComp {
|
||||
|
||||
J3DAlphaComp(u16 id) : mAlphaCmpID(id), mRef0(0), mRef1(0) {}
|
||||
|
||||
explicit J3DAlphaComp(const J3DAlphaCompInfo& info) { setAlphaCompInfo(info); }
|
||||
explicit J3DAlphaComp(const J3DAlphaCompInfo& info) {
|
||||
mAlphaCmpID = calcAlphaCmpID(info.mComp0, info.mOp, info.mComp1);
|
||||
mRef0 = info.mRef0;
|
||||
mRef1 = info.mRef1;
|
||||
}
|
||||
|
||||
GXCompare getComp0() const { return GXCompare(j3dAlphaCmpTable[mAlphaCmpID * 3]); }
|
||||
GXAlphaOp getOp() const { return GXAlphaOp(j3dAlphaCmpTable[mAlphaCmpID * 3 + 1]); }
|
||||
@@ -933,20 +937,20 @@ public:
|
||||
|
||||
inline u16 calcColorChanID(u16 enable, u8 matSrc, u8 lightMask, u8 diffuseFn, u8 attnFn, u8 ambSrc) {
|
||||
u32 reg = 0;
|
||||
reg = reg & ~0x0002 | enable << 1;
|
||||
reg = reg & ~0x0001 | matSrc;
|
||||
reg = reg & ~0x0040 | ambSrc << 6;
|
||||
reg = reg & ~0x0004 | bool(lightMask & 0x01) << 2;
|
||||
reg = reg & ~0x0008 | bool(lightMask & 0x02) << 3;
|
||||
reg = reg & ~0x0010 | bool(lightMask & 0x04) << 4;
|
||||
reg = reg & ~0x0020 | bool(lightMask & 0x08) << 5;
|
||||
reg = reg & ~0x0800 | bool(lightMask & 0x10) << 11;
|
||||
reg = reg & ~0x1000 | bool(lightMask & 0x20) << 12;
|
||||
reg = reg & ~0x2000 | bool(lightMask & 0x40) << 13;
|
||||
reg = reg & ~0x4000 | bool(lightMask & 0x80) << 14;
|
||||
reg = reg & ~0x0180 | (attnFn == GX_AF_SPEC ? 0 : diffuseFn) << 7;
|
||||
reg = reg & ~0x0200 | (attnFn != GX_AF_NONE) << 9;
|
||||
reg = reg & ~0x0400 | (attnFn != GX_AF_SPEC) << 10;
|
||||
reg = (reg & ~0x0002) | enable << 1;
|
||||
reg = (reg & ~0x0001) | matSrc;
|
||||
reg = (reg & ~0x0040) | ambSrc << 6;
|
||||
reg = (reg & ~0x0004) | bool(lightMask & 0x01) << 2;
|
||||
reg = (reg & ~0x0008) | bool(lightMask & 0x02) << 3;
|
||||
reg = (reg & ~0x0010) | bool(lightMask & 0x04) << 4;
|
||||
reg = (reg & ~0x0020) | bool(lightMask & 0x08) << 5;
|
||||
reg = (reg & ~0x0800) | bool(lightMask & 0x10) << 11;
|
||||
reg = (reg & ~0x1000) | bool(lightMask & 0x20) << 12;
|
||||
reg = (reg & ~0x2000) | bool(lightMask & 0x40) << 13;
|
||||
reg = (reg & ~0x4000) | bool(lightMask & 0x80) << 14;
|
||||
reg = (reg & ~0x0180) | (attnFn == GX_AF_SPEC ? 0 : diffuseFn) << 7;
|
||||
reg = (reg & ~0x0200) | (attnFn != GX_AF_NONE) << 9;
|
||||
reg = (reg & ~0x0400) | (attnFn != GX_AF_SPEC) << 10;
|
||||
return reg;
|
||||
}
|
||||
|
||||
@@ -966,10 +970,9 @@ inline u32 setChanCtrlMacro(u8 enable, GXColorSrc ambSrc, GXColorSrc matSrc, u32
|
||||
struct J3DColorChan {
|
||||
J3DColorChan() { setColorChanInfo(j3dDefaultColorChanInfo); }
|
||||
J3DColorChan(const J3DColorChanInfo& info) {
|
||||
mChanCtrl = calcColorChanID(
|
||||
info.mEnable, info.mMatSrc, info.mLightMask, info.mDiffuseFn, info.mAttnFn,
|
||||
info.mAmbSrc == 0xFF ? 0 : info.mAmbSrc
|
||||
);
|
||||
u32 ambSrc = info.mAmbSrc == 0xFF ? 0 : info.mAmbSrc;
|
||||
mChanCtrl = calcColorChanID(info.mEnable, info.mMatSrc, info.mLightMask,
|
||||
info.mDiffuseFn, info.mAttnFn, ambSrc);
|
||||
}
|
||||
void setColorChanInfo(const J3DColorChanInfo& info) {
|
||||
// Bug: It compares info.mAmbSrc (an 8 bit integer) with 0xFFFF instead of 0xFF.
|
||||
@@ -978,10 +981,9 @@ struct J3DColorChan {
|
||||
// same logic but without the bug.
|
||||
// See J3DMaterialFactory::newColorChan - both the bugged and correct behavior are present there, as it calls
|
||||
// both constructors.
|
||||
mChanCtrl = calcColorChanID(
|
||||
info.mEnable, info.mMatSrc, info.mLightMask, info.mDiffuseFn, info.mAttnFn,
|
||||
info.mAmbSrc == 0xFFFF ? 0 : info.mAmbSrc
|
||||
);
|
||||
u32 ambSrc = info.mAmbSrc == 0xFFFF ? 0 : info.mAmbSrc;
|
||||
mChanCtrl = calcColorChanID(info.mEnable, info.mMatSrc, info.mLightMask,
|
||||
info.mDiffuseFn, info.mAttnFn, ambSrc);
|
||||
}
|
||||
J3DColorChan(u16 id) : mChanCtrl(id) {}
|
||||
GXAttnFn getAttnFn();
|
||||
|
||||
@@ -83,9 +83,9 @@ struct J3DTexCoord : public J3DTexCoordInfo {
|
||||
J3DTexCoord() { *(J3DTexCoordInfo*)this = j3dDefaultTexCoordInfo[0]; }
|
||||
J3DTexCoord(const J3DTexCoordInfo& info) { *(J3DTexCoordInfo*)this = info; }
|
||||
|
||||
u8 getTexGenType() { return mTexGenType; }
|
||||
u8 getTexGenSrc() { return mTexGenSrc; }
|
||||
u32 getTexGenMtx() { return mTexGenMtx & 0xFF; }
|
||||
u8 getTexGenType() const { return mTexGenType; }
|
||||
u8 getTexGenSrc() const { return mTexGenSrc; }
|
||||
u8 getTexGenMtx() const { return mTexGenMtx; }
|
||||
void setTexGenMtx(u8 v) { mTexGenMtx = v; }
|
||||
}; // Size: 0x4
|
||||
|
||||
|
||||
@@ -124,6 +124,12 @@ struct J3DTextureBlock : public JUTDataBlockHeader {
|
||||
/* 0x10 */ void* mpNameTable;
|
||||
};
|
||||
|
||||
static inline u32 getMdlDataFlag_TevStageNum(u32 flags) { return (flags >> 0x10) & 0x1f; }
|
||||
static inline u32 getMdlDataFlag_TexGenFlag(u32 flags) { return flags & 0x0c000000; }
|
||||
static inline u32 getMdlDataFlag_ColorFlag(u32 flags) { return flags & 0xc0000000; }
|
||||
static inline u32 getMdlDataFlag_PEFlag(u32 flags) { return flags & 0x30000000; }
|
||||
static inline u32 getMdlDataFlag_MtxLoadType(u32 flags) { return flags & 0x10; }
|
||||
|
||||
class J3DModelLoaderDataBase {
|
||||
public:
|
||||
static J3DModelData* load(void const*, u32);
|
||||
|
||||
@@ -120,38 +120,29 @@ J3DMaterial* J3DMaterialFactory::create(J3DMaterial* mat, MaterialType type, int
|
||||
return mat;
|
||||
}
|
||||
|
||||
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 */
|
||||
J3DMaterial* J3DMaterialFactory::createNormalMaterial(J3DMaterial* mat, int idx, u32 flag) const {
|
||||
/* Nonmatching - regalloc */
|
||||
J3DMaterial* J3DMaterialFactory::createNormalMaterial(J3DMaterial* mat, int idx, u32 i_flags) const {
|
||||
if (mpDisplayListInit != NULL)
|
||||
return createLockedMaterial(mat, idx, flag);
|
||||
return createLockedMaterial(mat, idx, i_flags);
|
||||
|
||||
u32 stageNum = countStages(idx);
|
||||
u32 tevStageNum = (u32)getMdlDataFlag_TevStageNum(flag);
|
||||
|
||||
if (stageNum > tevStageNum)
|
||||
tevStageNum = stageNum;
|
||||
u32 texNum = tevStageNum > 8 ? 8 : tevStageNum;
|
||||
|
||||
u32 texGenNum = countTexGens(idx);
|
||||
u32 texGenFlag = texGenNum > 4 ? 0 : getMdlDataFlag_TexGenFlag(flag);
|
||||
u32 colorFlag = getMdlDataFlag_ColorFlag(flag);
|
||||
u32 peFlag = getMdlDataFlag_PEFlag(flag);
|
||||
bool indFlag = (flag & 0x01000000);
|
||||
const u32 stages = countStages(idx);
|
||||
u32 tev_stage_num = getMdlDataFlag_TevStageNum(i_flags);
|
||||
u32 tev_stage_num_max = stages > tev_stage_num ? stages : tev_stage_num;
|
||||
u32 tex_num = tev_stage_num_max > 8 ? 8 : tev_stage_num_max;
|
||||
u32 tex_gens = countTexGens(idx);
|
||||
u32 tex_gen_flag = tex_gens > 4 ? getMdlDataFlag_TexGenFlag(0) : getMdlDataFlag_TexGenFlag(i_flags);
|
||||
u32 color_block_flag = getMdlDataFlag_ColorFlag(i_flags);
|
||||
u32 pe_flag = getMdlDataFlag_PEFlag(i_flags);
|
||||
BOOL ind_flag = (i_flags & 0x1000000) ? TRUE : FALSE;
|
||||
|
||||
if (mat == NULL)
|
||||
mat = new J3DMaterial();
|
||||
|
||||
mat->mColorBlock = J3DMaterial::createColorBlock(colorFlag);
|
||||
mat->mTexGenBlock = J3DMaterial::createTexGenBlock(texGenFlag);
|
||||
mat->mTevBlock = J3DMaterial::createTevBlock((u16)tevStageNum);
|
||||
mat->mIndBlock = J3DMaterial::createIndBlock(indFlag);
|
||||
mat->mPEBlock = J3DMaterial::createPEBlock(peFlag, getMaterialMode(idx));
|
||||
mat->mColorBlock = J3DMaterial::createColorBlock(color_block_flag);
|
||||
mat->mTexGenBlock = J3DMaterial::createTexGenBlock(tex_gen_flag);
|
||||
mat->mTevBlock = J3DMaterial::createTevBlock((u16)tev_stage_num_max);
|
||||
mat->mIndBlock = J3DMaterial::createIndBlock(ind_flag);
|
||||
mat->mPEBlock = J3DMaterial::createPEBlock(pe_flag, getMaterialMode(idx));
|
||||
mat->mIndex = idx;
|
||||
mat->mMaterialMode = getMaterialMode(idx);
|
||||
mat->mColorBlock->setColorChanNum(newColorChanNum(idx));
|
||||
@@ -166,11 +157,11 @@ J3DMaterial* J3DMaterialFactory::createNormalMaterial(J3DMaterial* mat, int idx,
|
||||
mat->mPEBlock->setDither(newDither(idx));
|
||||
mat->mTevBlock->setTevStageNum(newTevStageNum(idx));
|
||||
|
||||
for (u8 i = 0; i < texNum; i++)
|
||||
for (u8 i = 0; i < tex_num; i++)
|
||||
mat->mTevBlock->setTexNo(i, newTexNo(idx, i));
|
||||
for (u8 i = 0; i < tevStageNum; i++)
|
||||
for (u8 i = 0; i < tev_stage_num_max; i++)
|
||||
mat->mTevBlock->setTevOrder(i, newTevOrder(idx, i));
|
||||
for (u8 i = 0; i < tevStageNum; i++) {
|
||||
for (u8 i = 0; i < tev_stage_num_max; i++) {
|
||||
J3DMaterialInitData* initData = &mpMaterialInitData[mpMaterialID[idx]];
|
||||
mat->mTevBlock->setTevStage(i, newTevStage(idx, i));
|
||||
if (initData->mTevSwapModeIdx[i] != 0xFFFF) {
|
||||
@@ -192,7 +183,7 @@ J3DMaterial* J3DMaterialFactory::createNormalMaterial(J3DMaterial* mat, int idx,
|
||||
J3DColorChan colorChan = newColorChan(idx, i);
|
||||
mat->mColorBlock->setColorChan(i, colorChan);
|
||||
}
|
||||
for (u8 i = 0; i < texGenNum; i++) {
|
||||
for (u8 i = 0; i < tex_gens; i++) {
|
||||
J3DTexCoord texCoord = newTexCoord(idx, i);
|
||||
mat->mTexGenBlock->setTexCoord(i, &texCoord);
|
||||
}
|
||||
@@ -200,14 +191,14 @@ J3DMaterial* J3DMaterialFactory::createNormalMaterial(J3DMaterial* mat, int idx,
|
||||
mat->mTexGenBlock->setTexMtx(i, newTexMtx(idx, i));
|
||||
}
|
||||
J3DMaterialInitData* initData = &mpMaterialInitData[mpMaterialID[idx]];
|
||||
for (u8 i = 0; i < tevStageNum; i++) {
|
||||
for (u8 i = 0; i < tev_stage_num_max; 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++) {
|
||||
for (u8 i = 0; i < tev_stage_num_max; i++) {
|
||||
if (initData->mTevKAlphaSel[i] != 0xff) {
|
||||
mat->mTevBlock->setTevKAlphaSel(i, initData->mTevKAlphaSel[i]);
|
||||
} else {
|
||||
@@ -223,7 +214,7 @@ J3DMaterial* J3DMaterialFactory::createNormalMaterial(J3DMaterial* mat, int idx,
|
||||
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++)
|
||||
for (u8 i = 0; i < tev_stage_num_max; i++)
|
||||
mat->mTevBlock->setIndTevStage(i, newIndTevStage(idx, i));
|
||||
}
|
||||
return mat;
|
||||
@@ -310,7 +301,6 @@ J3DMaterial* J3DMaterialFactory::createPatchedMaterial(J3DMaterial* mat, int idx
|
||||
|
||||
/* 802F7F98-802F80F8 .text modifyPatchedCurrentMtx__18J3DMaterialFactoryCFP11J3DMateriali */
|
||||
void J3DMaterialFactory::modifyPatchedCurrentMtx(J3DMaterial* mat, int idx) const {
|
||||
/* Nonmatching */
|
||||
J3DTexCoord coord[8];
|
||||
u32 texGenNum = countTexGens(idx);
|
||||
for (u8 i = 0; i < texGenNum; i++)
|
||||
@@ -373,29 +363,26 @@ u32 J3DMaterialFactory::calcSize(J3DMaterial* mat, MaterialType type, int idx, u
|
||||
|
||||
/* 802F8420-802F8554 .text calcSizeNormalMaterial__18J3DMaterialFactoryCFP11J3DMaterialiUl */
|
||||
u32 J3DMaterialFactory::calcSizeNormalMaterial(J3DMaterial* i_material, int i_idx, u32 i_flags) const {
|
||||
/* Nonmatching - regalloc */
|
||||
u32 size = 0;
|
||||
if (mpDisplayListInit != NULL) {
|
||||
return calcSizeLockedMaterial(i_material, i_idx, i_flags);
|
||||
}
|
||||
|
||||
u32 stages = countStages(i_idx);
|
||||
u32 tev_stage_num = (u32)getMdlDataFlag_TevStageNum(i_flags);
|
||||
if (stages > tev_stage_num) {
|
||||
tev_stage_num = stages;
|
||||
}
|
||||
u32 tex_gens = countTexGens(i_flags);
|
||||
u32 tex_gen_flag = tex_gens > 4 ?
|
||||
getMdlDataFlag_TexGenFlag(0) : getMdlDataFlag_TexGenFlag(i_flags);
|
||||
const u32 stages = countStages(i_idx);
|
||||
u32 tev_stage_num = getMdlDataFlag_TevStageNum(i_flags);
|
||||
u32 tev_stage_num_max = stages > tev_stage_num ? stages : tev_stage_num;
|
||||
u32 tex_num = tev_stage_num_max > 8 ? 8 : tev_stage_num_max;
|
||||
u32 tex_gens = countTexGens(i_idx);
|
||||
u32 tex_gen_flag = tex_gens > 4 ? getMdlDataFlag_TexGenFlag(0) : getMdlDataFlag_TexGenFlag(i_flags);
|
||||
u32 color_block_flag = getMdlDataFlag_ColorFlag(i_flags);
|
||||
u32 pe_flag = getMdlDataFlag_PEFlag(i_flags);
|
||||
u32 ind_flag = (i_flags >> 0x18) & 1;
|
||||
BOOL ind_flag = (i_flags & 0x1000000) ? TRUE : FALSE;
|
||||
if (i_material == NULL) {
|
||||
size = sizeof(J3DMaterial);
|
||||
size += sizeof(J3DMaterial);
|
||||
}
|
||||
size += J3DMaterial::calcSizeColorBlock(color_block_flag);
|
||||
size += J3DMaterial::calcSizeTexGenBlock(tex_gen_flag);
|
||||
size += J3DMaterial::calcSizeTevBlock((u16)tev_stage_num);
|
||||
size += J3DMaterial::calcSizeTevBlock((u16)tev_stage_num_max);
|
||||
size += J3DMaterial::calcSizeIndBlock(ind_flag);
|
||||
size += J3DMaterial::calcSizePEBlock(pe_flag, getMaterialMode(i_idx));
|
||||
J3DMaterialInitData* init_data = &mpMaterialInitData[mpMaterialID[i_idx]];
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "JSystem/J3DGraphLoader/J3DMaterialFactory_v21.h"
|
||||
#include "JSystem/J3DGraphLoader/J3DModelLoader.h"
|
||||
#include "JSystem/J3DGraphBase/J3DMatBlock.h"
|
||||
#include "JSystem/JMath/JMath.h"
|
||||
#include "JSystem/JSupport/JSupport.h"
|
||||
|
||||
/* 802F9A88-802F9C68 .text __ct__22J3DMaterialFactory_v21FRC20J3DMaterialBlock_v21 */
|
||||
@@ -78,97 +79,93 @@ u32 J3DMaterialFactory_v21::countStages(int idx) const {
|
||||
}
|
||||
}
|
||||
|
||||
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; }
|
||||
|
||||
/* 802F9D4C-802FA4C0 .text create__22J3DMaterialFactory_v21CFP11J3DMaterialiUl */
|
||||
J3DMaterial* J3DMaterialFactory_v21::create(J3DMaterial* mat, int idx, u32 flag) const {
|
||||
/* Nonmatching - regalloc */
|
||||
|
||||
u32 stageNum = countStages(idx);
|
||||
u32 tevStageNum = (u32)getMdlDataFlag_TevStageNum(flag);
|
||||
|
||||
if (stageNum > tevStageNum)
|
||||
tevStageNum = stageNum;
|
||||
u32 texNum = tevStageNum > 8 ? 8 : tevStageNum;
|
||||
|
||||
u32 texGenNum = countTexGens(idx);
|
||||
u32 texGenFlag = texGenNum > 4 ? 0 : getMdlDataFlag_TexGenFlag(flag);
|
||||
u32 colorFlag = getMdlDataFlag_ColorFlag(flag);
|
||||
u32 peFlag = getMdlDataFlag_PEFlag(flag);
|
||||
bool indFlag = (flag & 0x01000000);
|
||||
|
||||
if (mat == NULL)
|
||||
mat = new J3DMaterial();
|
||||
|
||||
mat->mColorBlock = J3DMaterial::createColorBlock(colorFlag);
|
||||
mat->mTexGenBlock = J3DMaterial::createTexGenBlock(texGenFlag);
|
||||
mat->mTevBlock = J3DMaterial::createTevBlock((u16)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 < texNum; 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_v21* 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);
|
||||
J3DMaterial* J3DMaterialFactory_v21::create(J3DMaterial* i_material, int i_idx, u32 i_flags) const {
|
||||
u32 stages = countStages(i_idx);
|
||||
u32 tev_stage_num = getMdlDataFlag_TevStageNum(i_flags);
|
||||
u32 tev_stage_num_max = stages > tev_stage_num ? stages : tev_stage_num;
|
||||
u32 tex_num = tev_stage_num_max > 8 ? 8 : tev_stage_num_max;
|
||||
u32 texgens = countTexGens(i_idx);
|
||||
u32 texgen_flag = texgens > 4 ? getMdlDataFlag_TexGenFlag(0) : getMdlDataFlag_TexGenFlag(i_flags);
|
||||
u32 color_flag = getMdlDataFlag_ColorFlag(i_flags);
|
||||
u32 pe_flag = getMdlDataFlag_PEFlag(i_flags);
|
||||
BOOL ind_flag = (i_flags & 0x1000000) ? TRUE : FALSE;
|
||||
if (i_material == NULL) {
|
||||
i_material = new J3DMaterial();
|
||||
}
|
||||
i_material->mColorBlock = J3DMaterial::createColorBlock(color_flag);
|
||||
i_material->mTexGenBlock = J3DMaterial::createTexGenBlock(texgen_flag);
|
||||
i_material->mTevBlock = J3DMaterial::createTevBlock((u16)tev_stage_num_max);
|
||||
i_material->mIndBlock = J3DMaterial::createIndBlock(ind_flag);
|
||||
i_material->mPEBlock = J3DMaterial::createPEBlock(pe_flag, getMaterialMode(i_idx));
|
||||
i_material->mIndex = i_idx;
|
||||
i_material->mMaterialMode = getMaterialMode(i_idx);
|
||||
i_material->mColorBlock->setColorChanNum(newColorChanNum(i_idx));
|
||||
i_material->mColorBlock->setCullMode(newCullMode(i_idx));
|
||||
i_material->mTexGenBlock->setTexGenNum(newTexGenNum(i_idx));
|
||||
i_material->mTexGenBlock->setNBTScale(newNBTScale(i_idx));
|
||||
i_material->mPEBlock->setFog(newFog(i_idx));
|
||||
i_material->mPEBlock->setAlphaComp(newAlphaComp(i_idx));
|
||||
i_material->mPEBlock->setBlend(newBlend(i_idx));
|
||||
i_material->mPEBlock->setZMode(newZMode(i_idx));
|
||||
i_material->mPEBlock->setZCompLoc(newZCompLoc(i_idx));
|
||||
i_material->mPEBlock->setDither(newDither(i_idx));
|
||||
i_material->mTevBlock->setTevStageNum(newTevStageNum(i_idx));
|
||||
for (u8 i = 0; i < tex_num; i++) {
|
||||
i_material->mTevBlock->setTexNo(i, newTexNo(i_idx, i));
|
||||
}
|
||||
for (u8 i = 0; i < tev_stage_num_max; i++) {
|
||||
i_material->mTevBlock->setTevOrder(i, newTevOrder(i_idx, i));
|
||||
}
|
||||
for (u8 i = 0; i < tev_stage_num_max; i++) {
|
||||
J3DMaterialInitData_v21* material_init_data = &mpMaterialInitData[mpMaterialID[i_idx]];
|
||||
i_material->mTevBlock->setTevStage(i, newTevStage(i_idx, i));
|
||||
if (material_init_data->mTevSwapModeIdx[i] != 0xffff) {
|
||||
i_material->mTevBlock->getTevStage(i)->setTexSel(
|
||||
mpTevSwapModeInfo[material_init_data->mTevSwapModeIdx[i]].mTexSel);
|
||||
i_material->mTevBlock->getTevStage(i)->setRasSel(
|
||||
mpTevSwapModeInfo[material_init_data->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->setMatColor(i, newMatColor(idx, i));
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
J3DColorChan colorChan = newColorChan(idx, i);
|
||||
mat->mColorBlock->setColorChan(i, colorChan);
|
||||
i_material->mTevBlock->setTevKColor(i, newTevKColor(i_idx, i));
|
||||
}
|
||||
for (u8 i = 0; i < texGenNum; i++) {
|
||||
J3DTexCoord texCoord = newTexCoord(idx, i);
|
||||
mat->mTexGenBlock->setTexCoord(i, &texCoord);
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
i_material->mTevBlock->setTevColor(i, newTevColor(i_idx, i));
|
||||
}
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
i_material->mTevBlock->setTevSwapModeTable(i, newTevSwapModeTable(i_idx, i));
|
||||
}
|
||||
for (u8 i = 0; i < 2; i++) {
|
||||
i_material->mColorBlock->setMatColor(i, newMatColor(i_idx, i));
|
||||
}
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
J3DColorChan color_chan = newColorChan(i_idx, i);
|
||||
i_material->mColorBlock->setColorChan(i, color_chan);
|
||||
}
|
||||
for (u8 i = 0; i < texgens; i++) {
|
||||
J3DTexCoord tex_coord = newTexCoord(i_idx, i);
|
||||
i_material->mTexGenBlock->setTexCoord(i, &tex_coord);
|
||||
}
|
||||
for (u8 i = 0; i < 8; i++) {
|
||||
mat->mTexGenBlock->setTexMtx(i, newTexMtx(idx, i));
|
||||
i_material->mTexGenBlock->setTexMtx(i, newTexMtx(i_idx, i));
|
||||
}
|
||||
J3DMaterialInitData_v21* initData = &mpMaterialInitData[mpMaterialID[idx]];
|
||||
for (u8 i = 0; i < tevStageNum; i++) {
|
||||
if (initData->mTevKColorSel[i] != 0xff) {
|
||||
mat->mTevBlock->setTevKColorSel(i, initData->mTevKColorSel[i]);
|
||||
J3DMaterialInitData_v21* material_init_data = &mpMaterialInitData[mpMaterialID[i_idx]];
|
||||
for (u8 i = 0; i < tev_stage_num_max; i++) {
|
||||
if (material_init_data->mTevKColorSel[i] != 0xff) {
|
||||
i_material->mTevBlock->setTevKColorSel(i, material_init_data->mTevKColorSel[i]);
|
||||
} else {
|
||||
mat->mTevBlock->setTevKColorSel(i, 0xc);
|
||||
i_material->mTevBlock->setTevKColorSel(i, 0xc);
|
||||
}
|
||||
}
|
||||
for (u8 i = 0; i < tevStageNum; i++) {
|
||||
if (initData->mTevKAlphaSel[i] != 0xff) {
|
||||
mat->mTevBlock->setTevKAlphaSel(i, initData->mTevKAlphaSel[i]);
|
||||
for (u8 i = 0; i < tev_stage_num_max; i++) {
|
||||
if (material_init_data->mTevKAlphaSel[i] != 0xff) {
|
||||
i_material->mTevBlock->setTevKAlphaSel(i, material_init_data->mTevKAlphaSel[i]);
|
||||
} else {
|
||||
mat->mTevBlock->setTevKAlphaSel(i, 0x1c);
|
||||
i_material->mTevBlock->setTevKAlphaSel(i, 0x1c);
|
||||
}
|
||||
}
|
||||
return mat;
|
||||
return i_material;
|
||||
}
|
||||
|
||||
/* 802FA4C0-802FA550 .text newMatColor__22J3DMaterialFactory_v21CFii */
|
||||
|
||||
Reference in New Issue
Block a user