mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-25 05:58:42 -04:00
Reorganize library code into libs/ (#3119)
* Reorganize files into libs/{dolphin,JSystem,PowerPC_EABI_Support,revolution,TRK_MINNOW_DOLPHIN}
* Update configure.py and project.py for new libs structure
* Refactor `#include <dolphin/x.h>` -> `<x.h>`
* Remove `__REVOLUTION_SDK__` forwards from dolphin
* Fix dolphin/ references in revolution
* Wrap `#include <dolphin.h>` in `!__REVOLUTION_SDK__`
* Always build TRK against dolphin headers
* Resolve revolution SDK header resolution issues
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
#ifndef J3DDRAWBUFFER_H
|
||||
#define J3DDRAWBUFFER_H
|
||||
|
||||
#include "JSystem/J3DGraphBase/J3DSys.h"
|
||||
|
||||
// matches debug
|
||||
inline f32 J3DCalcZValue(__REGISTER MtxP m, __REGISTER Vec v) {
|
||||
#ifdef __MWERKS__
|
||||
__REGISTER f32 temp_f4;
|
||||
__REGISTER f32 out;
|
||||
__REGISTER f32 temp_f0;
|
||||
__REGISTER f32 temp_f2;
|
||||
__REGISTER f32 temp_f1 = 1.0f;
|
||||
|
||||
// clang-format off
|
||||
asm {
|
||||
psq_l temp_f0, 0(v), 0, 0 /* qr0 */
|
||||
lfs temp_f2, 8(v)
|
||||
psq_l temp_f4, 32(m), 0, 0 /* qr0 */
|
||||
psq_l out, 40(m), 0, 0 /* qr0 */
|
||||
ps_merge00 temp_f2, temp_f2, temp_f1
|
||||
ps_mul temp_f4, temp_f0, temp_f4
|
||||
ps_madd out, temp_f2, out, temp_f4
|
||||
ps_sum0 out, out, out, out
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
return out;
|
||||
#endif
|
||||
}
|
||||
|
||||
class J3DDrawBuffer;
|
||||
class J3DPacket;
|
||||
class J3DDrawPacket;
|
||||
class J3DMatPacket;
|
||||
class J3DShapePacket;
|
||||
|
||||
enum J3DDrawBufDrawMode {
|
||||
J3DDrawBufDrawMode_Head,
|
||||
J3DDrawBufDrawMode_Tail,
|
||||
|
||||
J3DDrawBufDrawMode_MAX,
|
||||
};
|
||||
|
||||
enum J3DDrawBufSortMode {
|
||||
J3DDrawBufSortMode_Mat,
|
||||
J3DDrawBufSortMode_MatAnm,
|
||||
J3DDrawBufSortMode_Z,
|
||||
J3DDrawBufSortMode_Model,
|
||||
J3DDrawBufSortMode_Invalid,
|
||||
J3DDrawBufSortMode_Non,
|
||||
|
||||
J3DDrawBufSortMode_MAX,
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DDrawBuffer {
|
||||
public:
|
||||
typedef int (J3DDrawBuffer::*sortFunc)(J3DMatPacket*);
|
||||
typedef void (J3DDrawBuffer::*drawFunc)() const;
|
||||
|
||||
J3DDrawBuffer() { initialize(); }
|
||||
~J3DDrawBuffer();
|
||||
void initialize();
|
||||
int allocBuffer(u32);
|
||||
void frameInit();
|
||||
int entryMatSort(J3DMatPacket*);
|
||||
int entryMatAnmSort(J3DMatPacket*);
|
||||
int entryZSort(J3DMatPacket*);
|
||||
int entryModelSort(J3DMatPacket*);
|
||||
int entryInvalidSort(J3DMatPacket*);
|
||||
int entryNonSort(J3DMatPacket*);
|
||||
int entryImm(J3DPacket* pPacket, u16 index);
|
||||
void draw() const;
|
||||
void drawHead() const;
|
||||
void drawTail() const;
|
||||
|
||||
u32 getEntryTableSize() { return mEntryTableSize; }
|
||||
int getSortMode() { return mSortMode; }
|
||||
|
||||
inline void calcZRatio();
|
||||
void setNonSort() { mSortMode = J3DDrawBufSortMode_Non; }
|
||||
void setZSort() { mSortMode = J3DDrawBufSortMode_Z; }
|
||||
void setZMtx(MtxP mtx) { mpZMtx = mtx; }
|
||||
|
||||
public:
|
||||
/* 0x00 */ J3DPacket** mpBuffer;
|
||||
/* 0x04 */ u32 mEntryTableSize;
|
||||
/* 0x08 */ u32 mDrawMode;
|
||||
/* 0x0C */ u32 mSortMode;
|
||||
/* 0x10 */ f32 mZNear;
|
||||
/* 0x14 */ f32 mZFar;
|
||||
/* 0x18 */ f32 mZRatio;
|
||||
/* 0x1C */ MtxP mpZMtx;
|
||||
/* 0x20 */ J3DPacket* mpCallBackPacket;
|
||||
|
||||
static sortFunc sortFuncTable[6];
|
||||
static drawFunc drawFuncTable[2];
|
||||
static int entryNum;
|
||||
};
|
||||
|
||||
#endif /* J3DDRAWBUFFER_H */
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef J3DENUM_H
|
||||
#define J3DENUM_H
|
||||
|
||||
enum J3DError {
|
||||
kJ3DError_Success = 0,
|
||||
kJ3DError_Alloc = 4,
|
||||
};
|
||||
|
||||
#endif /* J3DENUM_H */
|
||||
@@ -0,0 +1,67 @@
|
||||
#ifndef J3DFIFO_H
|
||||
#define J3DFIFO_H
|
||||
|
||||
#include <gx.h>
|
||||
#include <gd.h>
|
||||
|
||||
inline void J3DFifoLoadBPCmd(u32 regval) {
|
||||
GXCmd1u8(GX_LOAD_BP_REG);
|
||||
GXCmd1u32(regval);
|
||||
}
|
||||
|
||||
inline void J3DFifoWriteXFCmdHdr(u16 addr, u8 len) {
|
||||
GXCmd1u8(GX_LOAD_XF_REG);
|
||||
GXCmd1u16(len - 1);
|
||||
GXCmd1u16(addr);
|
||||
}
|
||||
|
||||
inline void J3DFifoLoadIndx(u8 cmd, u16 indx, u16 addr) {
|
||||
GXWGFifo.u8 = cmd;
|
||||
GXWGFifo.u16 = indx;
|
||||
GXWGFifo.u16 = addr;
|
||||
}
|
||||
|
||||
inline void J3DFifoWriteCPCmd(u8 cmd, u32 param) {
|
||||
GXWGFifo.u8 = GX_LOAD_CP_REG;
|
||||
GXWGFifo.u8 = cmd;
|
||||
GXWGFifo.u32 = param;
|
||||
}
|
||||
|
||||
inline void J3DFifoLoadCPCmd(u8 reg, u32 value) {
|
||||
GXCmd1u8(GX_LOAD_CP_REG);
|
||||
GXCmd1u8(reg);
|
||||
GXCmd1u32(value);
|
||||
}
|
||||
|
||||
inline void J3DFifoWriteXFCmd(u16 cmd, u16 len) {
|
||||
GXWGFifo.u8 = GX_LOAD_XF_REG;
|
||||
GXWGFifo.u16 = (len - 1);
|
||||
GXWGFifo.u16 = cmd;
|
||||
}
|
||||
|
||||
inline void J3DFifoLoadXFCmdHdr(u16 addr, u8 len) {
|
||||
GXCmd1u8(GX_LOAD_XF_REG);
|
||||
GXCmd1u16(len - 1);
|
||||
GXCmd1u16(addr);
|
||||
}
|
||||
|
||||
inline void J3DFifoLoadPosMtxIndx(u16 index, u32 addr) {
|
||||
GXCmd1u8(GX_LOAD_INDX_A);
|
||||
GXCmd1u16(index);
|
||||
GXCmd1u16(((sizeof(Vec) - 1) << 12) | (u16)(addr * 4));
|
||||
}
|
||||
|
||||
inline void J3DFifoLoadNrmMtxIndx3x3(u16 index, u32 addr) {
|
||||
GXCmd1u8(GX_LOAD_INDX_B);
|
||||
GXCmd1u16(index);
|
||||
GXCmd1u16(((9 - 1) << 12) | (u16)((addr * 3) + 0x400));
|
||||
}
|
||||
|
||||
void J3DFifoLoadPosMtxImm(f32 (*)[4], u32);
|
||||
void J3DFifoLoadNrmMtxImm(f32 (*)[4], u32);
|
||||
void J3DFifoLoadNrmMtxImm3x3(f32 (*)[3], u32);
|
||||
void J3DFifoLoadNrmMtxToTexMtx(f32 (*)[4], u32);
|
||||
void J3DFifoLoadNrmMtxToTexMtx3x3(f32 (*)[3], u32);
|
||||
void J3DFifoLoadTexCached(GXTexMapID, u32, GXTexCacheSize, u32, GXTexCacheSize);
|
||||
|
||||
#endif /* J3DFIFO_H */
|
||||
@@ -0,0 +1,149 @@
|
||||
#ifndef J3DGD_H
|
||||
#define J3DGD_H
|
||||
|
||||
#include <gx.h>
|
||||
#include <gd.h>
|
||||
|
||||
inline void J3DGDWrite_u8(u8 data) {
|
||||
__GDWrite(data);
|
||||
}
|
||||
|
||||
inline void J3DGDWrite_u16(u16 data) {
|
||||
__GDWrite((u8)((data >> 8)));
|
||||
__GDWrite((u8)((data >> 0) & 0xFF));
|
||||
}
|
||||
|
||||
inline void J3DGDWrite_u32(u32 data) {
|
||||
__GDWrite((u8)((data >> 24) & 0xFF));
|
||||
__GDWrite((u8)((data >> 16) & 0xFF));
|
||||
__GDWrite((u8)((data >> 8) & 0xFF));
|
||||
__GDWrite((u8)((data >> 0) & 0xFF));
|
||||
}
|
||||
|
||||
inline void J3DGDWrite_f32(f32 data) {
|
||||
union {
|
||||
f32 f;
|
||||
u32 u;
|
||||
} fid;
|
||||
fid.f = data;
|
||||
J3DGDWrite_u32(fid.u);
|
||||
}
|
||||
|
||||
inline void J3DGDWriteBPCmd(u32 regval) {
|
||||
J3DGDWrite_u8(GX_LOAD_BP_REG);
|
||||
J3DGDWrite_u32(regval);
|
||||
}
|
||||
|
||||
inline void J3DGDWriteXFCmd(u16 addr, u32 val) {
|
||||
J3DGDWrite_u8(GX_LOAD_XF_REG);
|
||||
J3DGDWrite_u16(0);
|
||||
J3DGDWrite_u16(addr);
|
||||
J3DGDWrite_u32(val);
|
||||
}
|
||||
|
||||
inline void J3DGDWriteXFCmdHdr(u16 addr, u8 len) {
|
||||
J3DGDWrite_u8(GX_LOAD_XF_REG);
|
||||
J3DGDWrite_u16(len - 1);
|
||||
J3DGDWrite_u16(addr);
|
||||
}
|
||||
|
||||
inline void J3DGXCmd1f32ptr(f32* data) {
|
||||
GXCmd1u32(*(u32*)data);
|
||||
}
|
||||
|
||||
inline void J3DGXCmd1f32(f32 data) {
|
||||
union {
|
||||
f32 f;
|
||||
u32 u;
|
||||
} fid;
|
||||
fid.f = data;
|
||||
GXCmd1u32(fid.u);
|
||||
}
|
||||
|
||||
inline void J3DGDWriteCPCmd(u8 reg, u32 value) {
|
||||
J3DGDWrite_u8(8);
|
||||
J3DGDWrite_u8(reg);
|
||||
J3DGDWrite_u32(value);
|
||||
}
|
||||
|
||||
void J3DGDSetGenMode(u8 texGenNum, u8 colorChanNum, u8 tevStageNum, u8 IndTexStageNum,
|
||||
GXCullMode cullMode);
|
||||
void J3DGDSetGenMode_3Param(u8 texGenNum, u8 tevStageNum, u8 indTexStageNum);
|
||||
void J3DGDSetLightAttn(GXLightID, f32, f32, f32, f32, f32, f32);
|
||||
void J3DGDSetLightColor(GXLightID, GXColor);
|
||||
void J3DGDSetLightPos(GXLightID, f32, f32, f32);
|
||||
void J3DGDSetLightDir(GXLightID, f32, f32, f32);
|
||||
void J3DGDSetVtxAttrFmtv(GXVtxFmt, GXVtxAttrFmtList const*, bool);
|
||||
void J3DGDSetTexCoordGen(GXTexGenType, GXTexGenSrc);
|
||||
void J3DGDSetTexCoordScale2(GXTexCoordID, u16, u8, u8, u16, u8, u8);
|
||||
void J3DGDSetTexLookupMode(GXTexMapID, GXTexWrapMode, GXTexWrapMode, GXTexFilter, GXTexFilter, f32,
|
||||
f32, f32, u8, u8, GXAnisotropy);
|
||||
void J3DGDSetTexImgAttr(GXTexMapID, u16, u16, GXTexFmt);
|
||||
void J3DGDSetTexImgPtr(GXTexMapID, void*);
|
||||
void J3DGDSetTexImgPtrRaw(GXTexMapID, u32);
|
||||
void J3DGDSetTexTlut(GXTexMapID, u32, _GXTlutFmt);
|
||||
void J3DGDLoadTlut(void*, u32, _GXTlutSize);
|
||||
void J3DGDSetIndTexMtx(GXIndTexMtxID, f32 (*)[3], s8);
|
||||
void J3DGDSetIndTexCoordScale(GXIndTexStageID, GXIndTexScale, GXIndTexScale, GXIndTexScale,
|
||||
GXIndTexScale);
|
||||
void J3DGDSetIndTexOrder(u32, GXTexCoordID, GXTexMapID, GXTexCoordID, GXTexMapID, GXTexCoordID,
|
||||
GXTexMapID, GXTexCoordID, GXTexMapID);
|
||||
void J3DGDSetTevOrder(GXTevStageID, GXTexCoordID, GXTexMapID, GXChannelID, GXTexCoordID, GXTexMapID,
|
||||
GXChannelID);
|
||||
void J3DGDSetTevKColor(GXTevKColorID, GXColor);
|
||||
void J3DGDSetTevColorS10(GXTevRegID, GXColorS10);
|
||||
void J3DGDSetFog(GXFogType, f32, f32, f32, f32, GXColor);
|
||||
void J3DGDSetFogRangeAdj(u8, u16, _GXFogAdjTable*);
|
||||
|
||||
inline void J3DGDSetNumChans(u8 numChans) {
|
||||
J3DGDWriteXFCmd(0x1009, numChans);
|
||||
}
|
||||
|
||||
inline void J3DGDSetNumTexGens(u8 numTexGens) {
|
||||
J3DGDWriteXFCmd(0x103f, numTexGens);
|
||||
}
|
||||
|
||||
inline void J3DGDSetTevKonstantSel_SwapModeTable(GXTevStageID stage, GXTevKColorSel colorSel1, GXTevKAlphaSel alphaSel1, GXTevKColorSel colorSel2, GXTevKAlphaSel alphaSel2, GXTevColorChan chan1, GXTevColorChan chan2) {
|
||||
J3DGDWriteBPCmd((stage / 2 + 0xf6) << 24 | (chan1 | chan2 << 2 | colorSel1 << 4 | alphaSel1 << 9 | colorSel2 << 14 | alphaSel2 << 19) & 0x00FFFFFF);
|
||||
}
|
||||
|
||||
inline void J3DGDSetAlphaCompare(GXCompare cmp0, u8 ref0, GXAlphaOp op, GXCompare cmp1, u8 ref1) {
|
||||
J3DGDWriteBPCmd(ref0 | ref1 << 8 | cmp0 << 16 | cmp1 << 19 | op << 22 | 0xF3 << 24);
|
||||
}
|
||||
|
||||
inline void J3DGDSetBlendMode(GXBlendMode mode, GXBlendFactor srcFactor, GXBlendFactor dstFactor, GXLogicOp logicOp) {
|
||||
J3DGDWriteBPCmd(0xFE00FFE3);
|
||||
J3DGDWriteBPCmd(
|
||||
(mode == GX_BM_BLEND || mode == GX_BM_SUBTRACT) << 0 |
|
||||
(mode == GX_BM_LOGIC) << 1 |
|
||||
dstFactor << 5 |
|
||||
srcFactor << 8 |
|
||||
(mode == GX_BM_SUBTRACT) << 11 |
|
||||
logicOp << 12 |
|
||||
0x41 << 24);
|
||||
}
|
||||
|
||||
inline void J3DGDSetBlendMode(GXBlendMode mode, GXBlendFactor srcFactor, GXBlendFactor dstFactor, GXLogicOp logicOp, u8 ditherEnable) {
|
||||
J3DGDWriteBPCmd(0xFE00FFE7);
|
||||
J3DGDWriteBPCmd(
|
||||
u32(mode == GX_BM_BLEND || mode == GX_BM_SUBTRACT) << 0 |
|
||||
(mode == GX_BM_LOGIC) << 1 |
|
||||
ditherEnable << 2 |
|
||||
dstFactor << 5 |
|
||||
srcFactor << 8 |
|
||||
(mode == GX_BM_SUBTRACT) << 11 |
|
||||
logicOp << 12 |
|
||||
0x41 << 24);
|
||||
}
|
||||
|
||||
inline void J3DGDSetZMode(u8 compareEnable, GXCompare func, u8 writeEnable) {
|
||||
J3DGDWriteBPCmd(compareEnable | func << 1 | writeEnable << 4 | 0x40 << 24);
|
||||
}
|
||||
|
||||
inline void J3DGDSetZCompLoc(u32 compLocEnable) {
|
||||
J3DGDWriteBPCmd(0xFE000040);
|
||||
J3DGDWriteBPCmd(compLocEnable << 6 | 0x43 << 24);
|
||||
}
|
||||
|
||||
|
||||
#endif /* J3DGD_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,163 @@
|
||||
#ifndef J3DMATERIAL_H
|
||||
#define J3DMATERIAL_H
|
||||
|
||||
#include "JSystem/J3DGraphBase/J3DMatBlock.h"
|
||||
#include "JSystem/J3DGraphBase/J3DPacket.h"
|
||||
#include "JSystem/J3DGraphBase/J3DShape.h"
|
||||
#include <stdint.h>
|
||||
|
||||
class J3DJoint;
|
||||
class J3DMaterialAnm;
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DMaterial {
|
||||
public:
|
||||
static J3DColorBlock* createColorBlock(u32);
|
||||
static J3DTexGenBlock* createTexGenBlock(u32);
|
||||
static J3DTevBlock* createTevBlock(int);
|
||||
static J3DIndBlock* createIndBlock(int);
|
||||
static J3DPEBlock* createPEBlock(u32, u32);
|
||||
static u32 calcSizeColorBlock(u32);
|
||||
static u32 calcSizeTexGenBlock(u32);
|
||||
static u32 calcSizeTevBlock(int);
|
||||
static u32 calcSizeIndBlock(int);
|
||||
static u32 calcSizePEBlock(u32, u32);
|
||||
void initialize();
|
||||
u32 countDLSize();
|
||||
void makeDisplayList_private(J3DDisplayListObj*);
|
||||
void setCurrentMtx();
|
||||
void calcCurrentMtx();
|
||||
void copy(J3DMaterial*);
|
||||
s32 newSharedDisplayList(u32);
|
||||
s32 newSingleSharedDisplayList(u32);
|
||||
|
||||
virtual void calc(f32 const (*)[4]);
|
||||
virtual void calcDiffTexMtx(f32 const (*)[4]);
|
||||
virtual void makeDisplayList();
|
||||
virtual void makeSharedDisplayList();
|
||||
virtual void load();
|
||||
virtual void loadSharedDL();
|
||||
virtual void patch();
|
||||
virtual void diff(u32);
|
||||
virtual void reset();
|
||||
virtual void change();
|
||||
|
||||
J3DMaterial() { initialize(); }
|
||||
~J3DMaterial() {}
|
||||
J3DMaterial* getNext() { return mNext; }
|
||||
J3DShape* getShape() { return mShape; }
|
||||
J3DTevBlock* getTevBlock() { return mTevBlock; }
|
||||
J3DColorBlock* getColorBlock() { return mColorBlock; }
|
||||
J3DTexGenBlock* getTexGenBlock() { return mTexGenBlock; }
|
||||
J3DDisplayListObj* getSharedDisplayListObj() { return mSharedDLObj; }
|
||||
J3DIndBlock* getIndBlock() { return mIndBlock; }
|
||||
J3DJoint* getJoint() { return mJoint; }
|
||||
J3DMaterialAnm* getMaterialAnm() {
|
||||
return (uintptr_t)mMaterialAnm < 0xC0000000 ? mMaterialAnm : NULL;
|
||||
}
|
||||
u32 getMaterialMode() { return mMaterialMode; }
|
||||
J3DNBTScale* getNBTScale() { return mTexGenBlock->getNBTScale(); }
|
||||
u16 getTexNo(u32 idx) { return mTevBlock->getTexNo(idx); }
|
||||
J3DGXColor* getTevKColor(u32 param_0) { return mTevBlock->getTevKColor(param_0); }
|
||||
J3DGXColorS10* getTevColor(u32 param_0) { return mTevBlock->getTevColor(param_0); }
|
||||
J3DFog* getFog() { return mPEBlock->getFog(); }
|
||||
J3DTexMtx* getTexMtx(u32 idx) { return mTexGenBlock->getTexMtx(idx); }
|
||||
u16 getIndex() { return mIndex; }
|
||||
BOOL isDrawModeOpaTexEdge() { return (mMaterialMode & 3) ? 1 : 0; }
|
||||
J3DPEBlock* getPEBlock() { return mPEBlock; }
|
||||
void onInvalid() { mInvalid = 1; }
|
||||
u32 getInvalid() { return mInvalid; }
|
||||
u32 getTexGenNum() const { return mTexGenBlock->getTexGenNum(); }
|
||||
u8 getTevStageNum() const { return mTevBlock->getTevStageNum(); }
|
||||
J3DTexCoord* getTexCoord(u32 idx) { return mTexGenBlock->getTexCoord(idx); }
|
||||
J3DZMode* getZMode() { return mPEBlock->getZMode(); }
|
||||
J3DBlend* getBlend() { return mPEBlock->getBlend(); }
|
||||
J3DColorChan* getColorChan(u32 idx) { return mColorBlock->getColorChan(idx); }
|
||||
J3DGXColor* getMatColor(u32 i) { return mColorBlock->getMatColor(i); }
|
||||
|
||||
void setTevColor(u32 i, const J3DGXColorS10* i_color) { mTevBlock->setTevColor(i, i_color); }
|
||||
void setTevKColor(u32 i, const J3DGXColor* i_color) { mTevBlock->setTevKColor(i, i_color); }
|
||||
void setAmbColor(u32 i, const J3DGXColor* i_color) { mColorBlock->setAmbColor(i, i_color); }
|
||||
void setLight(u32 i, J3DLightObj* i_lightobj) { mColorBlock->setLight(i, i_lightobj); }
|
||||
void setMaterialAnm(J3DMaterialAnm* i_anm) { mMaterialAnm = i_anm; }
|
||||
void setCullMode(u8 i_mode) { mColorBlock->setCullMode(i_mode); }
|
||||
void setTexMtx(u32 idx, J3DTexMtx* mtx) { mTexGenBlock->setTexMtx(idx, mtx); }
|
||||
void setZCompLoc(u8 i_comploc) { mPEBlock->setZCompLoc(i_comploc); }
|
||||
void setMaterialMode(u32 i_mode) { mMaterialMode = i_mode; }
|
||||
|
||||
void addShape(J3DShape* pShape) {
|
||||
J3D_ASSERT_NULLPTR(618, pShape != NULL);
|
||||
mShape = pShape;
|
||||
}
|
||||
|
||||
void setNext(J3DMaterial* pMaterial) {
|
||||
J3D_ASSERT_NULLPTR(623, pMaterial != NULL);
|
||||
mNext = pMaterial;
|
||||
}
|
||||
|
||||
void setJoint(J3DJoint* pJoint) {
|
||||
J3D_ASSERT_NULLPTR(628, pJoint != NULL);
|
||||
mJoint = pJoint;
|
||||
}
|
||||
|
||||
public:
|
||||
/* 0x04 */ J3DMaterial* mNext;
|
||||
/* 0x08 */ J3DShape* mShape;
|
||||
/* 0x0C */ J3DJoint* mJoint;
|
||||
/* 0x10 */ u32 mMaterialMode;
|
||||
/* 0x14 */ u16 mIndex;
|
||||
/* 0x18 */ u32 mInvalid;
|
||||
/* 0x1C */ u32 field_0x1c;
|
||||
/* 0x20 */ u32 mDiffFlag;
|
||||
/* 0x24 */ J3DColorBlock* mColorBlock;
|
||||
/* 0x28 */ J3DTexGenBlock* mTexGenBlock;
|
||||
/* 0x2C */ J3DTevBlock* mTevBlock;
|
||||
/* 0x30 */ J3DIndBlock* mIndBlock;
|
||||
/* 0x34 */ J3DPEBlock* mPEBlock;
|
||||
/* 0x38 */ J3DMaterial* mpOrigMaterial;
|
||||
/* 0x3C */ J3DMaterialAnm* mMaterialAnm;
|
||||
/* 0x40 */ J3DCurrentMtx mCurrentMtx;
|
||||
/* 0x48 */ J3DDisplayListObj* mSharedDLObj;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DPatchedMaterial : public J3DMaterial {
|
||||
public:
|
||||
J3DPatchedMaterial() { initialize(); }
|
||||
void initialize();
|
||||
|
||||
virtual void makeDisplayList();
|
||||
virtual void makeSharedDisplayList();
|
||||
virtual void load();
|
||||
virtual void loadSharedDL();
|
||||
virtual void reset();
|
||||
virtual void change();
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DLockedMaterial : public J3DMaterial {
|
||||
public:
|
||||
J3DLockedMaterial() { initialize(); }
|
||||
void initialize();
|
||||
|
||||
virtual void calc(f32 const (*)[4]);
|
||||
virtual void makeDisplayList();
|
||||
virtual void makeSharedDisplayList();
|
||||
virtual void load();
|
||||
virtual void loadSharedDL();
|
||||
virtual void patch();
|
||||
virtual void diff(u32);
|
||||
virtual void reset();
|
||||
virtual void change();
|
||||
};
|
||||
|
||||
#endif /* J3DMATERIAL_H */
|
||||
@@ -0,0 +1,330 @@
|
||||
#ifndef J3DPACKET_H
|
||||
#define J3DPACKET_H
|
||||
|
||||
#include "JSystem/J3DAssert.h"
|
||||
#include "JSystem/J3DGraphBase/J3DSys.h"
|
||||
#include "JSystem/J3DGraphBase/J3DEnum.h"
|
||||
#include <gd/GDBase.h>
|
||||
#include <mtx.h>
|
||||
#include <stdint.h>
|
||||
|
||||
class J3DMatPacket;
|
||||
|
||||
class J3DDrawBuffer;
|
||||
class J3DMaterial;
|
||||
class J3DMaterialAnm;
|
||||
class J3DModel;
|
||||
class J3DMtxBuffer;
|
||||
class J3DShape;
|
||||
class J3DTexMtx;
|
||||
class J3DTexMtxObj;
|
||||
class J3DTexture;
|
||||
|
||||
enum J3DDiffFlag {
|
||||
J3DDiffFlag_MatColor = 0x1,
|
||||
J3DDiffFlag_ColorChan = 0x2,
|
||||
J3DDiffFlag_AmbColor = 0x4,
|
||||
J3DDiffFlag_TexGen = 0x1000,
|
||||
J3DDiffFlag_TevReg = 0x1000000,
|
||||
J3DDiffFlag_KonstColor = 0x2000000, // is this right?
|
||||
J3DDiffFlag_TexCoordScale = 0x4000000,
|
||||
J3DDiffFlag_TevStageIndirect = 0x8000000,
|
||||
J3DDiffFlag_Fog = 0x10000000,
|
||||
J3DDiffFlag_Blend = 0x20000000,
|
||||
J3DDiffFlag_Unk40000000 = 0x40000000,
|
||||
J3DDiffFlag_Changed = 0x80000000,
|
||||
};
|
||||
|
||||
#define J3D_DIFF_LIGHTOBJNUM(n) ((n & 0xF) << 4)
|
||||
#define J3D_DIFF_TEXGENNUM(n) ((n & 0xF) << 8)
|
||||
#define J3D_DIFF_TEXNONUM(n) ((n & 0xF) << 16)
|
||||
#define J3D_DIFF_TEVSTAGENUM(n) ((n & 0xF) << 20)
|
||||
|
||||
#define J3D_DIFF_FLAG(MatColor, ColorChan, AmbColor, LightNum, TexGenNum, TexGen, TexCoordNum, TevStageNum, TevReg, KColor, TexCoordScale, TevStageInd, Fog, Blend) \
|
||||
( \
|
||||
(MatColor << 0) | \
|
||||
(ColorChan << 1) | \
|
||||
(AmbColor << 2) | \
|
||||
((LightNum & 0xF) << 4) | \
|
||||
((TexGenNum & 0xF) << 8) | \
|
||||
(TexGen << 12) | \
|
||||
((TexCoordNum & 0xF) << 16) | \
|
||||
((TevStageNum & 0xF) << 20) | \
|
||||
(TevReg << 24) | \
|
||||
(KColor << 25) | \
|
||||
(TexCoordScale << 26) | \
|
||||
(TevStageInd << 27) | \
|
||||
(Fog << 28) | \
|
||||
(Blend << 29) \
|
||||
)
|
||||
|
||||
inline u32 getDiffFlag_LightObjNum(u32 diffFlags) {
|
||||
return (diffFlags & 0xf0) >> 4;
|
||||
}
|
||||
|
||||
inline u32 getDiffFlag_TexGenNum(u32 diffFlags) {
|
||||
return (diffFlags & 0xf00) >> 8;
|
||||
}
|
||||
|
||||
inline int calcDifferedBufferSize_TexMtxSize(u32 param_1) {
|
||||
return param_1 * 0x35;
|
||||
}
|
||||
|
||||
inline int calcDifferedBufferSize_TexGenSize(u32 param_1) {
|
||||
return param_1 * 0x3d + 10;
|
||||
}
|
||||
|
||||
inline u32 getDiffFlag_TexNoNum(u32 diffFlags) {
|
||||
return (diffFlags & 0xf0000) >> 0x10;
|
||||
}
|
||||
|
||||
inline int calcDifferedBufferSize_TexNoSize(u32 param_1) {
|
||||
return param_1 * 0x37;
|
||||
}
|
||||
|
||||
inline u32 calcDifferedBufferSize_TexNoAndTexCoordScaleSize(u32 param_1) {
|
||||
u32 res = param_1 * 0x37;
|
||||
res += ((param_1 + 1) >> 1) * 0x37;
|
||||
return res;
|
||||
}
|
||||
|
||||
inline u32 getDiffFlag_TevStageNum(u32 diffFlags) {
|
||||
return (diffFlags & 0xf00000) >> 0x14;
|
||||
}
|
||||
|
||||
inline int calcDifferedBufferSize_TevStageSize(u32 param_1) {
|
||||
return param_1 * 10;
|
||||
}
|
||||
|
||||
inline int calcDifferedBufferSize_TevStageDirectSize(u32 param_1) {
|
||||
return param_1 * 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DDisplayListObj {
|
||||
public:
|
||||
J3DDisplayListObj() {
|
||||
mpDisplayList[0] = NULL;
|
||||
mpDisplayList[1] = NULL;
|
||||
mSize = 0;
|
||||
mMaxSize = 0;
|
||||
}
|
||||
|
||||
J3DError newDisplayList(u32);
|
||||
J3DError newSingleDisplayList(u32);
|
||||
int single_To_Double();
|
||||
void setSingleDisplayList(void*, u32);
|
||||
void swapBuffer();
|
||||
void callDL() const;
|
||||
void beginDL();
|
||||
u32 endDL();
|
||||
void beginPatch();
|
||||
u32 endPatch();
|
||||
|
||||
u8* getDisplayList(int idx) { return (u8*)mpDisplayList[idx]; }
|
||||
u32 getDisplayListSize() { return mSize; }
|
||||
|
||||
static GDLObj sGDLObj;
|
||||
static s32 sInterruptFlag;
|
||||
|
||||
/* 0x0 */ void* mpDisplayList[2];
|
||||
/* 0x8 */ u32 mSize;
|
||||
/* 0xC */ u32 mMaxSize;
|
||||
}; // Size: 0x10
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DTexMtxObj {
|
||||
public:
|
||||
Mtx& getMtx(u16 idx) {
|
||||
J3D_ASSERT_RANGE(275, idx < mTexMtxNum);
|
||||
return mpTexMtx[idx];
|
||||
}
|
||||
|
||||
void setMtx(u16 idx, const Mtx mtx) {
|
||||
J3D_ASSERT_RANGE(288, idx < mTexMtxNum);
|
||||
MTXCopy(mtx, mpTexMtx[idx]);
|
||||
}
|
||||
|
||||
Mtx44& getEffectMtx(u16 idx) {
|
||||
J3D_ASSERT_RANGE(293, idx < mTexMtxNum);
|
||||
return mpEffectMtx[idx];
|
||||
}
|
||||
|
||||
u16 getNumTexMtx() const { return mTexMtxNum; }
|
||||
|
||||
/* 0x00 */ Mtx* mpTexMtx;
|
||||
/* 0x04 */ Mtx44* mpEffectMtx;
|
||||
/* 0x08 */ u16 mTexMtxNum;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DPacket {
|
||||
public:
|
||||
J3DPacket() {
|
||||
mpNextPacket = NULL;
|
||||
mpFirstChild = NULL;
|
||||
mpUserArea = NULL;
|
||||
}
|
||||
|
||||
void addChildPacket(J3DPacket*);
|
||||
|
||||
J3DPacket* getNextPacket() const { return mpNextPacket; }
|
||||
void setNextPacket(J3DPacket* i_packet) { mpNextPacket = i_packet; }
|
||||
|
||||
void drawClear() {
|
||||
mpNextPacket = NULL;
|
||||
mpFirstChild = NULL;
|
||||
}
|
||||
|
||||
void* getUserArea() const { return mpUserArea; }
|
||||
void setUserArea(uintptr_t area) { mpUserArea = (void*)area; }
|
||||
|
||||
virtual int entry(J3DDrawBuffer*);
|
||||
virtual void draw();
|
||||
virtual ~J3DPacket() {}
|
||||
|
||||
public:
|
||||
/* 0x04 */ J3DPacket* mpNextPacket;
|
||||
/* 0x08 */ J3DPacket* mpFirstChild;
|
||||
/* 0x0C */ void* mpUserArea;
|
||||
}; // Size: 0x10
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DDrawPacket : public J3DPacket {
|
||||
public:
|
||||
J3DDrawPacket();
|
||||
~J3DDrawPacket();
|
||||
J3DError newDisplayList(u32);
|
||||
J3DError newSingleDisplayList(u32);
|
||||
virtual void draw();
|
||||
|
||||
J3DDisplayListObj* getDisplayListObj() { return mpDisplayListObj; }
|
||||
void setDisplayListObj(J3DDisplayListObj* pObj) { mpDisplayListObj = pObj; }
|
||||
|
||||
void beginPatch() { mpDisplayListObj->beginPatch(); }
|
||||
void endPatch() { mpDisplayListObj->endPatch(); }
|
||||
|
||||
void callDL() const { mpDisplayListObj->callDL(); }
|
||||
void beginDL() { mpDisplayListObj->beginDL(); }
|
||||
void endDL() { mpDisplayListObj->endDL(); }
|
||||
|
||||
void* getDisplayList(int i) { return mpDisplayListObj->mpDisplayList[i]; }
|
||||
u32 getDisplayListSize() const { return mpDisplayListObj->mSize; }
|
||||
|
||||
enum {
|
||||
LOCKED = 0x01,
|
||||
};
|
||||
|
||||
bool checkFlag(u32 flag) const { return (mFlags & flag) ? true : false; }
|
||||
void onFlag(u32 flag) { mFlags |= flag; }
|
||||
void offFlag(u32 flag) { mFlags &= ~flag; }
|
||||
void lock() { onFlag(LOCKED); }
|
||||
void unlock() { offFlag(LOCKED); }
|
||||
J3DTexMtxObj* getTexMtxObj() { return mpTexMtxObj; }
|
||||
bool isLocked() const { return checkFlag(1); }
|
||||
|
||||
public:
|
||||
/* 0x10 */ u32 mFlags;
|
||||
/* 0x14 */ char unk_0x14[0x20 - 0x14];
|
||||
/* 0x20 */ J3DDisplayListObj* mpDisplayListObj;
|
||||
/* 0x24 */ J3DTexMtxObj* mpTexMtxObj;
|
||||
}; // Size: 0x28
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DShapePacket : public J3DDrawPacket {
|
||||
public:
|
||||
J3DShapePacket();
|
||||
u32 calcDifferedBufferSize(u32);
|
||||
int newDifferedDisplayList(u32);
|
||||
void prepareDraw() const;
|
||||
void drawFast();
|
||||
|
||||
virtual ~J3DShapePacket();
|
||||
virtual void draw();
|
||||
|
||||
void setShape(J3DShape* pShape) {
|
||||
J3D_ASSERT_NULLPTR(523, pShape != NULL);
|
||||
mpShape = pShape;
|
||||
}
|
||||
|
||||
void setModel(J3DModel* pModel) {
|
||||
J3D_ASSERT_NULLPTR(533, pModel != NULL);
|
||||
mpModel = pModel;
|
||||
}
|
||||
|
||||
void setMtxBuffer(J3DMtxBuffer* pMtxBuffer) { mpMtxBuffer = pMtxBuffer; }
|
||||
void setBaseMtxPtr(Mtx* pMtx) { mpBaseMtxPtr = pMtx; }
|
||||
|
||||
J3DShape* getShape() const { return mpShape; }
|
||||
J3DModel* getModel() const { return mpModel; }
|
||||
Mtx* getBaseMtxPtr() const { return mpBaseMtxPtr; }
|
||||
|
||||
public:
|
||||
/* 0x28 */ J3DShape* mpShape;
|
||||
/* 0x2C */ J3DMtxBuffer* mpMtxBuffer;
|
||||
/* 0x30 */ Mtx* mpBaseMtxPtr;
|
||||
/* 0x34 */ u32 mDiffFlag;
|
||||
/* 0x38 */ J3DModel* mpModel;
|
||||
}; // Size: 0x3C
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DMatPacket : public J3DDrawPacket {
|
||||
public:
|
||||
J3DMatPacket();
|
||||
void addShapePacket(J3DShapePacket*);
|
||||
void beginDiff();
|
||||
void endDiff();
|
||||
bool isSame(J3DMatPacket*) const;
|
||||
|
||||
J3DMaterial* getMaterial() const { return mpMaterial; }
|
||||
J3DShapePacket* getShapePacket() const { return mpShapePacket; }
|
||||
void setShapePacket(J3DShapePacket* packet) { mpShapePacket = packet; }
|
||||
|
||||
void setMaterial(J3DMaterial* pMaterial) {
|
||||
J3D_ASSERT_NULLPTR(646, pMaterial != NULL);
|
||||
mpMaterial = pMaterial;
|
||||
}
|
||||
|
||||
void setTexture(J3DTexture* pTexture) {
|
||||
J3D_ASSERT_NULLPTR(651, pTexture != NULL);
|
||||
mpTexture = pTexture;
|
||||
}
|
||||
|
||||
void setInitShapePacket(J3DShapePacket* packet) { mpInitShapePacket = packet; }
|
||||
void setMaterialID(u32 id) { mDiffFlag = id; }
|
||||
void setMaterialAnmID(J3DMaterialAnm* materialAnm) { mpMaterialAnm = materialAnm; }
|
||||
BOOL isChanged() { return mDiffFlag & J3DDiffFlag_Changed; }
|
||||
bool isEnabled_Diff() { return mpInitShapePacket->getDisplayListObj() != NULL; }
|
||||
|
||||
virtual ~J3DMatPacket();
|
||||
virtual int entry(J3DDrawBuffer*);
|
||||
virtual void draw();
|
||||
|
||||
public:
|
||||
/* 0x28 */ J3DShapePacket* mpInitShapePacket;
|
||||
/* 0x2C */ J3DShapePacket* mpShapePacket;
|
||||
/* 0x30 */ J3DMaterial* mpMaterial;
|
||||
/* 0x34 */ u32 mDiffFlag;
|
||||
/* 0x38 */ J3DTexture* mpTexture;
|
||||
/* 0x3C */ J3DMaterialAnm* mpMaterialAnm;
|
||||
}; // Size: 0x40
|
||||
|
||||
#endif /* J3DPACKET_H */
|
||||
@@ -0,0 +1,230 @@
|
||||
#ifndef J3DSHAPE_H
|
||||
#define J3DSHAPE_H
|
||||
|
||||
#include "JSystem/J3DGraphBase/J3DShapeDraw.h"
|
||||
#include "JSystem/J3DAssert.h"
|
||||
#include "JSystem/J3DGraphBase/J3DFifo.h"
|
||||
#include <mtx.h>
|
||||
|
||||
class J3DShapeMtx;
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DCurrentMtxInfo {
|
||||
public:
|
||||
u32 mMtxIdxRegA;
|
||||
u32 mMtxIdxRegB;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DCurrentMtx : public J3DCurrentMtxInfo {
|
||||
public:
|
||||
J3DCurrentMtx() {
|
||||
mMtxIdxRegA = 0x3cf3cf00;
|
||||
mMtxIdxRegB = 0x00f3cf3c;
|
||||
}
|
||||
|
||||
J3DCurrentMtx& operator=(J3DCurrentMtxInfo const& info) {
|
||||
mMtxIdxRegA = info.mMtxIdxRegA;
|
||||
mMtxIdxRegB = info.mMtxIdxRegB;
|
||||
return *this;
|
||||
}
|
||||
|
||||
u32 getMtxIdxRegA() const { return mMtxIdxRegA; }
|
||||
u32 getMtxIdxRegB() const { return mMtxIdxRegB; }
|
||||
|
||||
void load() const {
|
||||
J3DFifoLoadCPCmd(CP_REG_MTXIDXA_ID, mMtxIdxRegA);
|
||||
J3DFifoLoadCPCmd(CP_REG_MTXIDXB_ID, mMtxIdxRegB);
|
||||
J3DFifoLoadXFCmdHdr(GX_XF_REG_MATRIXINDEX0, 2);
|
||||
GXCmd1u32(mMtxIdxRegA);
|
||||
GXCmd1u32(mMtxIdxRegB);
|
||||
}
|
||||
|
||||
void setCurrentTexMtx(u8 param_1, u8 param_2, u8 param_3, u8 param_4,
|
||||
u8 param_5, u8 param_6, u8 param_7, u8 param_8) {
|
||||
mMtxIdxRegA = (param_1 << 6) | (param_2 << 0xc) | (param_3 << 0x12) | (param_4 << 0x18);
|
||||
mMtxIdxRegB = (param_5) | param_6 << 6 | param_7 << 0xc | param_8 << 0x12;
|
||||
}
|
||||
};
|
||||
|
||||
typedef void (J3DShapeMtx::*J3DShapeMtx_LoadFunc)(int, u16) const;
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DShapeMtx {
|
||||
public:
|
||||
J3DShapeMtx(u16 useMtxIndex)
|
||||
: mUseMtxIndex(useMtxIndex)
|
||||
{}
|
||||
|
||||
void loadMtxIndx_PNGP(int, u16) const;
|
||||
void loadMtxIndx_PCPU(int, u16) const;
|
||||
void loadMtxIndx_NCPU(int, u16) const;
|
||||
void loadMtxIndx_PNCPU(int, u16) const;
|
||||
|
||||
virtual ~J3DShapeMtx() {}
|
||||
virtual u32 getType() const { return 'SMTX'; }
|
||||
virtual u16 getUseMtxNum() const { return 1; }
|
||||
virtual u16 getUseMtxIndex(u16) const { return mUseMtxIndex; }
|
||||
virtual void load() const;
|
||||
virtual void calcNBTScale(Vec const&, f32 (*)[3][3], f32 (*)[3][3]);
|
||||
|
||||
static J3DShapeMtx_LoadFunc sMtxLoadPipeline[4];
|
||||
static u16 sMtxLoadCache[10];
|
||||
static u32 sCurrentPipeline;
|
||||
static u8* sCurrentScaleFlag;
|
||||
static bool sNBTFlag;
|
||||
static bool sLODFlag;
|
||||
static u32 sTexMtxLoadType;
|
||||
|
||||
static void setCurrentPipeline(u32 pipeline) {
|
||||
J3D_ASSERT_RANGE(91, pipeline < 4);
|
||||
sCurrentPipeline = pipeline;
|
||||
}
|
||||
|
||||
static void setLODFlag(bool flag) { sLODFlag = flag; }
|
||||
static u32 getLODFlag() { return sLODFlag; }
|
||||
static void resetMtxLoadCache();
|
||||
|
||||
protected:
|
||||
/* 0x04 */ u16 mUseMtxIndex;
|
||||
};
|
||||
|
||||
class J3DMaterial;
|
||||
class J3DVertexData;
|
||||
struct J3DDrawMtxData;
|
||||
|
||||
enum J3DShpFlag {
|
||||
J3DShpFlag_Visible = 0x0001,
|
||||
J3DShpFlag_SkinPosCpu = 0x0004,
|
||||
J3DShpFlag_SkinNrmCpu = 0x0008,
|
||||
J3DShpFlag_Hidden = 0x0010,
|
||||
J3DShpFlag_EnableLod = 0x0100,
|
||||
J3DShpFlag_NoMtx = 0x0200,
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DShape {
|
||||
public:
|
||||
J3DShape() {
|
||||
initialize();
|
||||
}
|
||||
|
||||
static const int kVcdVatDLSize = 0xC0;
|
||||
|
||||
void initialize();
|
||||
void addTexMtxIndexInDL(_GXAttr, u32);
|
||||
void addTexMtxIndexInVcd(_GXAttr);
|
||||
void calcNBTScale(Vec const&, f32 (*)[3][3], f32 (*)[3][3]);
|
||||
u16 countBumpMtxNum() const;
|
||||
void loadVtxArray() const;
|
||||
bool isSameVcdVatCmd(J3DShape*);
|
||||
void makeVtxArrayCmd();
|
||||
void makeVcdVatCmd();
|
||||
void loadPreDrawSetting() const;
|
||||
void setArrayAndBindPipeline() const;
|
||||
|
||||
virtual void draw() const;
|
||||
virtual void drawFast() const;
|
||||
virtual void simpleDraw() const;
|
||||
virtual void simpleDrawCache() const;
|
||||
|
||||
void loadCurrentMtx() const;
|
||||
|
||||
void onFlag(u32 flag) { mFlags |= flag; }
|
||||
void offFlag(u32 flag) { mFlags &= ~flag; }
|
||||
bool checkFlag(u32 flag) const { return (mFlags & flag) ? true : false; }
|
||||
|
||||
void setMaterial(J3DMaterial* pMaterial) {
|
||||
J3D_ASSERT_NULLPTR(509, pMaterial != NULL);
|
||||
mMaterial = pMaterial;
|
||||
}
|
||||
|
||||
void setDrawMtxDataPointer(J3DDrawMtxData* pMtxData) {
|
||||
J3D_ASSERT_NULLPTR(554, pMtxData != NULL);
|
||||
mDrawMtxData = pMtxData;
|
||||
}
|
||||
|
||||
void setVertexDataPointer(J3DVertexData* pVtxData) {
|
||||
J3D_ASSERT_NULLPTR(657, pVtxData != NULL);
|
||||
mVertexData = pVtxData;
|
||||
}
|
||||
|
||||
void* getVcdVatCmd() { return mVcdVatCmd; }
|
||||
void setVcdVatCmd(void* pVatCmd) { mVcdVatCmd = (u8*)pVatCmd; }
|
||||
void show() { offFlag(J3DShpFlag_Visible); }
|
||||
void hide() { onFlag(J3DShpFlag_Visible); }
|
||||
|
||||
void setCurrentViewNoPtr(u32* pViewNoPtr) {
|
||||
J3D_ASSERT_NULLPTR(584, pViewNoPtr != NULL);
|
||||
mCurrentViewNo = pViewNoPtr;
|
||||
}
|
||||
|
||||
void setCurrentMtx(J3DCurrentMtx& mtx) { mCurrentMtx = mtx; }
|
||||
|
||||
void setScaleFlagArray(u8* pScaleFlagArray) {
|
||||
J3D_ASSERT_NULLPTR(595, pScaleFlagArray != NULL);
|
||||
mScaleFlagArray = pScaleFlagArray;
|
||||
}
|
||||
|
||||
void setDrawMtx(Mtx** pDrawMtx) { mDrawMtx = pDrawMtx; }
|
||||
void setNrmMtx(Mtx33** pNrmMtx) { mNrmMtx = pNrmMtx; }
|
||||
void setTexMtxLoadType(u32 type) { mFlags = type | (mFlags & ~0xF000); }
|
||||
bool getNBTFlag() const { return mHasNBT; }
|
||||
u32 getBumpMtxOffset() const { return mBumpMtxOffset; }
|
||||
void setBumpMtxOffset(u32 offset) { mBumpMtxOffset = offset; }
|
||||
GXVtxDescList* getVtxDesc() { return mVtxDesc; }
|
||||
|
||||
J3DMaterial* getMaterial() const { return mMaterial; }
|
||||
u16 getIndex() const { return mIndex; }
|
||||
u32 getTexMtxLoadType() const { return mFlags & 0xF000; }
|
||||
u16 getMtxGroupNum() const { return mMtxGroupNum; }
|
||||
J3DShapeDraw* getShapeDraw(u16 idx) { return mShapeDraw[idx]; }
|
||||
J3DShapeMtx* getShapeMtx(u16 idx) { return mShapeMtx[idx]; }
|
||||
Vec* getMin() { return &mMin; }
|
||||
Vec* getMax() { return &mMax; }
|
||||
|
||||
static void resetVcdVatCache() { sOldVcdVatCmd = NULL; }
|
||||
|
||||
static void* sOldVcdVatCmd;
|
||||
static bool sEnvelopeFlag;
|
||||
|
||||
private:
|
||||
friend struct J3DShapeFactory;
|
||||
friend class J3DJointTree;
|
||||
|
||||
/* 0x04 */ J3DMaterial* mMaterial;
|
||||
/* 0x08 */ u16 mIndex;
|
||||
/* 0x0A */ u16 mMtxGroupNum;
|
||||
/* 0x0C */ u32 mFlags;
|
||||
/* 0x10 */ f32 mRadius;
|
||||
/* 0x14 */ Vec mMin;
|
||||
/* 0x20 */ Vec mMax;
|
||||
/* 0x2C */ u8* mVcdVatCmd;
|
||||
/* 0x30 */ GXVtxDescList* mVtxDesc;
|
||||
/* 0x34 */ bool mHasNBT;
|
||||
/* 0x38 */ J3DShapeMtx** mShapeMtx;
|
||||
/* 0x3C */ J3DShapeDraw** mShapeDraw;
|
||||
/* 0x40 */ J3DCurrentMtx mCurrentMtx;
|
||||
/* 0x48 */ bool mHasPNMTXIdx;
|
||||
/* 0x4C */ J3DVertexData* mVertexData;
|
||||
/* 0x50 */ J3DDrawMtxData* mDrawMtxData;
|
||||
/* 0x54 */ u8* mScaleFlagArray;
|
||||
/* 0x58 */ Mtx** mDrawMtx;
|
||||
/* 0x5C */ Mtx33** mNrmMtx;
|
||||
/* 0x60 */ u32* mCurrentViewNo;
|
||||
/* 0x64 */ u32 mBumpMtxOffset;
|
||||
};
|
||||
|
||||
#endif /* J3DSHAPE_H */
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef J3DSHAPEDRAW_H
|
||||
#define J3DSHAPEDRAW_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DShapeDraw {
|
||||
public:
|
||||
u32 countVertex(u32);
|
||||
void addTexMtxIndexInDL(u32, u32, u32);
|
||||
J3DShapeDraw(u8 const*, u32);
|
||||
void draw() const;
|
||||
|
||||
virtual ~J3DShapeDraw();
|
||||
|
||||
u8* getDisplayList() const { return (u8*)mDisplayList; }
|
||||
u32 getDisplayListSize() const { return mDisplayListSize; }
|
||||
void setDisplayListSize(u32 size) { mDisplayListSize = size; }
|
||||
|
||||
private:
|
||||
/* 0x04 */ u32 mDisplayListSize;
|
||||
/* 0x08 */ void* mDisplayList;
|
||||
};
|
||||
|
||||
#endif /* J3DSHAPEDRAW_H */
|
||||
@@ -0,0 +1,137 @@
|
||||
#ifndef J3DSHAPEMTX_H
|
||||
#define J3DSHAPEMTX_H
|
||||
|
||||
#include "JSystem/J3DGraphBase/J3DShape.h"
|
||||
#include "JSystem/J3DAssert.h"
|
||||
#include <mtx.h>
|
||||
|
||||
class J3DTexMtx;
|
||||
class J3DTexGenBlock;
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DDifferedTexMtx {
|
||||
public:
|
||||
static void loadExecute(f32 const (*)[4]);
|
||||
|
||||
static inline void load(const Mtx m) {
|
||||
if (sTexGenBlock != NULL)
|
||||
loadExecute(m);
|
||||
}
|
||||
|
||||
static J3DTexGenBlock* sTexGenBlock;
|
||||
static J3DTexMtxObj* sTexMtxObj;
|
||||
};
|
||||
|
||||
class J3DShapeMtxConcatView;
|
||||
typedef void (J3DShapeMtxConcatView::*J3DShapeMtxConcatView_LoadFunc)(int, u16) const;
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DShapeMtxMulti : public J3DShapeMtx {
|
||||
public:
|
||||
J3DShapeMtxMulti(u16 useMtxIndex, u16 useMtxNum, u16* useMtxIndexTable)
|
||||
: J3DShapeMtx(useMtxIndex)
|
||||
, mUseMtxNum(useMtxNum)
|
||||
, mUseMtxIndexTable(useMtxIndexTable)
|
||||
{}
|
||||
|
||||
virtual ~J3DShapeMtxMulti() {}
|
||||
virtual u32 getType() const { return 'SMML'; }
|
||||
virtual u16 getUseMtxNum() const { return mUseMtxNum; }
|
||||
virtual u16 getUseMtxIndex(u16 no) const { return mUseMtxIndexTable[no]; }
|
||||
virtual void load() const;
|
||||
virtual void calcNBTScale(Vec const&, f32 (*)[3][3], f32 (*)[3][3]);
|
||||
|
||||
private:
|
||||
/* 0x8 */ u16 mUseMtxNum;
|
||||
/* 0xC */ u16* mUseMtxIndexTable;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DShapeMtxConcatView : public J3DShapeMtx {
|
||||
public:
|
||||
J3DShapeMtxConcatView(u16 useMtxIndex)
|
||||
: J3DShapeMtx(useMtxIndex)
|
||||
{}
|
||||
|
||||
virtual ~J3DShapeMtxConcatView() {}
|
||||
virtual u32 getType() const { return 'SMCV'; }
|
||||
virtual void load() const;
|
||||
virtual void loadNrmMtx(int, u16) const {}
|
||||
virtual void loadNrmMtx(int, u16, f32 (*)[4]) const;
|
||||
|
||||
void loadMtxConcatView_PNGP(int, u16) const;
|
||||
void loadMtxConcatView_PCPU(int, u16) const;
|
||||
void loadMtxConcatView_NCPU(int, u16) const;
|
||||
void loadMtxConcatView_PNCPU(int, u16) const;
|
||||
void loadMtxConcatView_PNGP_LOD(int, u16) const;
|
||||
|
||||
static J3DShapeMtxConcatView_LoadFunc sMtxLoadPipeline[4];
|
||||
static J3DShapeMtxConcatView_LoadFunc sMtxLoadLODPipeline[4];
|
||||
static MtxP sMtxPtrTbl[2];
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DShapeMtxMultiConcatView : public J3DShapeMtxConcatView {
|
||||
public:
|
||||
J3DShapeMtxMultiConcatView(u16 useMtxIndex, u16 useMtxNum, u16* useMtxIndexTable)
|
||||
: J3DShapeMtxConcatView(useMtxIndex)
|
||||
, mUseMtxNum(useMtxNum)
|
||||
, mUseMtxIndexTable(useMtxIndexTable)
|
||||
{}
|
||||
|
||||
virtual ~J3DShapeMtxMultiConcatView() {}
|
||||
virtual u32 getType() const { return 'SMMC'; }
|
||||
virtual u16 getUseMtxNum() const { return mUseMtxNum; }
|
||||
virtual u16 getUseMtxIndex(u16 no) const { return mUseMtxIndexTable[no]; }
|
||||
virtual void load() const;
|
||||
virtual void loadNrmMtx(int, u16) const {}
|
||||
virtual void loadNrmMtx(int, u16, f32 (*)[4]) const;
|
||||
|
||||
private:
|
||||
/* 0x8 */ u16 mUseMtxNum;
|
||||
/* 0xC */ u16* mUseMtxIndexTable;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DShapeMtxBBoardConcatView : public J3DShapeMtxConcatView {
|
||||
public:
|
||||
J3DShapeMtxBBoardConcatView(u16 useMtxIndex)
|
||||
: J3DShapeMtxConcatView(useMtxIndex)
|
||||
{}
|
||||
|
||||
virtual ~J3DShapeMtxBBoardConcatView() {}
|
||||
virtual u32 getType() const { return 'SMBB'; }
|
||||
virtual void load() const;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DShapeMtxYBBoardConcatView : public J3DShapeMtxConcatView {
|
||||
public:
|
||||
J3DShapeMtxYBBoardConcatView(u16 useMtxIndex)
|
||||
: J3DShapeMtxConcatView(useMtxIndex)
|
||||
{}
|
||||
|
||||
virtual ~J3DShapeMtxYBBoardConcatView() {}
|
||||
virtual u32 getType() const { return 'SMYB'; }
|
||||
virtual void load() const;
|
||||
};
|
||||
|
||||
#endif /* J3DSHAPEMTX_H */
|
||||
@@ -0,0 +1,324 @@
|
||||
#ifndef J3DSTRUCT_H
|
||||
#define J3DSTRUCT_H
|
||||
|
||||
#include <gx.h>
|
||||
#include <mtx.h>
|
||||
#include <mtx.h>
|
||||
#include "global.h"
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DLightInfo {
|
||||
bool operator==(J3DLightInfo& other) const;
|
||||
J3DLightInfo& operator=(J3DLightInfo const&);
|
||||
|
||||
/* 0x00 */ Vec mLightPosition;
|
||||
/* 0x0C */ Vec mLightDirection;
|
||||
/* 0x18 */ GXColor mColor;
|
||||
/* 0x1C */ Vec mCosAtten;
|
||||
/* 0x28 */ Vec mDistAtten;
|
||||
}; // Size = 0x34
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DTextureSRTInfo {
|
||||
/* 0x00 */ f32 mScaleX;
|
||||
/* 0x04 */ f32 mScaleY;
|
||||
/* 0x08 */ s16 mRotation;
|
||||
/* 0x0C */ f32 mTranslationX;
|
||||
/* 0x10 */ f32 mTranslationY;
|
||||
|
||||
bool operator==(J3DTextureSRTInfo&) const;
|
||||
inline void operator=(J3DTextureSRTInfo const& other) {
|
||||
#ifdef __MWERKS__
|
||||
__REGISTER const f32* src = &other.mScaleX;
|
||||
__REGISTER f32* dst = &mScaleX;
|
||||
__REGISTER f32 xy;
|
||||
asm {
|
||||
psq_l xy, 0(src), 0, 0
|
||||
psq_st xy, 0(dst), 0, 0
|
||||
};
|
||||
|
||||
// Unclear why there's a 4 byte copy here.
|
||||
*(u32*)&mRotation = *(u32*)&other.mRotation;
|
||||
src = &other.mTranslationX;
|
||||
dst = &mTranslationX;
|
||||
|
||||
asm {
|
||||
psq_l xy, 0(src), 0, 0
|
||||
psq_st xy, 0(dst), 0, 0
|
||||
};
|
||||
#endif
|
||||
}
|
||||
}; // Size: 0x14
|
||||
|
||||
enum J3DTexMtxMode {
|
||||
J3DTexMtxMode_None,
|
||||
J3DTexMtxMode_EnvmapBasic,
|
||||
J3DTexMtxMode_ProjmapBasic,
|
||||
J3DTexMtxMode_ViewProjmapBasic,
|
||||
J3DTexMtxMode_Unknown4,
|
||||
J3DTexMtxMode_Unknown5,
|
||||
J3DTexMtxMode_EnvmapOld,
|
||||
J3DTexMtxMode_Envmap,
|
||||
J3DTexMtxMode_Projmap,
|
||||
J3DTexMtxMode_ViewProjmap,
|
||||
J3DTexMtxMode_EnvmapOldEffectMtx,
|
||||
J3DTexMtxMode_EnvmapEffectMtx,
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DTexMtxInfo {
|
||||
bool operator==(J3DTexMtxInfo& other) const;
|
||||
J3DTexMtxInfo& operator=(J3DTexMtxInfo const&);
|
||||
void setEffectMtx(Mtx);
|
||||
|
||||
/* 0x00 */ u8 mProjection;
|
||||
/* 0x01 */ u8 mInfo;
|
||||
/* 0x02 */ u8 field_0x2;
|
||||
/* 0x03 */ u8 field_0x3;
|
||||
/* 0x04 */ Vec mCenter;
|
||||
/* 0x10 */ J3DTextureSRTInfo mSRT;
|
||||
/* 0x24 */ Mtx44 mEffectMtx;
|
||||
}; // Size: 0x64
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DIndTexMtxInfo {
|
||||
J3DIndTexMtxInfo& operator=(J3DIndTexMtxInfo const&);
|
||||
/* 0x00 */ Mtx23 field_0x0;
|
||||
/* 0x18 */ s8 field_0x18;
|
||||
}; // Size: 0x1C
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DFogInfo {
|
||||
bool operator==(J3DFogInfo&) const;
|
||||
J3DFogInfo& operator=(const J3DFogInfo&);
|
||||
|
||||
/* 0x00 */ u8 mType;
|
||||
/* 0x01 */ u8 mAdjEnable;
|
||||
/* 0x02 */ u16 mCenter;
|
||||
/* 0x04 */ f32 mStartZ;
|
||||
/* 0x08 */ f32 mEndZ;
|
||||
/* 0x0C */ f32 mNearZ;
|
||||
/* 0x10 */ f32 mFarZ;
|
||||
/* 0x14 */ GXColor mColor;
|
||||
/* 0x18 */ GXFogAdjTable mFogAdjTable;
|
||||
}; // Size: 0x2C
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DNBTScaleInfo {
|
||||
bool operator==(const J3DNBTScaleInfo& other) const;
|
||||
J3DNBTScaleInfo& operator=(const J3DNBTScaleInfo&);
|
||||
|
||||
/* 0x0 */ u8 mbHasScale;
|
||||
/* 0x4 */ Vec mScale;
|
||||
}; // Size: 0x10
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DIndTexOrderInfo {
|
||||
/* 0x0 */ u8 mCoord;
|
||||
/* 0x1 */ u8 mMap;
|
||||
/* 0x2 */ u8 field_0x2;
|
||||
/* 0x3 */ u8 field_0x3;
|
||||
|
||||
void operator=(J3DIndTexOrderInfo const& other) {
|
||||
__memcpy(this, &other, sizeof(J3DIndTexOrderInfo));
|
||||
}
|
||||
}; // Size: 0x04
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DTevSwapModeInfo {
|
||||
/* 0x0 */ u8 mRasSel;
|
||||
/* 0x1 */ u8 mTexSel;
|
||||
/* 0x2 */ u8 field_0x2;
|
||||
/* 0x3 */ u8 field_0x3;
|
||||
}; // Size: 0x4
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DTevSwapModeTableInfo {
|
||||
/* 0x0 */ u8 field_0x0;
|
||||
/* 0x1 */ u8 field_0x1;
|
||||
/* 0x2 */ u8 field_0x2;
|
||||
/* 0x3 */ u8 field_0x3;
|
||||
}; // Size: 0x4
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DTevStageInfo {
|
||||
/* 0x0 */ u8 field_0x0;
|
||||
/* 0x1 */ u8 mTevColorOp;
|
||||
/* 0x2 */ u8 mTevColorAB;
|
||||
/* 0x3 */ u8 mTevColorCD;
|
||||
/* 0x4 */ u8 field_0x4;
|
||||
/* 0x5 */ u8 mTevAlphaOp;
|
||||
/* 0x6 */ u8 mTevAlphaAB;
|
||||
/* 0x7 */ u8 mTevSwapModeInfo;
|
||||
/* 0x8 */ u8 field_0x8;
|
||||
/* 0x8 */ u8 field_0x9;
|
||||
/* 0x8 */ u8 field_0xa;
|
||||
/* 0x8 */ u8 field_0xb;
|
||||
/* 0x8 */ u8 field_0xc;
|
||||
/* 0x8 */ u8 field_0xd;
|
||||
/* 0x8 */ u8 field_0xe;
|
||||
/* 0x8 */ u8 field_0xf;
|
||||
/* 0x8 */ u8 field_0x10;
|
||||
/* 0x8 */ u8 field_0x11;
|
||||
/* 0x8 */ u8 field_0x12;
|
||||
/* 0x8 */ u8 field_0x13;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DIndTevStageInfo {
|
||||
/* 0x0 */ u8 mIndStage;
|
||||
/* 0x1 */ u8 mIndFormat;
|
||||
/* 0x2 */ u8 mBiasSel;
|
||||
/* 0x3 */ u8 mMtxSel;
|
||||
/* 0x4 */ u8 mWrapS;
|
||||
/* 0x5 */ u8 mWrapT;
|
||||
/* 0x6 */ u8 mPrev;
|
||||
/* 0x7 */ u8 mLod;
|
||||
/* 0x8 */ u8 mAlphaSel;
|
||||
/* 0x9 */ u8 pad[3];
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DTexCoordInfo {
|
||||
/* 0x0 */ u8 mTexGenType;
|
||||
/* 0x1 */ u8 mTexGenSrc;
|
||||
/* 0x2 */ u8 mTexGenMtx;
|
||||
/* 0x3 */ u8 pad;
|
||||
|
||||
J3DTexCoordInfo& operator=(const J3DTexCoordInfo& other) {
|
||||
__memcpy(this, &other, sizeof(J3DTexCoordInfo));
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DIndTexCoordScaleInfo {
|
||||
/* 0x0 */ u8 mScaleS;
|
||||
/* 0x1 */ u8 mScaleT;
|
||||
/* 0x2 */ u8 field_0x2;
|
||||
/* 0x3 */ u8 field_0x3;
|
||||
|
||||
J3DIndTexCoordScaleInfo& operator=(const J3DIndTexCoordScaleInfo& other) {
|
||||
__memcpy(this, &other, sizeof(J3DIndTexCoordScaleInfo));
|
||||
return *this;
|
||||
}
|
||||
}; // Size: 0x4
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DBlendInfo {
|
||||
void operator=(J3DBlendInfo const& other) {
|
||||
__memcpy(this, &other, sizeof(J3DBlendInfo));
|
||||
}
|
||||
/* 0x0 */ u8 mType;
|
||||
/* 0x1 */ u8 mSrcFactor;
|
||||
/* 0x2 */ u8 mDstFactor;
|
||||
/* 0x3 */ u8 mOp;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DTevOrderInfo {
|
||||
void operator=(const J3DTevOrderInfo& other) {
|
||||
*(u32*) this = *(u32*)&other;
|
||||
}
|
||||
|
||||
/* 0x0 */ u8 mTexCoord;
|
||||
/* 0x1 */ u8 mTexMap;
|
||||
/* 0x2 */ u8 mColorChan;
|
||||
/* 0x3 */ u8 field_0x3; // Maybe padding
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DColorChanInfo {
|
||||
/* 0x0 */ u8 mEnable;
|
||||
/* 0x1 */ u8 mMatSrc;
|
||||
/* 0x2 */ u8 mLightMask;
|
||||
/* 0x3 */ u8 mDiffuseFn;
|
||||
/* 0x4 */ u8 mAttnFn;
|
||||
/* 0x5 */ u8 mAmbSrc;
|
||||
/* 0x6 */ u8 pad[2];
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DZModeInfo {
|
||||
/* 0x0 */ u8 field_0x0;
|
||||
/* 0x1 */ u8 field_0x1;
|
||||
/* 0x2 */ u8 field_0x2;
|
||||
/* 0x3 */ u8 pad;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DAlphaCompInfo {
|
||||
/* 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;
|
||||
|
||||
J3DAlphaCompInfo& operator=(const J3DAlphaCompInfo& other) {
|
||||
mComp0 = other.mComp0;
|
||||
mRef0 = other.mRef0;
|
||||
mOp = other.mOp;
|
||||
mComp1 = other.mComp1;
|
||||
mRef1 = other.mRef1;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* J3DSTRUCT_H */
|
||||
@@ -0,0 +1,183 @@
|
||||
#ifndef J3DSYS_H
|
||||
#define J3DSYS_H
|
||||
|
||||
#include <gx.h>
|
||||
#include <mtx.h>
|
||||
#include "JSystem/J3DAssert.h"
|
||||
|
||||
enum J3DSysDrawBuf {
|
||||
/* 0x0 */ J3DSysDrawBuf_Opa,
|
||||
/* 0x1 */ J3DSysDrawBuf_Xlu,
|
||||
|
||||
/* 0x2 */ J3DSysDrawBuf_MAX
|
||||
};
|
||||
|
||||
class J3DMtxCalc;
|
||||
class J3DModel;
|
||||
class J3DMatPacket;
|
||||
class J3DShapePacket;
|
||||
class J3DShape;
|
||||
class J3DDrawBuffer;
|
||||
class J3DTexture;
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DTexCoordScaleInfo {
|
||||
/* 0x0 */ u16 field_0x00;
|
||||
/* 0x2 */ u16 field_0x02;
|
||||
/* 0x4 */ u16 field_0x04;
|
||||
/* 0x6 */ u16 field_0x06;
|
||||
};
|
||||
|
||||
enum J3DSysFlag {
|
||||
J3DSysFlag_SkinPosCpu = 0x00000004,
|
||||
J3DSysFlag_SkinNrmCpu = 0x00000008,
|
||||
J3DSysFlag_PostTexMtx = 0x40000000,
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DSys {
|
||||
/* 0x000 */ Mtx mViewMtx;
|
||||
/* 0x030 */ J3DMtxCalc* mCurrentMtxCalc;
|
||||
/* 0x034 */ u32 mFlags;
|
||||
/* 0x038 */ J3DModel* mModel;
|
||||
/* 0x03C */ J3DMatPacket* mMatPacket;
|
||||
/* 0x040 */ J3DShapePacket* mShapePacket;
|
||||
/* 0x044 */ J3DShape* mShape;
|
||||
/* 0x048 */ J3DDrawBuffer* mDrawBuffer[J3DSysDrawBuf_MAX];
|
||||
/* 0x050 */ u32 mDrawMode;
|
||||
/* 0x054 */ u32 mMaterialMode;
|
||||
/* 0x058 */ J3DTexture* mTexture;
|
||||
/* 0x05C */ u8 unk_0x5c[0x60 - 0x5C];
|
||||
/* 0x060 */ u32 mTexCacheRegionNum;
|
||||
/* 0x064 */ GXTexRegion mTexCacheRegion[8];
|
||||
/* 0x0E4 */ u8 unk_0xe4[0x104 - 0xE4];
|
||||
/* 0x104 */ Mtx* mModelDrawMtx;
|
||||
/* 0x108 */ Mtx33* mModelNrmMtx;
|
||||
/* 0x10C */ void* mVtxPos;
|
||||
/* 0x110 */ void* mVtxNrm;
|
||||
/* 0x114 */ GXColor* mVtxCol;
|
||||
/* 0x118 */ Vec* mNBTScale;
|
||||
|
||||
J3DSys();
|
||||
void loadPosMtxIndx(int, u16) const;
|
||||
void loadNrmMtxIndx(int, u16) const;
|
||||
void setTexCacheRegion(GXTexCacheSize);
|
||||
void drawInit();
|
||||
void reinitGX();
|
||||
void reinitGenMode();
|
||||
void reinitLighting();
|
||||
void reinitTransform();
|
||||
void reinitTexture();
|
||||
void reinitTevStages();
|
||||
void reinitIndStages();
|
||||
void reinitPixelProc();
|
||||
|
||||
enum J3DSysDrawMode {
|
||||
J3DSysDrawMode_OpaTexEdge = 3,
|
||||
J3DSysDrawMode_Xlu
|
||||
};
|
||||
|
||||
MtxP getViewMtx() { return mViewMtx; }
|
||||
|
||||
void setDrawModeOpaTexEdge() { mDrawMode = J3DSysDrawMode_OpaTexEdge; }
|
||||
void setDrawModeXlu() { mDrawMode = J3DSysDrawMode_Xlu; }
|
||||
|
||||
void setDrawBuffer(J3DDrawBuffer* buffer, int type) {
|
||||
J3D_ASSERT_RANGE(114, type >= 0 && type < J3DSysDrawBuf_MAX);
|
||||
J3D_ASSERT_NULLPTR(115, buffer);
|
||||
mDrawBuffer[type] = buffer;
|
||||
}
|
||||
|
||||
J3DDrawBuffer* getDrawBuffer(int type) {
|
||||
J3D_ASSERT_RANGE(121, type >= 0 && type < J3DSysDrawBuf_MAX);
|
||||
return mDrawBuffer[type];
|
||||
}
|
||||
|
||||
void setMatPacket(J3DMatPacket* pPacket) {
|
||||
J3D_ASSERT_NULLPTR(162, pPacket != NULL);
|
||||
mMatPacket = pPacket;
|
||||
}
|
||||
|
||||
void setShapePacket(J3DShapePacket* pPacket) {
|
||||
J3D_ASSERT_NULLPTR(172, pPacket != NULL);
|
||||
mShapePacket = pPacket;
|
||||
}
|
||||
|
||||
void setModel(J3DModel* pModel) {
|
||||
J3D_ASSERT_NULLPTR(200, pModel != NULL);
|
||||
mModel = pModel;
|
||||
}
|
||||
|
||||
J3DMatPacket* getMatPacket() { return mMatPacket; }
|
||||
void setMaterialMode(u32 mode) { mMaterialMode = mode; }
|
||||
|
||||
void setCurrentMtxCalc(J3DMtxCalc * pCalc) {
|
||||
J3D_ASSERT_NULLPTR(210, pCalc != NULL);
|
||||
mCurrentMtxCalc = pCalc;
|
||||
}
|
||||
|
||||
J3DMtxCalc * getCurrentMtxCalc() const { return mCurrentMtxCalc; }
|
||||
|
||||
void setTexture(J3DTexture* pTex) {
|
||||
JUT_ASSERT_MSG(220, pTex != NULL, "Error : null pointer.");
|
||||
mTexture = pTex;
|
||||
}
|
||||
J3DTexture* getTexture() { return mTexture; }
|
||||
|
||||
void setNBTScale(Vec* scale) { mNBTScale = scale; }
|
||||
Vec* getNBTScale() { return mNBTScale; }
|
||||
|
||||
void onFlag(u32 flag) { mFlags |= flag; }
|
||||
|
||||
void offFlag(u32 flag) { mFlags &= ~flag; }
|
||||
|
||||
bool checkFlag(u32 flag) { return mFlags & flag ? true : false; }
|
||||
|
||||
void setModelDrawMtx(Mtx* pMtxArr) {
|
||||
J3D_ASSERT_NULLPTR(230, pMtxArr);
|
||||
mModelDrawMtx = pMtxArr;
|
||||
GXSetArray(GX_POS_MTX_ARRAY, mModelDrawMtx, sizeof(*mModelDrawMtx));
|
||||
}
|
||||
|
||||
void setModelNrmMtx(Mtx33* pMtxArr) {
|
||||
J3D_ASSERT_NULLPTR(241, pMtxArr);
|
||||
mModelNrmMtx = pMtxArr;
|
||||
GXSetArray(GX_NRM_MTX_ARRAY, mModelNrmMtx, sizeof(*mModelNrmMtx));
|
||||
}
|
||||
|
||||
void* getVtxPos() { return mVtxPos; }
|
||||
|
||||
void setVtxPos(void* pVtxPos) {
|
||||
J3D_ASSERT_NULLPTR(252, pVtxPos != NULL);
|
||||
mVtxPos = pVtxPos;
|
||||
}
|
||||
|
||||
void* getVtxNrm() { return mVtxNrm; }
|
||||
void setVtxNrm(void* pVtxNrm) { mVtxNrm = pVtxNrm; }
|
||||
|
||||
void* getVtxCol() { return mVtxCol; }
|
||||
void setVtxCol(GXColor* pVtxCol) { mVtxCol = pVtxCol; }
|
||||
|
||||
Mtx& getModelDrawMtx(u16 no) { return mModelDrawMtx[no]; }
|
||||
J3DShapePacket* getShapePacket() { return mShapePacket; }
|
||||
|
||||
void setViewMtx(const Mtx m) { MTXCopy(m, mViewMtx); }
|
||||
|
||||
J3DModel* getModel() { return mModel; }
|
||||
|
||||
static Mtx mCurrentMtx;
|
||||
static Vec mCurrentS;
|
||||
static Vec mParentS;
|
||||
static J3DTexCoordScaleInfo sTexCoordScaleTable[8];
|
||||
};
|
||||
|
||||
extern u32 j3dDefaultViewNo;
|
||||
extern J3DSys j3dSys;
|
||||
|
||||
#endif /* J3DSYS_H */
|
||||
@@ -0,0 +1,310 @@
|
||||
#ifndef J3DTEVS_H
|
||||
#define J3DTEVS_H
|
||||
|
||||
#include <types.h>
|
||||
#include <gx.h>
|
||||
#include "JSystem/J3DGraphBase/J3DGD.h"
|
||||
#include "JSystem/J3DGraphBase/J3DStruct.h"
|
||||
|
||||
extern u8 j3dTevSwapTableTable[1024];
|
||||
|
||||
extern const J3DLightInfo j3dDefaultLightInfo;
|
||||
extern const J3DTexCoordInfo j3dDefaultTexCoordInfo[8];
|
||||
extern const J3DTexMtxInfo j3dDefaultTexMtxInfo;
|
||||
extern const J3DIndTexMtxInfo j3dDefaultIndTexMtxInfo;
|
||||
extern const J3DTevStageInfo j3dDefaultTevStageInfo;
|
||||
extern const J3DIndTevStageInfo j3dDefaultIndTevStageInfo;
|
||||
extern const J3DFogInfo j3dDefaultFogInfo;
|
||||
extern const J3DNBTScaleInfo j3dDefaultNBTScaleInfo;
|
||||
|
||||
extern const GXColor j3dDefaultColInfo;
|
||||
extern const GXColor j3dDefaultAmbInfo;
|
||||
extern const u8 j3dDefaultColorChanNum;
|
||||
extern const J3DTevOrderInfo j3dDefaultTevOrderInfoNull;
|
||||
extern const J3DIndTexOrderInfo j3dDefaultIndTexOrderNull;
|
||||
extern const GXColorS10 j3dDefaultTevColor;
|
||||
extern const J3DIndTexCoordScaleInfo j3dDefaultIndTexCoordScaleInfo;
|
||||
extern const GXColor j3dDefaultTevKColor;
|
||||
extern const J3DTevSwapModeInfo j3dDefaultTevSwapMode;
|
||||
extern const J3DTevSwapModeTableInfo j3dDefaultTevSwapModeTable;
|
||||
extern const J3DBlendInfo j3dDefaultBlendInfo;
|
||||
extern const J3DColorChanInfo j3dDefaultColorChanInfo;
|
||||
extern const u8 j3dDefaultTevSwapTableID;
|
||||
extern const u16 j3dDefaultAlphaCmpID;
|
||||
extern const u16 j3dDefaultZModeID;
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DTevStage {
|
||||
J3DTevStage() {
|
||||
setTevStageInfo(j3dDefaultTevStageInfo);
|
||||
setTevSwapModeInfo(j3dDefaultTevSwapMode);
|
||||
}
|
||||
|
||||
void setTevColorOp(u8 param_1, u8 param_2, u8 param_3, u8 param_4, u8 param_5) {
|
||||
mTevColorOp = mTevColorOp & ~(0x01 << 2) | param_1 << 2;
|
||||
if (param_1 <= 1) {
|
||||
mTevColorOp = mTevColorOp & ~(0x03 << 4) | param_3 << 4;
|
||||
mTevColorOp = mTevColorOp & ~0x03 | param_2;
|
||||
} else {
|
||||
mTevColorOp = mTevColorOp & ~(0x03 << 4) | (param_1 >> 1 & 3) << 4;
|
||||
mTevColorOp = mTevColorOp & ~0x03 | 3;
|
||||
}
|
||||
mTevColorOp = mTevColorOp & ~(0x01 << 3) | param_4 << 3;
|
||||
mTevColorOp = mTevColorOp & ~(0x03 << 6) | param_5 << 6;
|
||||
}
|
||||
|
||||
void setTevColorAB(u8 a, u8 b) { mTevColorAB = a << 4 | b; }
|
||||
void setTevColorCD(u8 c, u8 d) { mTevColorCD = c << 4 | d; }
|
||||
void setAlphaA(u8 a) { mTevAlphaAB = mTevAlphaAB & ~(0x07 << 5) | a << 5; }
|
||||
void setAlphaB(u8 b) { mTevAlphaAB = mTevAlphaAB & ~(0x07 << 2) | b << 2; }
|
||||
void setAlphaC(u8 c) {
|
||||
mTevAlphaAB = mTevAlphaAB & ~0x03 | c >> 1;
|
||||
mTevSwapModeInfo = mTevSwapModeInfo & ~(0x01 << 7) | c << 7;
|
||||
}
|
||||
void setAlphaD(u8 d) { mTevSwapModeInfo = mTevSwapModeInfo & ~(0x07 << 4) | d << 4; }
|
||||
void setAlphaABCD(u8 a, u8 b, u8 c, u8 d) {
|
||||
setAlphaA(a);
|
||||
setAlphaB(b);
|
||||
setAlphaC(c);
|
||||
setAlphaD(d);
|
||||
}
|
||||
|
||||
void setTevAlphaOp(u8 param_1, u8 param_2, u8 param_3, u8 param_4, u8 param_5) {
|
||||
mTevAlphaOp = mTevAlphaOp & ~(0x01 << 2) | param_1 << 2;
|
||||
if (param_1 <= 1) {
|
||||
mTevAlphaOp = mTevAlphaOp & ~0x03 | param_2;
|
||||
mTevAlphaOp = mTevAlphaOp & ~(0x03 << 4) | param_3 << 4;
|
||||
} else {
|
||||
mTevAlphaOp = mTevAlphaOp & ~(0x03 << 4) | (param_1 >> 1 & 3) << 4;
|
||||
mTevAlphaOp = mTevAlphaOp & ~0x03 | 3;
|
||||
}
|
||||
mTevAlphaOp = mTevAlphaOp & ~(0x01 << 3) | param_4 << 3;
|
||||
mTevAlphaOp = mTevAlphaOp & ~(0x03 << 6) | param_5 << 6;
|
||||
}
|
||||
|
||||
void setTevStageInfo(const J3DTevStageInfo& info) {
|
||||
setTevColorOp(info.mTevAlphaOp, info.mTevAlphaAB, info.mTevSwapModeInfo, info.field_0x8, info.field_0x9);
|
||||
setTevColorAB(info.mTevColorOp, info.mTevColorAB);
|
||||
setTevColorCD(info.mTevColorCD, info.field_0x4);
|
||||
setAlphaABCD(info.field_0xa, info.field_0xb, info.field_0xc, info.field_0xd);
|
||||
setTevAlphaOp(info.field_0xe, info.field_0xf, info.field_0x10, info.field_0x11, info.field_0x12);
|
||||
}
|
||||
|
||||
J3DTevStage(J3DTevStageInfo const& param_0) {
|
||||
setTevStageInfo(param_0);
|
||||
setTevSwapModeInfo(j3dDefaultTevSwapMode);
|
||||
}
|
||||
|
||||
void setTevSwapModeInfo(J3DTevSwapModeInfo const& param_0) {
|
||||
setTexSel(param_0.mTexSel);
|
||||
setRasSel(param_0.mRasSel);
|
||||
}
|
||||
|
||||
void setStageNo(u32 param_0) {
|
||||
field_0x0 = 0xC0 + param_0 * 2;
|
||||
field_0x4 = 0xC1 + param_0 * 2;
|
||||
}
|
||||
|
||||
void setRasSel(u8 ras_sel) { mTevSwapModeInfo = (mTevSwapModeInfo & ~3) | ras_sel; }
|
||||
void setTexSel(u8 tex_sel) { mTevSwapModeInfo = (mTevSwapModeInfo & ~0xc) | (tex_sel << 2); }
|
||||
|
||||
void load(u32 param_1) const {
|
||||
J3DGDWriteBPCmd(*(u32*)&field_0x0);
|
||||
J3DGDWriteBPCmd(*(u32*)&field_0x4);
|
||||
}
|
||||
|
||||
J3DTevStage& operator=(const J3DTevStage& other) {
|
||||
mTevColorOp = other.mTevColorOp;
|
||||
mTevColorAB = other.mTevColorAB;
|
||||
mTevColorCD = other.mTevColorCD;
|
||||
mTevAlphaOp = other.mTevAlphaOp;
|
||||
mTevAlphaAB = other.mTevAlphaAB;
|
||||
mTevSwapModeInfo = other.mTevSwapModeInfo;
|
||||
return *this;
|
||||
}
|
||||
|
||||
J3DTevStage& operator=(J3DTevStage& other) {
|
||||
mTevColorOp = other.mTevColorOp;
|
||||
mTevColorAB = other.mTevColorAB;
|
||||
mTevColorCD = other.mTevColorCD;
|
||||
mTevAlphaOp = other.mTevAlphaOp;
|
||||
mTevAlphaAB = other.mTevAlphaAB;
|
||||
mTevSwapModeInfo = other.mTevSwapModeInfo;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/* 0x0 */ u8 field_0x0;
|
||||
/* 0x1 */ u8 mTevColorOp;
|
||||
/* 0x2 */ u8 mTevColorAB;
|
||||
/* 0x3 */ u8 mTevColorCD;
|
||||
/* 0x4 */ u8 field_0x4;
|
||||
/* 0x5 */ u8 mTevAlphaOp;
|
||||
/* 0x6 */ u8 mTevAlphaAB;
|
||||
/* 0x7 */ u8 mTevSwapModeInfo;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DIndTevStage {
|
||||
J3DIndTevStage() : mInfo(0) { setIndTevStageInfo(j3dDefaultIndTevStageInfo); }
|
||||
J3DIndTevStage(J3DIndTevStageInfo const& info) : mInfo(0) { setIndTevStageInfo(info); }
|
||||
void setIndTevStageInfo(J3DIndTevStageInfo const& info) {
|
||||
setIndStage(info.mIndStage);
|
||||
setIndFormat(info.mIndFormat);
|
||||
setBiasSel(info.mBiasSel);
|
||||
setMtxSel(info.mMtxSel);
|
||||
setWrapS(info.mWrapS);
|
||||
setWrapT(info.mWrapT);
|
||||
setPrev(info.mPrev);
|
||||
setLod(info.mLod);
|
||||
setAlphaSel(info.mAlphaSel);
|
||||
}
|
||||
void setIndStage(u8 indStage) { mInfo = (mInfo & ~3) | indStage; }
|
||||
void setIndFormat(u8 indFormat) { mInfo = (mInfo & ~0xc) | (indFormat << 2); }
|
||||
void setBiasSel(u8 biasSel) { mInfo = (mInfo & ~0x70) | (biasSel << 4); }
|
||||
void setMtxSel(u8 mtxSel) { mInfo = (mInfo & ~0x1e00) | (mtxSel << 9); }
|
||||
void setWrapS(u8 wrapS) { mInfo = (mInfo & ~0xe000) | (wrapS << 13); }
|
||||
void setWrapT(u8 wrapT) { mInfo = (mInfo & ~0x70000) | (wrapT << 16); }
|
||||
void setPrev(u8 prev) { mInfo = (mInfo & ~0x100000) | (prev << 20); }
|
||||
void setLod(u8 lod) { mInfo = (mInfo & ~0x80000) | (lod << 19); }
|
||||
void setAlphaSel(u8 alphaSel) { mInfo = (mInfo & ~0x180) | (alphaSel << 7); }
|
||||
|
||||
void load(u32 param_1) const {
|
||||
J3DGDWriteBPCmd(mInfo | (param_1 + 0x10) * 0x1000000);
|
||||
}
|
||||
|
||||
J3DIndTevStage& operator=(const J3DIndTevStage& other) {
|
||||
mInfo = other.mInfo;
|
||||
return *this;
|
||||
}
|
||||
|
||||
J3DIndTevStage& operator=(J3DIndTevStage& other) {
|
||||
mInfo = other.mInfo;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/* 0x0 */ u32 mInfo;
|
||||
};
|
||||
|
||||
extern const J3DTevOrderInfo j3dDefaultTevOrderInfoNull;
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DTevOrder : public J3DTevOrderInfo {
|
||||
J3DTevOrder() {
|
||||
J3DTevOrderInfo::operator=(j3dDefaultTevOrderInfoNull);
|
||||
}
|
||||
J3DTevOrder(const J3DTevOrderInfo& info) {
|
||||
J3DTevOrderInfo::operator=(info);
|
||||
}
|
||||
J3DTevOrderInfo& getTevOrderInfo() { return *this; }
|
||||
|
||||
u8 getTexMap() const { return mTexMap; }
|
||||
};
|
||||
|
||||
extern u8 j3dTevSwapTableTable[1024];
|
||||
extern u8 const j3dDefaultTevSwapTableID;
|
||||
|
||||
inline u8 calcTevSwapTableID(u8 param_0, u8 param_1, u8 param_2, u8 param_3) {
|
||||
return 0x40 * (u8)param_0 + 0x10 * (u8)param_1 + 4 * (u8)param_2 + param_3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DTevSwapModeTable {
|
||||
J3DTevSwapModeTable() { mIdx = j3dDefaultTevSwapTableID; }
|
||||
J3DTevSwapModeTable(J3DTevSwapModeTableInfo const& info) {
|
||||
mIdx = calcTevSwapTableID(info.field_0x0, info.field_0x1, info.field_0x2, info.field_0x3);
|
||||
}
|
||||
|
||||
J3DTevSwapModeTable& operator=(const J3DTevSwapModeTable& rhs) {
|
||||
mIdx = rhs.mIdx;
|
||||
return *this;
|
||||
}
|
||||
|
||||
J3DTevSwapModeTable& operator=(J3DTevSwapModeTable& other) {
|
||||
mIdx = other.mIdx;
|
||||
return *this;
|
||||
}
|
||||
|
||||
u8 getR() const { return *(&j3dTevSwapTableTable[mIdx * 4] + 0); }
|
||||
u8 getG() const { return *(&j3dTevSwapTableTable[mIdx * 4] + 1); }
|
||||
u8 getB() const { return *(&j3dTevSwapTableTable[mIdx * 4] + 2); }
|
||||
u8 getA() const { return *(&j3dTevSwapTableTable[mIdx * 4] + 3); }
|
||||
|
||||
/* 0x0 */ u8 mIdx;
|
||||
}; // Size: 0x1
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DLightObj {
|
||||
public:
|
||||
J3DLightObj() { mInfo = j3dDefaultLightInfo; }
|
||||
void load(u32) const;
|
||||
|
||||
J3DLightInfo* getLightInfo() { return &mInfo; }
|
||||
J3DLightObj& operator=(J3DLightObj const& other) {
|
||||
mInfo = other.mInfo;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/* 0x00 */ J3DLightInfo mInfo;
|
||||
/* 0x34 */ GXLightObj mLightObj;
|
||||
}; // Size = 0x74
|
||||
|
||||
extern const J3DNBTScaleInfo j3dDefaultNBTScaleInfo;
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DNBTScale : public J3DNBTScaleInfo {
|
||||
J3DNBTScale() {
|
||||
mbHasScale = j3dDefaultNBTScaleInfo.mbHasScale;
|
||||
mScale.x = j3dDefaultNBTScaleInfo.mScale.x;
|
||||
mScale.y = j3dDefaultNBTScaleInfo.mScale.y;
|
||||
mScale.z = j3dDefaultNBTScaleInfo.mScale.z;
|
||||
}
|
||||
|
||||
J3DNBTScale(J3DNBTScaleInfo const& info) {
|
||||
mbHasScale = info.mbHasScale;
|
||||
mScale.x = info.mScale.x;
|
||||
mScale.y = info.mScale.y;
|
||||
mScale.z = info.mScale.z;
|
||||
}
|
||||
|
||||
Vec* getScale() { return &mScale; }
|
||||
};
|
||||
|
||||
extern const GXColor j3dDefaultColInfo;
|
||||
extern const GXColor j3dDefaultAmbInfo;
|
||||
extern const GXColorS10 j3dDefaultTevColor;
|
||||
extern const GXColor j3dDefaultTevKColor;
|
||||
extern u8 j3dAlphaCmpTable[768];
|
||||
extern const u8 j3dDefaultNumChans;
|
||||
|
||||
struct J3DNBTScale;
|
||||
struct J3DTexCoord;
|
||||
void loadNBTScale(J3DNBTScale& param_0);
|
||||
void loadTexCoordGens(u32 param_0, J3DTexCoord* param_1);
|
||||
void loadTexNo(u32 param_0, u16 const& param_1);
|
||||
void patchTexNo_PtrToIdx(u32 texID, u16 const& idx);
|
||||
bool isTexNoReg(void* param_0);
|
||||
u16 getTexNoReg(void* param_0);
|
||||
void makeTexCoordTable();
|
||||
void makeAlphaCmpTable();
|
||||
void makeZModeTable();
|
||||
void makeTevSwapTable();
|
||||
|
||||
#endif /* J3DTEVS_H */
|
||||
@@ -0,0 +1,119 @@
|
||||
#ifndef J3DTEXTURE_H
|
||||
#define J3DTEXTURE_H
|
||||
|
||||
#include "JSystem/J3DGraphBase/J3DStruct.h"
|
||||
#include "JSystem/J3DAssert.h"
|
||||
#include "JSystem/JUtility/JUTTexture.h"
|
||||
#include "global.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DTexture {
|
||||
private:
|
||||
/* 0x0 */ u16 mNum;
|
||||
/* 0x2 */ u16 unk_0x2;
|
||||
/* 0x4 */ ResTIMG* mpRes;
|
||||
|
||||
public:
|
||||
J3DTexture(u16 num, ResTIMG* res) : mNum(num), unk_0x2(0), mpRes(res) {
|
||||
J3D_ASSERT_NULLPTR(52, res != NULL || num == 0);
|
||||
}
|
||||
|
||||
void loadGX(u16, GXTexMapID) const;
|
||||
void entryNum(u16);
|
||||
void addResTIMG(u16, ResTIMG const*);
|
||||
virtual ~J3DTexture() {}
|
||||
|
||||
u16 getNum() const { return mNum; }
|
||||
|
||||
ResTIMG* getResTIMG(u16 index) const {
|
||||
J3D_ASSERT_RANGE(72, index < mNum);
|
||||
return &mpRes[index];
|
||||
}
|
||||
|
||||
void setResTIMG(u16 index, const ResTIMG& timg) {
|
||||
J3D_ASSERT_RANGE(81, index < mNum);
|
||||
mpRes[index] = timg;
|
||||
mpRes[index].imageOffset = ((mpRes[index].imageOffset + (uintptr_t)&timg - (uintptr_t)(mpRes + index)));
|
||||
mpRes[index].paletteOffset = ((mpRes[index].paletteOffset + (uintptr_t)&timg - (uintptr_t)(mpRes + index)));
|
||||
}
|
||||
};
|
||||
|
||||
extern J3DTexMtxInfo const j3dDefaultTexMtxInfo;
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DTexMtx {
|
||||
public:
|
||||
J3DTexMtx() {
|
||||
mTexMtxInfo = j3dDefaultTexMtxInfo;
|
||||
}
|
||||
|
||||
J3DTexMtx(const J3DTexMtxInfo& info) {
|
||||
mTexMtxInfo = info;
|
||||
}
|
||||
|
||||
void load(u32) const;
|
||||
void calc(const Mtx);
|
||||
void calcTexMtx(const Mtx);
|
||||
void calcPostTexMtx(const Mtx);
|
||||
void loadTexMtx(u32) const;
|
||||
void loadPostTexMtx(u32) const;
|
||||
|
||||
J3DTexMtxInfo& getTexMtxInfo() { return mTexMtxInfo; }
|
||||
Mtx& getMtx() { return mMtx; }
|
||||
void setEffectMtx(Mtx effectMtx) { mTexMtxInfo.setEffectMtx(effectMtx); }
|
||||
|
||||
private:
|
||||
/* 0x00 */ J3DTexMtxInfo mTexMtxInfo;
|
||||
/* 0x64 */ Mtx mMtx;
|
||||
}; // Size: 0x94
|
||||
|
||||
extern J3DTexCoordInfo const j3dDefaultTexCoordInfo[8];
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DTexCoord : public J3DTexCoordInfo {
|
||||
J3DTexCoord() {
|
||||
J3DTexCoordInfo::operator=(j3dDefaultTexCoordInfo[0]);
|
||||
mTexMtxReg = mTexGenMtx;
|
||||
}
|
||||
J3DTexCoord(const J3DTexCoordInfo& info) {
|
||||
J3DTexCoordInfo::operator=(info);
|
||||
mTexMtxReg = mTexGenMtx;
|
||||
}
|
||||
void setTexCoordInfo(const J3DTexCoordInfo& info) {
|
||||
J3DTexCoordInfo::operator=(info);
|
||||
}
|
||||
|
||||
u8 getTexGenType() const { return mTexGenType; }
|
||||
u8 getTexGenSrc() const { return mTexGenSrc; }
|
||||
u8 getTexGenMtx() const { return mTexGenMtx; }
|
||||
u32 getTexMtxReg() const { return mTexMtxReg & 0xff; }
|
||||
void setTexGenMtx(u8 param_1) { mTexGenMtx = param_1; }
|
||||
void setTexMtxReg(u16 reg) { mTexMtxReg = reg; }
|
||||
J3DTexCoord& operator=(const J3DTexCoord& other) {
|
||||
#if DEBUG
|
||||
J3DTexCoordInfo::operator=(other);
|
||||
#else
|
||||
// Fakematch: Instruction order is wrong with __memcpy or J3DTexCoordInfo::operator=
|
||||
*(u32*)this = *(u32*)&other;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
void resetTexMtxReg() {
|
||||
mTexMtxReg = mTexGenMtx;
|
||||
}
|
||||
|
||||
/* 0x4 */ u16 mTexMtxReg;
|
||||
}; // Size: 0x6
|
||||
|
||||
#endif /* J3DTEXTURE_H */
|
||||
@@ -0,0 +1,231 @@
|
||||
#ifndef J3DTRANSFORM_H
|
||||
#define J3DTRANSFORM_H
|
||||
|
||||
#include <mtx.h>
|
||||
|
||||
struct J3DTextureSRTInfo;
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
|
||||
struct J3DTransformInfo {
|
||||
/* 0x00 */ Vec mScale;
|
||||
/* 0x0C */ S16Vec mRotation;
|
||||
/* 0x14 */ Vec mTranslate;
|
||||
|
||||
/* inline J3DTransformInfo& operator=(const J3DTransformInfo& b) {
|
||||
mScale = b.mScale;
|
||||
mRotation = b.mRotation;
|
||||
mTranslate = b.mTranslate;
|
||||
return *this;
|
||||
} */
|
||||
|
||||
#ifdef __MWERKS__
|
||||
inline J3DTransformInfo& operator=(const __REGISTER J3DTransformInfo& b) {
|
||||
__REGISTER const J3DTransformInfo& var_r31 = b;
|
||||
__REGISTER J3DTransformInfo& var_r30 = *this;
|
||||
__REGISTER f32 var_f31;
|
||||
asm {
|
||||
psq_l var_f31, J3DTransformInfo.mScale(var_r31), 0, 0
|
||||
psq_st var_f31, J3DTransformInfo.mScale(var_r30), 0, 0
|
||||
}
|
||||
mScale.z = b.mScale.z;
|
||||
*(u32*)&mRotation = *(u32*)&b.mRotation;
|
||||
mRotation.z = b.mRotation.z;
|
||||
asm {
|
||||
psq_l var_f31, J3DTransformInfo.mTranslate(var_r31), 0, 0
|
||||
psq_st var_f31, J3DTransformInfo.mTranslate(var_r30), 0, 0
|
||||
}
|
||||
mTranslate.z = b.mTranslate.z;
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
}; // Size: 0x20
|
||||
|
||||
extern J3DTransformInfo const j3dDefaultTransformInfo;
|
||||
extern Vec const j3dDefaultScale;
|
||||
extern Mtx const j3dDefaultMtx;
|
||||
extern f32 const PSMulUnit01[];
|
||||
|
||||
void J3DGQRSetup7(u32 param_0, u32 param_1, u32 param_2, u32 param_3);
|
||||
void J3DCalcBBoardMtx(f32 (*)[4]);
|
||||
void J3DCalcYBBoardMtx(f32 (*)[4]);
|
||||
void J3DPSCalcInverseTranspose(f32 (*param_0)[4], f32 (*param_1)[3]);
|
||||
void J3DGetTranslateRotateMtx(const J3DTransformInfo&, Mtx);
|
||||
void J3DGetTranslateRotateMtx(s16, s16, s16, f32, f32, f32, Mtx);
|
||||
void J3DGetTextureMtx(const J3DTextureSRTInfo&, const Vec&, f32 (*)[4]);
|
||||
void J3DGetTextureMtxOld(const J3DTextureSRTInfo&, const Vec&, f32 (*)[4]);
|
||||
void J3DGetTextureMtxMaya(const J3DTextureSRTInfo&, f32 (*)[4]);
|
||||
void J3DGetTextureMtxMayaOld(const J3DTextureSRTInfo& param_0, f32 (*)[4]);
|
||||
void J3DScaleNrmMtx(f32 (*)[4], const Vec&);
|
||||
void J3DScaleNrmMtx33(f32 (*)[3], const Vec&);
|
||||
void J3DMtxProjConcat(f32 (*)[4], f32 (*)[4], f32 (*)[4]);
|
||||
void J3DPSMtxArrayConcat(f32 (*)[4], f32 (*)[4], f32 (*)[4], u32);
|
||||
|
||||
inline void J3DPSMtx33Copy(__REGISTER Mtx3P src, __REGISTER Mtx3P dst) {
|
||||
#ifdef __MWERKS__
|
||||
__REGISTER f32 fr4;
|
||||
__REGISTER f32 fr3;
|
||||
__REGISTER f32 fr2;
|
||||
__REGISTER f32 fr1;
|
||||
__REGISTER f32 fr0;
|
||||
|
||||
asm {
|
||||
psq_l fr4, 0(src), 0, 0
|
||||
psq_l fr3, 8(src), 0, 0
|
||||
psq_l fr2, 0x10(src), 0, 0
|
||||
psq_l fr1, 0x18(src), 0, 0
|
||||
lfs fr0, 0x20(src)
|
||||
psq_st fr4, 0(dst), 0, 0
|
||||
psq_st fr3, 8(dst), 0, 0
|
||||
psq_st fr2, 0x10(dst), 0, 0
|
||||
psq_st fr1, 0x18(dst), 0, 0
|
||||
stfs fr0, 0x20(dst)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void J3DPSMtx33CopyFrom34(__REGISTER MtxP src, __REGISTER Mtx3P dst) {
|
||||
#ifdef __MWERKS__
|
||||
__REGISTER f32 x_y1;
|
||||
__REGISTER f32 z1;
|
||||
__REGISTER f32 x_y2;
|
||||
__REGISTER f32 z2;
|
||||
__REGISTER f32 x_y3;
|
||||
__REGISTER f32 z3;
|
||||
asm {
|
||||
psq_l x_y1, 0(src), 0, 0
|
||||
lfs z1, 8(src)
|
||||
psq_l x_y2, 16(src), 0, 0
|
||||
lfs z2, 0x18(src)
|
||||
psq_l x_y3, 32(src), 0, 0
|
||||
lfs z3, 0x28(src)
|
||||
psq_st x_y1, 0(dst), 0, 0
|
||||
stfs z1, 8(dst)
|
||||
psq_st x_y2, 12(dst), 0, 0
|
||||
stfs z2, 0x14(dst)
|
||||
psq_st x_y3, 24(dst), 0, 0
|
||||
stfs z3, 0x20(dst)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void J3DPSMulMtxVec(__REGISTER MtxP mtx, __REGISTER Vec* vec, __REGISTER Vec* dst) {
|
||||
#ifdef __MWERKS__
|
||||
asm {
|
||||
psq_l f0, 0(vec), 0, 0
|
||||
psq_l f2, 0(mtx), 0, 0
|
||||
psq_l f1, 8(vec), 1, 0
|
||||
ps_mul f4, f2, f0
|
||||
psq_l f3, 8(mtx), 0, 0
|
||||
ps_madd f5, f3, f1, f4
|
||||
psq_l f8, 16(mtx), 0, 0
|
||||
ps_sum0 f6, f5, f6, f5
|
||||
psq_l f9, 24(mtx), 0, 0
|
||||
ps_mul f10, f8, f0
|
||||
psq_st f6, 0(dst), 1, 0
|
||||
ps_madd f11, f9, f1, f10
|
||||
psq_l f2, 32(mtx), 0, 0
|
||||
ps_sum0 f12, f11, f12, f11
|
||||
psq_l f3, 40(mtx), 0, 0
|
||||
ps_mul f4, f2, f0
|
||||
psq_st f12, 4(dst), 1, 0
|
||||
ps_madd f5, f3, f1, f4
|
||||
ps_sum0 f6, f5, f6, f5
|
||||
psq_st f6, 8(dst), 1, 0
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void J3DPSMulMtxVec(__REGISTER MtxP mtx, __REGISTER S16Vec* vec, __REGISTER S16Vec* dst) {
|
||||
#ifdef __MWERKS__
|
||||
asm {
|
||||
psq_l f0, 0(vec), 0, 7
|
||||
psq_l f2, 0(mtx), 0, 0
|
||||
psq_l f1, 4(vec), 1, 7
|
||||
ps_mul f4, f2, f0
|
||||
psq_l f3, 8(mtx), 0, 0
|
||||
ps_madd f5, f3, f1, f4
|
||||
psq_l f8, 16(mtx), 0, 0
|
||||
ps_sum0 f6, f5, f6, f5
|
||||
psq_l f9, 24(mtx), 0, 0
|
||||
ps_mul f10, f8, f0
|
||||
psq_st f6, 0(dst), 1, 7
|
||||
ps_madd f11, f9, f1, f10
|
||||
psq_l f2, 32(mtx), 0, 0
|
||||
ps_sum0 f12, f11, f12, f11
|
||||
psq_l f3, 40(mtx), 0, 0
|
||||
ps_mul f4, f2, f0
|
||||
psq_st f12, 2(dst), 1, 7
|
||||
ps_madd f5, f3, f1, f4
|
||||
ps_sum0 f6, f5, f6, f5
|
||||
psq_st f6, 4(dst), 1, 7
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void J3DPSMulMtxVec(__REGISTER Mtx3P mtx, __REGISTER Vec* vec, __REGISTER Vec* dst) {
|
||||
#ifdef __MWERKS__
|
||||
asm {
|
||||
lis r6, PSMulUnit01@ha
|
||||
psq_l f0, 0(vec), 0, 0
|
||||
addi r6, r6, PSMulUnit01@l
|
||||
psq_l f2, 0(mtx), 0, 0
|
||||
psq_l f13, 0(r6), 0, 0
|
||||
psq_l f1, 8(vec), 1, 0
|
||||
ps_add f1, f13, f1
|
||||
psq_l f3, 8(mtx), 1, 0
|
||||
ps_mul f4, f2, f0
|
||||
psq_l f8, 12(mtx), 0, 0
|
||||
ps_madd f5, f3, f1, f4
|
||||
ps_sum0 f6, f5, f6, f5
|
||||
psq_l f9, 20(mtx), 1, 0
|
||||
ps_mul f10, f8, f0
|
||||
psq_st f6, 0(dst), 1, 0
|
||||
ps_madd f11, f9, f1, f10
|
||||
psq_l f2, 24(mtx), 0, 0
|
||||
ps_sum0 f12, f11, f12, f11
|
||||
psq_l f3, 32(mtx), 1, 0
|
||||
ps_mul f4, f2, f0
|
||||
psq_st f12, 4(dst), 1, 0
|
||||
ps_madd f5, f3, f1, f4
|
||||
ps_sum0 f6, f5, f6, f5
|
||||
psq_st f6, 8(dst), 1, 0
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void J3DPSMulMtxVec(__REGISTER Mtx3P mtx, __REGISTER S16Vec* vec, __REGISTER S16Vec* dst) {
|
||||
#ifdef __MWERKS__
|
||||
asm {
|
||||
lis r6, PSMulUnit01@ha
|
||||
psq_l f0, 0(vec), 0, 7
|
||||
addi r6, r6, PSMulUnit01@l
|
||||
psq_l f2, 0(mtx), 0, 0
|
||||
psq_l f13, 0(r6), 0, 0
|
||||
psq_l f1, 4(vec), 1, 7
|
||||
ps_add f1, f13, f1
|
||||
psq_l f3, 8(mtx), 1, 0
|
||||
ps_mul f4, f2, f0
|
||||
psq_l f8, 12(mtx), 0, 0
|
||||
ps_madd f5, f3, f1, f4
|
||||
ps_sum0 f6, f5, f6, f5
|
||||
psq_l f9, 20(mtx), 1, 0
|
||||
ps_mul f10, f8, f0
|
||||
psq_st f6, 0(dst), 1, 7
|
||||
ps_madd f11, f9, f1, f10
|
||||
psq_l f2, 24(mtx), 0, 0
|
||||
ps_sum0 f12, f11, f12, f11
|
||||
psq_l f3, 32(mtx), 1, 0
|
||||
ps_mul f4, f2, f0
|
||||
psq_st f12, 2(dst), 1, 7
|
||||
ps_madd f5, f3, f1, f4
|
||||
ps_sum0 f6, f5, f6, f5
|
||||
psq_st f6, 4(dst), 1, 7
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* J3DTRANSFORM_H */
|
||||
@@ -0,0 +1,165 @@
|
||||
#ifndef J3DVERTEX_H
|
||||
#define J3DVERTEX_H
|
||||
|
||||
#include <gx.h>
|
||||
#include <mtx.h>
|
||||
|
||||
typedef struct _GXColor GXColor;
|
||||
class J3DModel;
|
||||
class J3DAnmVtxColor;
|
||||
class J3DVertexBuffer;
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
struct J3DVtxColorCalc {
|
||||
void calc(J3DModel*);
|
||||
virtual void calc(J3DVertexBuffer*);
|
||||
virtual ~J3DVtxColorCalc() {}
|
||||
|
||||
bool checkFlag(u32 flag) { return mFlags & flag ? true : false; }
|
||||
|
||||
/* 0x4 */ u32 mFlags;
|
||||
/* 0x8 */ J3DAnmVtxColor* mpVtxColor;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DVertexData {
|
||||
public:
|
||||
J3DVertexData();
|
||||
~J3DVertexData() {}
|
||||
|
||||
void* getVtxPosArray() const { return mVtxPosArray; }
|
||||
void* getVtxNrmArray() const { return mVtxNrmArray; }
|
||||
GXColor* getVtxColorArray(u8 idx) const { return mVtxColorArray[idx]; }
|
||||
void* getVtxTexCoordArray(u8 idx) const { return mVtxTexCoordArray[idx]; }
|
||||
void* getVtxNBTArray() const { return mVtxNBTArray; }
|
||||
u32 getNrmNum() const { return mNrmNum; }
|
||||
u32 getVtxNum() const { return mVtxNum; }
|
||||
u32 getColNum() const { return mColNum; }
|
||||
GXVtxAttrFmtList* getVtxAttrFmtList() const { return mVtxAttrFmtList; }
|
||||
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; }
|
||||
void setVtxNrmFrac(u8 frac) { mVtxNrmFrac = frac; }
|
||||
void setVtxNrmType(GXCompType type) { mVtxNrmType = type; }
|
||||
|
||||
private:
|
||||
friend class J3DModelLoader;
|
||||
|
||||
/* 0x00 */ u32 mVtxNum;
|
||||
/* 0x04 */ u32 mNrmNum;
|
||||
/* 0x08 */ u32 mColNum;
|
||||
/* 0x0C */ u32 mTexCoordNum;
|
||||
/* 0x10 */ u32 mPacketNum;
|
||||
/* 0x14 */ GXVtxAttrFmtList* mVtxAttrFmtList;
|
||||
/* 0x18 */ void* mVtxPosArray;
|
||||
/* 0x1C */ void* mVtxNrmArray;
|
||||
/* 0x20 */ void* mVtxNBTArray;
|
||||
/* 0x24 */ GXColor* mVtxColorArray[2];
|
||||
/* 0x2C */ void* mVtxTexCoordArray[8];
|
||||
/* 0x4C */ u8 mVtxPosFrac;
|
||||
/* 0x50 */ GXCompType mVtxPosType;
|
||||
/* 0x54 */ u8 mVtxNrmFrac;
|
||||
/* 0x58 */ GXCompType mVtxNrmType;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j3d
|
||||
*
|
||||
*/
|
||||
class J3DVertexBuffer {
|
||||
public:
|
||||
J3DVertexBuffer() { init(); }
|
||||
|
||||
void setVertexData(J3DVertexData*);
|
||||
void init();
|
||||
~J3DVertexBuffer();
|
||||
void setArray() const;
|
||||
s32 copyLocalVtxPosArray(u32);
|
||||
s32 copyLocalVtxNrmArray(u32);
|
||||
s32 copyLocalVtxArray(u32);
|
||||
s32 allocTransformedVtxPosArray();
|
||||
s32 allocTransformedVtxNrmArray();
|
||||
|
||||
void setCurrentVtxPos(void* pVtxPos) { mCurrentVtxPos = pVtxPos; }
|
||||
void* getCurrentVtxPos() { return mCurrentVtxPos; }
|
||||
|
||||
void setCurrentVtxNrm(void* pVtxNrm) { mCurrentVtxNrm = pVtxNrm; }
|
||||
void* getCurrentVtxNrm() { return mCurrentVtxNrm; }
|
||||
|
||||
void setCurrentVtxCol(GXColor* pVtxCol) { mCurrentVtxCol = pVtxCol; }
|
||||
|
||||
void frameInit() {
|
||||
setCurrentVtxPos(mVtxPosArray[0]);
|
||||
setCurrentVtxNrm(mVtxNrmArray[0]);
|
||||
setCurrentVtxCol(mVtxColArray[0]);
|
||||
}
|
||||
|
||||
void* getTransformedVtxPos(int idx) { return mTransformedVtxPosArray[idx]; }
|
||||
void* getTransformedVtxNrm(int idx) { return mTransformedVtxNrmArray[idx]; }
|
||||
J3DVertexData* getVertexData() const { return mVtxData; }
|
||||
|
||||
void swapTransformedVtxPos() {
|
||||
void* tmp = mTransformedVtxPosArray[0];
|
||||
mTransformedVtxPosArray[0] = mTransformedVtxPosArray[1];
|
||||
mTransformedVtxPosArray[1] = tmp;
|
||||
}
|
||||
|
||||
void swapTransformedVtxNrm() {
|
||||
void* tmp = mTransformedVtxNrmArray[0];
|
||||
mTransformedVtxNrmArray[0] = mTransformedVtxNrmArray[1];
|
||||
mTransformedVtxNrmArray[1] = tmp;
|
||||
}
|
||||
|
||||
void swapVtxPosArrayPointer() {
|
||||
void* temp = mVtxPosArray[0];
|
||||
mVtxPosArray[0] = mVtxPosArray[1];
|
||||
mVtxPosArray[1] = temp;
|
||||
}
|
||||
|
||||
void swapVtxNrmArrayPointer() {
|
||||
void* temp = mVtxNrmArray[0];
|
||||
mVtxNrmArray[0] = mVtxNrmArray[1];
|
||||
mVtxNrmArray[1] = temp;
|
||||
}
|
||||
|
||||
void swapVtxColArrayPointer() {
|
||||
GXColor* temp = mVtxColArray[0];
|
||||
mVtxColArray[0] = mVtxColArray[1];
|
||||
mVtxColArray[1] = temp;
|
||||
}
|
||||
|
||||
void* getVtxPosArrayPointer(int index) {
|
||||
return mVtxPosArray[index];
|
||||
}
|
||||
|
||||
void* getVtxNrmArrayPointer(int index) {
|
||||
return mVtxNrmArray[index];
|
||||
}
|
||||
|
||||
GXColor* getVtxColArrayPointer(int index) {
|
||||
return mVtxColArray[index];
|
||||
}
|
||||
|
||||
private:
|
||||
/* 0x00 */ J3DVertexData* mVtxData;
|
||||
/* 0x04 */ void* mVtxPosArray[2];
|
||||
/* 0x0C */ void* mVtxNrmArray[2];
|
||||
/* 0x14 */ GXColor* mVtxColArray[2];
|
||||
/* 0x1C */ void* mTransformedVtxPosArray[2];
|
||||
/* 0x24 */ void* mTransformedVtxNrmArray[2];
|
||||
/* 0x2C */ void* mCurrentVtxPos;
|
||||
/* 0x30 */ void* mCurrentVtxNrm;
|
||||
/* 0x34 */ GXColor* mCurrentVtxCol;
|
||||
}; // Size: 0x38
|
||||
|
||||
#endif /* J3DVERTEX_H */
|
||||
Reference in New Issue
Block a user