Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

m_Do_ext WIP #497

Merged
merged 2 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 54 additions & 29 deletions include/JSystem/J3DGraphAnimator/J3DMaterialAnm.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,123 +9,148 @@ typedef struct _GXColorS10 GXColorS10;
class J3DMatColorAnm {
public:
~J3DMatColorAnm() {}
J3DMatColorAnm() {}
J3DMatColorAnm(J3DAnmColor * pAnm, u16 materialIdx) {
J3DMatColorAnm() {
mAnmColor = NULL;
mAnmIndex = 0;
}
J3DMatColorAnm(J3DAnmColor* pAnm, u16 anmIdx) {
mAnmColor = pAnm;
mMaterialIdx = materialIdx;
mAnmIndex = anmIdx;
}

void operator=(J3DMatColorAnm const& other) {
mAnmColor = other.mAnmColor;
mMaterialIdx = other.mMaterialIdx;
mAnmIndex = other.mAnmIndex;
mAnmFlag = other.mAnmFlag;
}

void setAnmIndex(u16 index) { mAnmIndex = index; }
void setAnmFlag(bool flag) { mAnmFlag = flag; }
bool getAnmFlag() const { return mAnmFlag; }
void calc(_GXColor* pColor) const { mAnmColor->getColor(mMaterialIdx, pColor); }
void setAnmColor(J3DAnmColor* anmColor) { mAnmColor = anmColor; }
void calc(_GXColor* pColor) const { mAnmColor->getColor(mAnmIndex, pColor); }

private:
/* 0x0 */ u16 mMaterialIdx;
/* 0x0 */ u16 mAnmIndex;
/* 0x2 */ u16 mAnmFlag;
/* 0x4 */ J3DAnmColor* mAnmColor;
}; // Size: 0x8

class J3DTexNoAnm {
public:
~J3DTexNoAnm() {};
J3DTexNoAnm() {};
virtual void calc(u16* param_0) const { mAnmTexPattern->getTexNo(field_0x4, param_0); }
J3DTexNoAnm() {
mAnmTexPattern = NULL;
mAnmIndex = 0;
};
virtual void calc(u16* param_0) const { mAnmTexPattern->getTexNo(mAnmIndex, param_0); }

void operator=(J3DTexNoAnm const& other) {
mAnmTexPattern = other.mAnmTexPattern;
field_0x4 = other.field_0x4;
mAnmIndex = other.mAnmIndex;
mAnmFlag = other.mAnmFlag;
}

void setAnmIndex(u16 index) { mAnmIndex = index; }
void setAnmFlag(bool flag) { mAnmFlag = flag; }
bool getAnmFlag() const { return mAnmFlag; }
J3DAnmTexPattern* getAnmTexPattern() { return mAnmTexPattern; }
void setAnmTexPattern(J3DAnmTexPattern* pattern) { mAnmTexPattern = pattern; }

private:
/* 0x4 */ u16 field_0x4;
/* 0x4 */ u16 mAnmIndex;
/* 0x6 */ u16 mAnmFlag;
/* 0x8 */ J3DAnmTexPattern* mAnmTexPattern;
}; // Size: 0xC

class J3DTexMtxAnm {
public:
~J3DTexMtxAnm() {}
J3DTexMtxAnm() {}
J3DTexMtxAnm(J3DAnmTextureSRTKey * pAnm, u16 materialIdx) {
J3DTexMtxAnm() {
mAnmIndex = 0;
mAnmTransform = NULL;
}
J3DTexMtxAnm(J3DAnmTextureSRTKey * pAnm, u16 anmIdx) {
mAnmTransform = pAnm;
mMaterialIdx = materialIdx;
mAnmIndex = anmIdx;
}

void operator=(J3DTexMtxAnm const& other) {
mAnmTransform = other.mAnmTransform;
mMaterialIdx = other.mMaterialIdx;
mAnmIndex = other.mAnmIndex;
mAnmFlag = other.mAnmFlag;
}

void setAnmIndex(u16 index) { mAnmIndex = index; }
bool getAnmFlag() const { return mAnmFlag; }
void setAnmFlag(bool flag) { mAnmFlag = flag; }
void setAnmTransform(J3DAnmTextureSRTKey* transform) { mAnmTransform = transform; }
void calc(J3DTextureSRTInfo* pSRTInfo) const {
mAnmTransform->getTransform(mMaterialIdx, pSRTInfo);
mAnmTransform->getTransform(mAnmIndex, pSRTInfo);
}
bool getAnmFlag() const { return mAnmFlag; }

private:
/* 0x0 */ u16 mMaterialIdx;
/* 0x0 */ u16 mAnmIndex;
/* 0x2 */ u16 mAnmFlag;
/* 0x4 */ J3DAnmTextureSRTKey* mAnmTransform;
}; // Size: 0x8

class J3DTevKColorAnm {
public:
~J3DTevKColorAnm() {}
J3DTevKColorAnm() {}
J3DTevKColorAnm(J3DAnmTevRegKey * pAnm, u16 materialIdx) {
J3DTevKColorAnm() {
mAnmTevReg = NULL;
mAnmIndex = 0;
}
J3DTevKColorAnm(J3DAnmTevRegKey * pAnm, u16 anmIdx) {
mAnmTevReg = pAnm;
mMaterialIdx = materialIdx;
mAnmIndex = anmIdx;
}

void operator=(J3DTevKColorAnm const& other) {
mAnmTevReg = other.mAnmTevReg;
mMaterialIdx = other.mMaterialIdx;
mAnmIndex = other.mAnmIndex;
mAnmFlag = other.mAnmFlag;
}

void setAnmIndex(u16 index) { mAnmIndex = index; }
void setAnmFlag(bool flag) { mAnmFlag = flag; }
bool getAnmFlag() const { return mAnmFlag; }
void calc(_GXColor* pColor) const { mAnmTevReg->getTevKonstReg(mMaterialIdx, pColor); }
void setAnmTevReg(J3DAnmTevRegKey* tevReg) { mAnmTevReg = tevReg; }
void calc(_GXColor* pColor) const { mAnmTevReg->getTevKonstReg(mAnmIndex, pColor); }

private:
/* 0x0 */ u16 mMaterialIdx;
/* 0x0 */ u16 mAnmIndex;
/* 0x2 */ u16 mAnmFlag;
/* 0x4 */ J3DAnmTevRegKey* mAnmTevReg;
}; // Size: 0x8

class J3DTevColorAnm {
public:
~J3DTevColorAnm() {}
J3DTevColorAnm() {}
J3DTevColorAnm(J3DAnmTevRegKey * pAnm, u16 materialIdx) {
J3DTevColorAnm() {
mAnmTevReg = NULL;
mAnmIndex = 0;
}
J3DTevColorAnm(J3DAnmTevRegKey * pAnm, u16 anmIdx) {
mAnmTevReg = pAnm;
mMaterialIdx = materialIdx;
mAnmIndex = anmIdx;
}

void operator=(J3DTevColorAnm const& other) {
mAnmTevReg = other.mAnmTevReg;
mMaterialIdx = other.mMaterialIdx;
mAnmIndex = other.mAnmIndex;
mAnmFlag = other.mAnmFlag;
}

void setAnmIndex(u16 index) { mAnmIndex = index; }
void setAnmFlag(bool flag) { mAnmFlag = flag; }
bool getAnmFlag() const { return mAnmFlag; }
void calc(_GXColorS10* pColor) const { mAnmTevReg->getTevColorReg(mMaterialIdx, pColor); }
void setAnmTevReg(J3DAnmTevRegKey* tevReg) { mAnmTevReg = tevReg; }
void calc(_GXColorS10* pColor) const { mAnmTevReg->getTevColorReg(mAnmIndex, pColor); }

private:
/* 0x0 */ u16 mMaterialIdx;
/* 0x0 */ u16 mAnmIndex;
/* 0x2 */ u16 mAnmFlag;
/* 0x4 */ J3DAnmTevRegKey* mAnmTevReg;
}; // Size: 0x8
Expand Down
2 changes: 2 additions & 0 deletions include/JSystem/J3DGraphAnimator/J3DModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class J3DModel {
void calcDrawMtx();
void prepareShapePackets();
MtxP getAnmMtx(int idx) { return mpNodeMtx[idx]; }
void setAnmMtx(int idx, Mtx mtx) { MTXCopy(mtx, mpNodeMtx[idx]); }
MtxP getWeightAnmMtx(int idx) { return mpWeightEnvMtx[idx]; }

s32 setNoUseDrawMtx();
Expand Down Expand Up @@ -106,6 +107,7 @@ class J3DModel {
u32* getCurrentViewNoPtr() { return &mCurrentViewNo; }
u8* getScaleFlagArray() const { return mpScaleFlagArr; }
u8 getScaleFlag(u32 idx) const { return mpScaleFlagArr[idx]; }
void setScaleFlag(int idx, u8 param_1) { mpScaleFlagArr[idx] = param_1; }
u8 getEnvScaleFlag(u32 idx) const { return mpEvlpScaleFlagArr[idx]; }
J3DVertexBuffer* getVertexBuffer() const { return (J3DVertexBuffer*)&mVertexBuffer; }
J3DMatPacket* getMatPacket(u16 idx) const { return &mpMatPacket[idx]; }
Expand Down
2 changes: 1 addition & 1 deletion include/JSystem/J3DGraphBase/J3DMatBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class J3DTexGenBlock {
virtual void setTexCoord(u32, J3DTexCoord const*);
virtual J3DTexCoord* getTexCoord(u32);
virtual void setTexMtx(u32, J3DTexMtx*);
virtual J3DTexMtx* getTexMtx(u32);
virtual J3DTexMtx* getTexMtx(u32) { return NULL; }
virtual void setNBTScale(J3DNBTScale const*);
virtual void setNBTScale(J3DNBTScale);
virtual J3DNBTScale* getNBTScale();
Expand Down
12 changes: 11 additions & 1 deletion include/JSystem/J3DGraphBase/J3DStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,17 @@ enum J3DTexMtxMode {
};

struct J3DTexMtxInfo {
void operator=(J3DTexMtxInfo const&);
void operator=(J3DTexMtxInfo const& other) {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
mEffectMtx[i][j] = other.mEffectMtx[i][j];
}
}
mCenter = other.mCenter;
mProjection = other.mProjection;
mInfo = other.mInfo;
mSRT = other.mSRT;
}
void setEffectMtx(Mtx);

/* 0x00 */ u8 mProjection;
Expand Down
5 changes: 3 additions & 2 deletions include/JSystem/J3DGraphBase/J3DTexture.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#ifndef J3DTEXTURE_H
#define J3DTEXTURE_H

#include "JSystem/J3DGraphBase/J3DStruct.h"
#include "JSystem/J3DGraphBase/J3DGD.h"
#include "JSystem/J3DGraphBase/J3DStruct.h"
#include "JSystem/J3DGraphBase/J3DTevs.h"
#include "JSystem/JUtility/JUTTexture.h"
#include "dolphin/mtx/mtx.h"
#include "dolphin/types.h"
Expand Down Expand Up @@ -49,7 +50,7 @@ class J3DTexture {

class J3DTexMtx {
public:
J3DTexMtx();
J3DTexMtx() { mTexMtxInfo = j3dDefaultTexMtxInfo; }
J3DTexMtx(const J3DTexMtxInfo& info) {
mTexMtxInfo = info;
}
Expand Down
38 changes: 21 additions & 17 deletions include/m_Do/m_Do_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,30 @@ class J3DTexMtxAnm;

class mDoExt_baseAnm {
public:
mDoExt_baseAnm() { mpFrameCtrl = NULL; }
mDoExt_baseAnm() { mFrameCtrl = NULL; }
virtual ~mDoExt_baseAnm() {}

int initPlay(s16 i_frameMax, int i_attribute, f32 i_rate, s16 i_startF, s16 i_endF, bool);
int play();

J3DFrameCtrl* getFrameCtrl() { return mpFrameCtrl; }
f32 getPlaySpeed() { return mpFrameCtrl->getRate(); }
void setPlaySpeed(f32 speed) { mpFrameCtrl->setRate(speed); }
f32 getFrame() { return mpFrameCtrl->getFrame(); }
f32 getEndFrame() { return mpFrameCtrl->getEnd(); }
void setFrame(f32 frame) { mpFrameCtrl->setFrame(frame); }
void setPlayMode(int i_mode) { mpFrameCtrl->setAttribute(i_mode); }
void setLoopFrame(f32 i_frame) { mpFrameCtrl->setLoop(i_frame); }
J3DFrameCtrl* getFrameCtrl() { return mFrameCtrl; }
f32 getPlaySpeed() { return mFrameCtrl->getRate(); }
void setPlaySpeed(f32 speed) { mFrameCtrl->setRate(speed); }
f32 getFrame() { return mFrameCtrl->getFrame(); }
f32 getEndFrame() { return mFrameCtrl->getEnd(); }
void setFrame(f32 frame) { mFrameCtrl->setFrame(frame); }
void setPlayMode(int i_mode) { mFrameCtrl->setAttribute(i_mode); }
void setLoopFrame(f32 i_frame) { mFrameCtrl->setLoop(i_frame); }
bool isStop() {
bool stopped = true;
if (!mpFrameCtrl->checkState(1) && mpFrameCtrl->getRate() != 0.0f) {
if (!mFrameCtrl->checkState(1) && mFrameCtrl->getRate() != 0.0f) {
stopped = false;
}
return stopped;
}

private:
/* 0x4 */ J3DFrameCtrl* mpFrameCtrl;
/* 0x4 */ J3DFrameCtrl* mFrameCtrl;
}; // Size: 0x08

class mDoExt_btkAnm : public mDoExt_baseAnm {
Expand All @@ -65,7 +65,7 @@ class mDoExt_btkAnm : public mDoExt_baseAnm {
private:
/* 0x08 */ J3DAnmTextureSRTKey* mpAnm;
/* 0x0C */ J3DTexMtxAnm* mpTexMtxAnm;
/* 0x10 */ s16 mUpdateMaterialNum;
/* 0x10 */ u16 mUpdateMaterialNum;
}; // Size: 0x14

STATIC_ASSERT(sizeof(mDoExt_btkAnm) == 0x14);
Expand Down Expand Up @@ -138,12 +138,10 @@ class mDoExt_btpAnm : public mDoExt_baseAnm {
int i_attribute, f32 i_rate, s16 i_start, s16 param_6);
int init(J3DModelData*, J3DAnmTexPattern*, int, int, float, short, short, bool, int);
int init(J3DMaterialTable*, J3DAnmTexPattern*, int, int, float, short, short, bool, int);
void entry(J3DModelData* i_modelData, s16 i_frame);
/* 8000D5E8 */ void entry(J3DMaterialTable* i_matTable, s16 i_frame);

void entry(J3DModelData* i_modelData) { entry(i_modelData, getFrame()); }
void entry(J3DModelData* i_modelData, s16 i_frame) {
entry(&i_modelData->getMaterialTable(), i_frame);
}

int init(J3DModelData* i_modelData, J3DAnmTexPattern* i_btk, int i_anmPlay, int i_attribute,
f32 i_rate, s16 i_start, s16 param_6) {
Expand All @@ -154,7 +152,9 @@ class mDoExt_btpAnm : public mDoExt_baseAnm {
int remove(J3DModelData* i_modelData) { return i_modelData->removeTexNoAnimator(mpAnm); }

private:
/* 0x14 */ J3DAnmTexPattern* mpAnm;
/* 0x08 */ J3DAnmTexPattern* mpAnm;
/* 0x0C */ J3DTexNoAnm* field_0xc;
/* 0x10 */ u16 mUpdateMaterialNum;
};

class mDoExt_blkAnm : public mDoExt_baseAnm {
Expand All @@ -177,7 +177,9 @@ class mDoExt_bpkAnm : public mDoExt_baseAnm {
void entry(J3DMaterialTable*, float);

private:
// TODO
/* 0x08 */ J3DAnmColor* mpAnm;
/* 0x0C */ J3DMatColorAnm* field_0xc;
/* 0x10 */ u16 mUpdateMaterialNum;
};

class mDoExt_bvaAnm : public mDoExt_baseAnm {
Expand Down Expand Up @@ -465,4 +467,6 @@ extern JKRExpHeap* gameHeap;
extern JKRExpHeap* commandHeap;
extern JKRExpHeap* archiveHeap;

//inline void mDoMtx_concat(const Mtx a, const Mtx b, Mtx ab) { MTXConcat(a, b, ab); }

#endif
Loading