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..d17f52b --- /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 +{ + + struct 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 */ 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 diff --git a/include/tp/J3DShape.h b/include/tp/J3DShape.h index f5be8e0..033ad61 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,6 +13,15 @@ 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 { /* 0x00 */ void* vtable; @@ -42,5 +52,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 +#endif 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]; 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