From 3edd6a0946d964a7fe581c99c3348802657de637 Mon Sep 17 00:00:00 2001 From: Captain Kitty Cat <68467449+Captainkittyca2@users.noreply.github.com> Date: Sat, 2 Nov 2024 17:06:15 +0300 Subject: [PATCH 1/6] 3D model stuff --- .../J3DGraphAnimator/J3DMaterialAttach.h | 24 +++++++++++++ .../JSystem/J3DGraphAnimator/J3DModelData.h | 35 +++++++++++++++++++ include/JSystem/J3DGraphBase/J3DMatBlock.h | 24 +++++++++++++ include/JSystem/J3DGraphBase/J3DMaterial.h | 27 ++++++++++++++ include/JSystem/JMath/JMATrigonometric.h | 26 ++++++++++++++ 5 files changed, 136 insertions(+) create mode 100644 include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h create mode 100644 include/JSystem/J3DGraphAnimator/J3DModelData.h create mode 100644 include/JSystem/J3DGraphBase/J3DMatBlock.h create mode 100644 include/JSystem/J3DGraphBase/J3DMaterial.h create mode 100644 include/JSystem/JMath/JMATrigonometric.h diff --git a/include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h b/include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h new file mode 100644 index 0000000..fdc6a98 --- /dev/null +++ b/include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h @@ -0,0 +1,24 @@ +/** @file J3DMaterialAttach.h + * @brief Contains defintions and functions that relate to Drawn 3D Objects + * + * @author Captain Kitty Cat + * @bug No known bugs. + */ +#ifndef TP_J3DMATERIALATTACH_H +#define TP_J3DMATERIALATTACH_H + +#include +#include + +namespace libtp::tp +{ + + struct J3DMaterialTable { + /* 0x0 */ uint8_t field_0x0[8]; + /* 0x8 */ J3DMaterial** mMaterialNodePointer; + uint8_t unk1[0x14]; + } __attribute__((__packed__)); + + static_assert(sizeof(J3DMaterialTable) == 0x20); +} +#endif /* TP_J3DMATERIALATTACH_H */ \ No newline at end of file diff --git a/include/JSystem/J3DGraphAnimator/J3DModelData.h b/include/JSystem/J3DGraphAnimator/J3DModelData.h new file mode 100644 index 0000000..2f2c4a1 --- /dev/null +++ b/include/JSystem/J3DGraphAnimator/J3DModelData.h @@ -0,0 +1,35 @@ +/** @file J3DModelData.h + * @brief Contains defintions and functions that relate to Drawn 3D Objects + * + * @author Captain Kitty Cat + * @bug No known bugs. + */ +#ifndef TP_J3DMODELDATA_H +#define TP_J3DMODELDATA_H + +#include +#include "J3DMaterialAttach.h" + +namespace libtp::tp +{ + + struct J3DModelData { + /* 0x0 */ uint8_t field_0x0[0x58]; + /* 0x58 */ J3DMaterialTable mMaterialTable; + /* 0x78 */ uint8_t unk1[0x6C]; + } __attribute__((__packed__)); + + struct GXColorS10 { + /* 0x0 */ int16_t r; + /* 0x2 */ int16_t g; + /* 0x4 */ int16_t b; + /* 0x6 */ int16_t a; + } __attribute__((__packed__)); + + static_assert(sizeof(J3DModelData) == 0xE4); + + extern "C" { + extern GXColorS10 j3dDefaultTevColor; + } +} +#endif /* TP_J3DMODELDATA_H */ \ No newline at end of file diff --git a/include/JSystem/J3DGraphBase/J3DMatBlock.h b/include/JSystem/J3DGraphBase/J3DMatBlock.h new file mode 100644 index 0000000..90865cf --- /dev/null +++ b/include/JSystem/J3DGraphBase/J3DMatBlock.h @@ -0,0 +1,24 @@ +/** @file J3DMatBlock.h + * @brief Contains defintions and functions that relate to Drawn 3D Objects + * + * @author Captain Kitty Cat + * @bug No known bugs. + */ +#ifndef TP_J3DMATBLOCK_H +#define TP_J3DMATBLOCK_H + +#include + +namespace libtp::tp +{ + + struct J3DTevBlock { + uint32_t field_0x0; + uint32_t mTexNoOffset; + } __attribute__((__packed__)); + +extern "C" { + //void setTevColor(libtp::tp::J3DTevBlock amog, uint32_t param_0, const GXColorS10* icolor); +} +} +#endif /* TP_J3DMATBLOCK_H */ \ No newline at end of file diff --git a/include/JSystem/J3DGraphBase/J3DMaterial.h b/include/JSystem/J3DGraphBase/J3DMaterial.h new file mode 100644 index 0000000..f18c109 --- /dev/null +++ b/include/JSystem/J3DGraphBase/J3DMaterial.h @@ -0,0 +1,27 @@ +/** @file J3DMaterial.h + * @brief Contains defintions and functions that relate to Drawn 3D Objects + * + * @author Captain Kitty Cat + * @bug No known bugs. + */ +#ifndef TP_J3DMATERIAL_H +#define TP_J3DMATERIAL_H + +#include +#include "J3DMatBlock.h" +#include "tp/J3DShape.h" + +namespace libtp::tp +{ + + class J3DMaterial { + /* 0x00 */ uint8_t field_0x0[0x8]; + /* 0x08 */ libtp::tp::J3DShape::J3DShape* mShape; + /* 0x0C */ uint8_t field_0x0c[0x2C-0x0C]; + /* 0x2C */ J3DTevBlock* mTevBlock; + /* 0x30 */ uint8_t field_0x30[0x4C-0x30]; + } __attribute__((__packed__)); + + static_assert(sizeof(J3DMaterial) == 0x4C); +} +#endif /* TP_J3DMATERIAL_H */ \ No newline at end of file diff --git a/include/JSystem/JMath/JMATrigonometric.h b/include/JSystem/JMath/JMATrigonometric.h new file mode 100644 index 0000000..e984c77 --- /dev/null +++ b/include/JSystem/JMath/JMATrigonometric.h @@ -0,0 +1,26 @@ +/** @file JMATrigonometric.h + * @brief Contains functions for handling various aspects of the game + * + * @author Captain Kitty Cat + * @bug No known bugs. + */ +#ifndef JMATRIGONOMETRIC_H +#define JMATRIGONOMETRIC_H + +#include +#include + +namespace libtp::tp +{ + struct TSinCosTable + { + libtp::pair table[0x2000]; + + } __attribute__((__packed__)); + + extern "C" + { + extern TSinCosTable sincosTable_; + } +} // namespace libtp::tp +#endif \ No newline at end of file From d9a4f7d05c2467ad5b79e03bd63b99973c50b009 Mon Sep 17 00:00:00 2001 From: Captain Kitty Cat <68467449+Captainkittyca2@users.noreply.github.com> Date: Sat, 2 Nov 2024 17:07:31 +0300 Subject: [PATCH 2/6] Add files via upload --- source/tp/J3DShape.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 source/tp/J3DShape.cpp diff --git a/source/tp/J3DShape.cpp b/source/tp/J3DShape.cpp new file mode 100644 index 0000000..d77b99d --- /dev/null +++ b/source/tp/J3DShape.cpp @@ -0,0 +1,23 @@ +#include + +#include + +namespace libtp::tp::J3DShape +{ + void onFlag(J3DShape* shapePtr, uint32_t flaag) { + shapePtr->mFlags |= flaag; + } + + void offFlag(J3DShape* shapePtr, uint32_t flaag) { + shapePtr->mFlags &= ~flaag; + } + + void showMesh(J3DShape* shapePtr) { + offFlag(shapePtr, J3DShpFlag_Visible); + } + + void hideMesh(J3DShape* shapePtr) { + onFlag(shapePtr, J3DShpFlag_Visible); + } + +} // namespace libtp::tp::J3DShape From 34edad98d6b28470c4f7451ac0f1c7ec798cfc06 Mon Sep 17 00:00:00 2001 From: Captain Kitty Cat <68467449+Captainkittyca2@users.noreply.github.com> Date: Sat, 2 Nov 2024 17:14:15 +0300 Subject: [PATCH 3/6] J3DModelData stuff --- include/tp/d_a_alink.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/tp/d_a_alink.h b/include/tp/d_a_alink.h index 5ff3248..699749d 100644 --- a/include/tp/d_a_alink.h +++ b/include/tp/d_a_alink.h @@ -22,6 +22,7 @@ #include "tp/J3DShape.h" #include "SSystem/SComponent/c_phase.h" #include "tp/J3DModel.h" +#include "JSystem/J3DGraphAnimator/J3DModelData.h" #include "tp/m_do_ext.h" namespace libtp::tp::d_a_alink @@ -402,7 +403,7 @@ namespace libtp::tp::d_a_alink /* 0x0063C */ request_of_phase_process_class mShieldPhaseReq; /* 0x00644 */ char* mShieldArcName; /* 0x00648 */ void* field_0x0648; // JKRExpHeap* - /* 0x0064C */ void* field_0x064C; // J3DModelData* + /* 0x0064C */ J3DModelData* field_0x064C; /* 0x00650 */ libtp::tp::J3DModel::J3DModel* mpLinkModel; /* 0x00654 */ libtp::tp::J3DModel::J3DModel* mpLinkFaceModel; /* 0x00658 */ libtp::tp::J3DModel::J3DModel* mpLinkHatModel; @@ -431,7 +432,7 @@ namespace libtp::tp::d_a_alink /* 0x006B4 */ libtp::tp::J3DAnimation::J3DAnmTransform* field_0x06b4; /* 0x006B8 */ libtp::tp::J3DModel::J3DModel* mSwordModel; /* 0x006BC */ libtp::tp::J3DModel::J3DModel* mSheathModel; - /* 0x006C0 */ void* field_0x06c0; // J3DModelData* + /* 0x006C0 */ J3DModelData* field_0x06c0; /* 0x006C4 */ libtp::tp::J3DAnimation::J3DAnmTextureSRTKey* m_nSwordBtk; /* 0x006C8 */ libtp::tp::J3DAnimation::J3DAnmTextureSRTKey* m_mSwordBtk; /* 0x006CC */ libtp::tp::J3DAnimation::J3DAnmTevRegKey* m_mSwordBrk; @@ -461,7 +462,7 @@ namespace libtp::tp::d_a_alink /* 0x0072C */ libtp::tp::J3DAnimation::J3DAnmTexPattern* field_0x072c; /* 0x00730 */ libtp::tp::m_Do_ext::mDoExt_bckAnm mItemBck; /* 0x0074C */ libtp::tp::m_Do_ext::mDoExt_bckAnm mHookTipBck; - /* 0x00768 */ void* mpHookKusariModelData; // J3DModelData + /* 0x00768 */ J3DModelData* mpHookKusariModelData; /* 0x0076C */ void* mpHookSound; // Z2SoundObjSimple /* 0x00770 */ void* mpHookChain; // hsChainShape_c /* 0x00774 */ uint8_t field_0x0774[0x8]; From e879277d4a39deafb583af0dc3aa7cd51dbabcad Mon Sep 17 00:00:00 2001 From: Captain Kitty Cat <68467449+Captainkittyca2@users.noreply.github.com> Date: Sat, 2 Nov 2024 17:53:19 +0300 Subject: [PATCH 4/6] Update J3DMaterial.h --- include/JSystem/J3DGraphBase/J3DMaterial.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/JSystem/J3DGraphBase/J3DMaterial.h b/include/JSystem/J3DGraphBase/J3DMaterial.h index f18c109..d17f52b 100644 --- a/include/JSystem/J3DGraphBase/J3DMaterial.h +++ b/include/JSystem/J3DGraphBase/J3DMaterial.h @@ -14,7 +14,7 @@ namespace libtp::tp { - class J3DMaterial { + struct J3DMaterial { /* 0x00 */ uint8_t field_0x0[0x8]; /* 0x08 */ libtp::tp::J3DShape::J3DShape* mShape; /* 0x0C */ uint8_t field_0x0c[0x2C-0x0C]; @@ -24,4 +24,4 @@ namespace libtp::tp static_assert(sizeof(J3DMaterial) == 0x4C); } -#endif /* TP_J3DMATERIAL_H */ \ No newline at end of file +#endif /* TP_J3DMATERIAL_H */ From 2dcf40322a43b2814061b8164619ce703794961b Mon Sep 17 00:00:00 2001 From: Captain Kitty Cat <68467449+Captainkittyca2@users.noreply.github.com> Date: Sat, 2 Nov 2024 17:58:13 +0300 Subject: [PATCH 5/6] Add files via upload --- include/tp/J3DShape.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/tp/J3DShape.h b/include/tp/J3DShape.h index f5be8e0..907a257 100644 --- a/include/tp/J3DShape.h +++ b/include/tp/J3DShape.h @@ -2,6 +2,7 @@ * @brief Contains defintions and functions that relate to Drawn 3D Objects * * @author Lunar Soap + * @author Captain Kitty Cat * @bug No known bugs. */ #ifndef TP_J3DSHAPE_H @@ -12,8 +13,18 @@ namespace libtp::tp::J3DShape { + enum J3DShpFlag { + J3DShpFlag_Visible = 0x0001, + J3DShpFlag_SkinPosCpu = 0x0004, + J3DShpFlag_SkinNrmCpu = 0x0008, + J3DShpFlag_Hidden = 0x0010, + J3DShpFlag_EnableLod = 0x0100, + J3DShpFlag_NoMtx = 0x0200, + }; + struct J3DShape { + public: /* 0x00 */ void* vtable; /* 0x04 */ void* mMaterial; // J3DMaterial* /* 0x08 */ uint16_t mIndex; @@ -42,5 +53,12 @@ namespace libtp::tp::J3DShape static_assert(sizeof(J3DShape) == 0x68); + extern "C" { + void onFlag(J3DShape* shapePtr, uint32_t flaag); + void offFlag(J3DShape* shapePtr, uint32_t flaag); + void showMesh(J3DShape* shapePtr); + void hideMesh(J3DShape* shapePtr); + } + } // namespace libtp::tp::J3DShape #endif \ No newline at end of file From 8ed18f324f97aa28033a19fee00fb4a68a4ae6c3 Mon Sep 17 00:00:00 2001 From: Captain Kitty Cat <68467449+Captainkittyca2@users.noreply.github.com> Date: Sat, 2 Nov 2024 17:59:09 +0300 Subject: [PATCH 6/6] Update J3DShape.h --- include/tp/J3DShape.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/tp/J3DShape.h b/include/tp/J3DShape.h index 907a257..033ad61 100644 --- a/include/tp/J3DShape.h +++ b/include/tp/J3DShape.h @@ -24,7 +24,6 @@ namespace libtp::tp::J3DShape struct J3DShape { - public: /* 0x00 */ void* vtable; /* 0x04 */ void* mMaterial; // J3DMaterial* /* 0x08 */ uint16_t mIndex; @@ -61,4 +60,4 @@ namespace libtp::tp::J3DShape } } // namespace libtp::tp::J3DShape -#endif \ No newline at end of file +#endif