Files
tp/include/JSystem/J3DGraphBase/J3DTexture.h
T

123 lines
3.0 KiB
C++
Raw Normal View History

2024-04-12 00:10:30 -06:00
#ifndef J3DTEXTURE_H
#define J3DTEXTURE_H
#include "JSystem/J3DGraphBase/J3DStruct.h"
2025-09-04 07:56:59 -07:00
#include "JSystem/J3DAssert.h"
2024-04-12 00:10:30 -06:00
#include "JSystem/JUtility/JUTTexture.h"
2025-09-04 07:56:59 -07:00
#include <stdint.h>
2024-04-12 00:10:30 -06:00
/**
* @ingroup jsystem-j3d
*
*/
class J3DTexture {
private:
/* 0x0 */ u16 mNum;
2025-09-04 07:56:59 -07:00
/* 0x2 */ u16 unk_0x2;
2024-04-12 00:10:30 -06:00
/* 0x4 */ ResTIMG* mpRes;
public:
2025-09-04 07:56:59 -07:00
J3DTexture(u16 num, ResTIMG* res) : mNum(num), unk_0x2(0), mpRes(res) {}
2025-11-30 14:23:42 -08:00
void loadGX(u16, GXTexMapID) const;
void entryNum(u16);
void addResTIMG(u16, ResTIMG const*);
virtual ~J3DTexture() {}
2024-04-12 00:10:30 -06:00
u16 getNum() const { return mNum; }
2025-09-04 07:56:59 -07:00
ResTIMG* getResTIMG(u16 index) const {
J3D_ASSERT_RANGE(72, index < mNum);
return &mpRes[index];
2025-06-20 02:41:43 -04:00
}
2025-09-04 07:56:59 -07:00
void setResTIMG(u16 index, const ResTIMG& timg) {
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)));
2024-04-12 00:10:30 -06:00
}
};
extern J3DTexMtxInfo const j3dDefaultTexMtxInfo;
/**
* @ingroup jsystem-j3d
*
*/
class J3DTexMtx {
public:
J3DTexMtx() {
mTexMtxInfo = j3dDefaultTexMtxInfo;
}
2025-09-04 07:56:59 -07:00
2024-04-12 00:10:30 -06:00
J3DTexMtx(const J3DTexMtxInfo& info) {
mTexMtxInfo = info;
}
2025-09-04 07:56:59 -07:00
2025-11-30 14:23:42 -08:00
void load(u32) const;
void calc(const Mtx);
void calcTexMtx(const Mtx);
void calcPostTexMtx(const Mtx);
void loadTexMtx(u32) const;
void loadPostTexMtx(u32) const;
2024-04-12 00:10:30 -06:00
J3DTexMtxInfo& getTexMtxInfo() { return mTexMtxInfo; }
Mtx& getMtx() { return mMtx; }
void setEffectMtx(Mtx effectMtx) { mTexMtxInfo.setEffectMtx(effectMtx); }
private:
/* 0x00 */ J3DTexMtxInfo mTexMtxInfo;
/* 0x64 */ Mtx mMtx;
}; // Size: 0x94
/**
* @ingroup jsystem-j3d
*
*/
struct J3DTexCoordInfo {
/* 0x0 */ u8 mTexGenType;
/* 0x1 */ u8 mTexGenSrc;
/* 0x2 */ u8 mTexGenMtx;
/* 0x3 */ u8 pad;
};
extern J3DTexCoordInfo const j3dDefaultTexCoordInfo[8];
/**
* @ingroup jsystem-j3d
*
*/
struct J3DTexCoord : public J3DTexCoordInfo {
2025-11-30 14:23:42 -08:00
J3DTexCoord() {
2024-04-12 00:10:30 -06:00
setTexCoordInfo(j3dDefaultTexCoordInfo[0]);
resetTexMtxReg();
}
J3DTexCoord(J3DTexCoordInfo const& info) {
setTexCoordInfo(info);
resetTexMtxReg();
}
void setTexCoordInfo(J3DTexCoordInfo const& info) {
__memcpy(this, &info, sizeof(J3DTexCoordInfo));
}
2025-04-09 01:17:20 -04:00
u8 getTexGenType() const { return mTexGenType; }
u8 getTexGenSrc() const { return mTexGenSrc; }
u8 getTexGenMtx() const { return mTexGenMtx; }
2025-04-09 16:45:30 -04:00
u32 getTexMtxReg() const { return mTexMtxReg & 0xff; }
2024-04-12 00:10:30 -06:00
void setTexGenMtx(u8 param_1) { mTexGenMtx = param_1; }
void setTexMtxReg(u16 reg) { mTexMtxReg = reg; }
2024-06-04 23:25:37 +03:00
J3DTexCoord& operator=(const J3DTexCoord& other) {
// Fake match (__memcpy or = doesn't match)
2025-09-04 07:56:59 -07:00
*(uintptr_t*)this = *(uintptr_t*)&other;
2024-06-04 23:25:37 +03:00
return *this;
}
2024-04-12 00:10:30 -06:00
void resetTexMtxReg() {
mTexMtxReg = mTexGenMtx;
}
/* 0x4 */ u16 mTexMtxReg;
}; // Size: 0x6
#endif /* J3DTEXTURE_H */