More player model

This commit is contained in:
robojumper
2025-05-18 12:41:12 +02:00
parent 790fc7fda3
commit bb6fd66745
25 changed files with 1489 additions and 364 deletions
+504 -249
View File
@@ -4,15 +4,18 @@
#include "common.h"
#include "d/a/d_a_base.h"
#include "d/a/d_a_itembase.h"
#include "d/a/e/d_a_en_base.h"
#include "d/a/obj/d_a_obj_base.h"
#include "d/col/cc/d_cc_d.h"
#include "d/a/e/d_a_en_base.h"
#include "m/m3d/m_anmchr.h"
#include "m/m3d/m_anmchrblend.h"
#include "m/m3d/m_anmmatclr.h"
#include "m/m3d/m_anmtexpat.h"
#include "m/m3d/m_anmtexsrt.h"
#include "m/m3d/m_banm.h"
#include "m/m3d/m_bmdl.h"
#include "m/m3d/m_mdl.h"
#include "m/m3d/m_scnleaf.h"
#include "m/m3d/m_smdl.h"
#include "m/m_allocator.h"
#include "m/m_angle.h"
@@ -22,6 +25,7 @@
#include "nw4r/g3d/g3d_calcworld.h"
#include "nw4r/g3d/g3d_scnobj.h"
#include "nw4r/g3d/res/g3d_resanmchr.h"
#include "nw4r/g3d/res/g3d_resanmtexsrt.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resmdl.h"
#include "toBeSorted/file_manager.h"
@@ -30,6 +34,15 @@
// See Below for some info
// https://github.com/lepelog/skywardsword-tools/wiki/Player-Actor
struct PlayerAnimation {
/* 0x00 */ const char *animName;
/* 0x04 */ u8 field_0x04;
/* 0x05 */ u8 field_0x05;
/* 0x06 */ u16 mFaceTexPatIdx;
/* 0x08 */ u16 mFaceTexSrtIdx;
/* 0x0A */ u16 mFaceAnmChrIdx;
};
/*
* The inheritance chain goes something like:
* dAcObjBase_c straightfoward
@@ -44,49 +57,111 @@
*/
// Vtable at 80533128, no differences to dAcObjBase_c?
class daPlBase_c : public dAcObjBase_c {
public:
virtual ~daPlBase_c() {}
};
class daPlBaseCallback1_c : m3d::callback_c {
u8 _0x__[4];
};
class daPlBaseCallback2_c : m3d::callback_c {
u8 _0x__[4];
class daPlayerModelBase_c;
class daPlBaseScnObjCallback_c : public dScnCallback_c {
public:
daPlBaseScnObjCallback_c(dAcObjBase_c *b) : dScnCallback_c(b), field_0x0C(b) {}
/* vt 0x10 */ virtual void
ExecCallback_CALC_MAT(nw4r::g3d::ScnObj::Timing, nw4r::g3d::ScnObj *, u32, void *) override;
/* 0x18 */ virtual void ExecCallback_DRAW_OPA(nw4r::g3d::ScnObj::Timing, nw4r::g3d::ScnObj *, u32, void *) override;
private:
/* 0x0C */ dAcObjBase_c *field_0x0C;
};
class daPlBaseMdlCallback_c : m3d::mdl_c::mdlCallback_c {
u8 _0x__[8];
class daPlBaseMdlCallback_c : public m3d::mdl_c::mdlCallback_c {
public:
virtual void ExecCallbackA(nw4r::g3d::ChrAnmResult *, nw4r::g3d::ResMdl, nw4r::g3d::FuncObjCalcWorld *) override;
void setNodeIds(u16 min, u16 max) {
mNodeIdMin = min;
mNodeIdMax = max;
}
private:
/* 0x30 */ u16 mNodeIdMin;
/* 0x32 */ u16 mNodeIdMax;
};
class daPlBaseAnmChr_c : m3d::anmChr_c {
class daPlBaseMdl_c : public m3d::mdl_c {
public:
daPlBaseMdl_c() : field_0x5C(0) {}
virtual bool setAnm(m3d::banm_c &anm) override;
virtual void remove() override;
bool create(
daPlayerModelBase_c *player, nw4r::g3d::ResMdl mdl, mAllocator_c *alloc, u32 bufferOption, u32 nView, u32 *pSize
);
void setBlendNodeRange(u16, u16, f32);
private:
/* 0x24 */ daPlBaseMdlCallback_c mCallback;
/* 0x58 */ u8 field_0x58;
/* 0x5A */ u16 field_0x5A;
/* 0x5C */ u32 field_0x5C;
};
class daPlBaseMainCallback_c : public m3d::callback_c {
public:
virtual void timingA(u32, nw4r::g3d::ChrAnmResult *, nw4r::g3d::ResMdl) override;
virtual void timingB(u32, nw4r::g3d::WorldMtxManip *, nw4r::g3d::ResMdl) override;
virtual void timingC(nw4r::math::MTX34 *, nw4r::g3d::ResMdl) override;
void setPlayer(daPlayerModelBase_c *p) {
mpPlayer = p;
}
private:
daPlayerModelBase_c *mpPlayer;
};
class daPlBaseAnmChr_c : public m3d::anmChr_c {
public:
daPlBaseAnmChr_c() : field_0x35(0), field_0x36(0) {}
void play() override;
bool isFinished();
private:
/* 0x35 */ u8 field_0x35;
/* 0x36 */ u8 field_0x36;
};
class daPlBaseMdl_c : m3d::mdl_c {
public:
daPlBaseMdl_c() : field_0x5C(0) {}
private:
/* 0x24 */ daPlBaseMdlCallback_c mCallback;
/* 0x5C */ UNKWORD field_0x5C;
};
class daPlBaseCalcWorldCallback_c : public nw4r::g3d::ICalcWorldCallback {
public:
virtual void ExecCallbackC(
nw4r::math::MTX34 *pMtxArray, nw4r::g3d::ResMdl mdl,
nw4r::g3d::FuncObjCalcWorld *pFuncObj
) override; // at 0x14
void setPlayer(daPlayerModelBase_c *p) {
mpPlayer = p;
}
private:
/* 0x04 */ daPlayerModelBase_c *mpPlayer;
};
class daPlBaseScnObjCallback_c : public nw4r::g3d::IScnObjCallback {
u8 _0x__[0x10];
class daPlBaseHeadCallback_c : public m3d::callback_c {
public:
virtual void timingB(u32, nw4r::g3d::WorldMtxManip *, nw4r::g3d::ResMdl) override;
void setPlayer(daPlayerModelBase_c *p) {
mpPlayer = p;
}
private:
daPlayerModelBase_c *mpPlayer;
};
class UnkPlayerClass {
@@ -119,6 +194,8 @@ public:
return 0.0f;
}
/* vt 0x094 */ virtual void relatedToUsingItem0x11() {
// TODO obvious hack, not sure
delete (daPlBase_c *)0;
}
/* vt 0x098 */ virtual void setPosRot(const mVec3_c *pos, const mAng3_c *ang, bool force, UNKWORD, UNKWORD);
/* vt 0x09C */ virtual bool isLiftingObject() {
@@ -300,17 +377,19 @@ public:
/* vt 0x18C */ virtual void getBodyMtx(mMtx_c *out_mtx, int boneIdx) {
// unused; overridden by daPlayerModelBase_c
}
/* vt 0x190 */ virtual void getSheathModelMatrix() {
/* vt 0x190 */ virtual void getSheathModelMatrix(mMtx_c *out_mtx) {
// unused; overridden by daPlayerModelBase_c
}
/* vt 0x194 */ virtual void getSwordModelMatrix() {
/* vt 0x194 */ virtual void getSwordModelMatrix(mMtx_c *out_mtx) {
// unused; overridden by daPlayerModelBase_c
}
/* vt 0x198 */ virtual void vt_0x198() {
/* vt 0x198 */ virtual mAng vt_0x198() {
// unused; overridden by daPlayerModelBase_c
return 0;
}
/* vt 0x19C */ virtual void vt_0x19C() {
/* vt 0x19C */ virtual mAng vt_0x19C() {
// unused; overridden by daPlayerModelBase_c
return 0;
}
/* vt 0x1A0 */ virtual f32 vt_0x1A0() {
return 0.0f;
@@ -423,9 +502,7 @@ public:
return 0;
}
/* vt 0x238 */ virtual void setVecIfInFreeFall() {}
/* vt 0x23C */ virtual void setActorRef10() {
}
/* vt 0x23C */ virtual void setActorRef10() {}
/* vt 0x240 */ virtual f32 vt_0x240() {
return 0.0f;
}
@@ -551,66 +628,33 @@ public:
ATTACK_FINAL_BLOW = 11,
};
static bool isInEvent();
bool isAttackingLeft() const;
bool isAttackingRight() const;
bool isAttackingDown() const;
bool isAttackingUp() const;
bool isAttackingStab() const;
bool isAttackingSpinHorizontal() const;
bool isAttackingSpinVertical() const;
void setBonkRelatedAnimFlag(bool b);
void setPosYRot(const mVec3_c &pos, mAng rot, bool force, UNKWORD, UNKWORD);
void setTransform(const mMtx_c &mtx, bool force, UNKWORD, UNKWORD);
bool someTargetedActorCheck() const;
static mAng fn_8005BA90();
static mAng fn_8005BAA0();
enum ModelUpdateFlags_e {
UPDATE_MODEL_SWORD = 0x20,
UPDATE_MODEL_SHIELD = 0x40,
};
static const mColor &getEarringsColor();
static mVec3_c sPos1;
static mVec3_c sPos2;
static mAng sRot1;
static mAng sRot2;
static const f32 sPushRelatedConstant;
protected:
/* 0x330 */ u8 unk_0x330[0x334 - 0x330];
/* 0x334 */ f32 field_0x334;
/* 0x338 */ u8 mAttackDirection;
/* 0x339 */ u8 mRidingActorType;
/* 0x33A */ u8 unk_0x33A[0x340 - 0x33A];
/* 0x340 */ u32 someFlags_0x340;
/* 0x344 */ u8 unk_0x344[0x348 - 0x344];
/* 0x348 */ u32 mSwordAndMoreStates;
/* 0x34C */ u8 unk_0x34C[0x350 - 0x34C];
/* 0x350 */ u32 someFlags_0x350;
/* 0x354 */ u32 someFlags_0x354;
/* 0x358 */ u32 someFlags_0x358;
/* 0x35C */ u32 mForceOrPreventActionFlags;
/* 0x360 */ u32 field_0x360;
/* 0x364 */ u32 mActionFlags;
/* 0x368 */ u32 mActionFlagsCont;
/* 0x36C */ int mCurrentAction; // TODO (Document Enum)
};
// Vtable at 8050da00, dtor reveals two superclasses
// until dAcObjBase_c
class daPlayerModelBase_c : public daPlayerActBase_c {
public:
daPlayerModelBase_c()
: mSwordRes(nullptr),
mAlinkRes(nullptr),
mPlCommonAnimeRes(nullptr),
mPlCommonSoundRes(nullptr),
mCurrentRes(nullptr),
mAlink2Res(nullptr),
mScnCallback1(this),
mScnCallback2(this),
mScnCallback3(this),
mScnCallback4(this),
mScnCallback5(this) {}
virtual ~daPlayerModelBase_c() {}
enum SwordAndMoreStates_e {
NO_SHIETH = (1 << 0),
POUCH = (1 << 1),
SWORD_AWAY = (1 << 2),
FLASH_RED = (1 << 4),
DEPLETE_STAMINA = (1 << 5),
SPRINTING = (1 << 6),
B_WHEEL_OPEN = (1 << 7),
POUCH_OPEN = (1 << 8),
TRYING_TO_USE_STAMINA_NOT_ABLE = (1 << 9),
PUTTING_AWAY_SAILCLOTH = (1 << 10),
GRAB_LEDGE_FROM_UNDER = (1 << 13),
HOLDING_A_NO_STAMINA_DROP = (1 << 14),
FIRST_PERSON = (1 << 18),
SKYWARD_STRIKE_ACTIVE = (1 << 20),
LIGHTNING_STRIKE_ACTIVE = (1 << 22),
C_MENU_OPEN = (1 << 23),
SHIELD_OUT = (1 << 27),
HOLDING_TARGET = (1 << 28),
ITEM_NEAR_LINK = (1 << 29),
USING_ITEM = (1 << 31),
};
// These Flags are named under general guesses. Very likely may need some changes
// Correspond to mActionFlags
@@ -652,166 +696,14 @@ public:
FLG0_HANGING_ITEM | FLG0_HANGING_LEDGE | FLG0_UNK_0x10 | FLG0_IN_AIR,
};
void fn_8005ED60();
void fn_8005EAC0();
void fn_8005F890();
void fn_80061410();
/* vt 0x114 */ virtual void somethingWithCarriedActorFlags() override {
// TODO
}
/* vt 0x118 */ virtual dAcObjBase_c *getCurrentCarriedActor() override {
// TODO
return nullptr;
}
/* vt 0x0E4 */ virtual const mVec3_c &getCenterTranslation() const override {
// TODO
return mVec3_c::Zero;
}
/* vt 0x0E8 */ virtual const mVec3_c &vt_0x0E8() const override {
return field_0x12F4;
}
/* vt 0x0EC */ virtual const mVec3_c &vt_0x0EC() const override {
// TODO
return mVec3_c::Zero;
}
/* vt 0x0F0 */ virtual const mVec3_c &vt_0x0F0() const override {
// TODO
return mVec3_c::Zero;
}
/* vt 0x0F4 */ virtual const mVec3_c &vt_0x0F4() const override {
// TODO
return mVec3_c::Zero;
}
/* vt 0x2E0 */ virtual void vt_0x2E0() {}
/* vt 0x2E4 */ virtual void someDivingHrabbingStuff() {}
/* vt 0x2E8 */ virtual bool vt_0x2E8() {
return true;
}
/* vt 0x2EC */ virtual void isOnClawTargetMaybe(UNKWORD, mAng &a1, mAng &a2) {
a1.setR(0);
a2.setR(0);
}
/* vt 0x2F0 */ virtual bool isMPPose() {
return false;
}
/* vt 0x2F4 */ virtual bool isOnTightRope() {
return false;
}
/* vt 0x2F8 */ virtual bool isOnVines() {
return false;
}
/* vt 0x2FC */ virtual bool alwaysRet0() {
return 0;
}
/* vt 0x300 */ virtual bool canBlockAttack() {
return false;
}
/* vt 0x304 */ virtual const mVec3_c &vt_0x304() const {
return mVec3_c::Zero;
}
/* vt 0x308 */ virtual mAng vt_0x308() {
return 0;
}
/* vt 0x30C */ virtual void vt_0x30C(mVec3_c &res) {
res = mVec3_c::Ex;
}
protected:
/* 0x370 */ mHeapAllocator_c mModelAllocator;
/* 0x38C */ mHeapAllocator_c mSwordAllocator;
/* 0x3A8 */ mHeapAllocator_c mShieldAllocator;
/* 0x3C4 */ u32 mModelUpdateFlags;
/* 0x3C8 */ nw4r::g3d::ResFile mSwordRes;
/* 0x3CC */ nw4r::g3d::ResFile mAlinkRes;
/* 0x3D0 */ nw4r::g3d::ResFile mPlCommonAnimeRes;
/* 0x3D4 */ nw4r::g3d::ResFile mPlCommonSoundRes;
/* 0x3D8 */ nw4r::g3d::ResFile mCurrentRes;
/* 0x3DC */ nw4r::g3d::ResFile mAlink2Res;
/* 0x3E0 */ daPlBaseMdl_c mMainMdl;
/* 0x440 */ daPlBaseCallback1_c mCallback1;
/* 0x448 */ m3d::mdl_c mHeadMdl;
/* 0x46C */ daPlBaseCallback2_c mCallback2;
/* 0x474 */ m3d::smdl_c mFaceMdl;
/* 0x490 */ m3d::anmChr_c mFaceAnmChr;
/* 0x4C8 */ u8 _0x4C8[4];
/* 0x4CC */ m3d::anmTexPat_c mFaceTexPat;
/* 0x4F8 */ u8 _0x4F8[4];
/* 0x4FC */ m3d::anmTexSrt_c mFaceTexSrt;
/* 0x528 */ u8 _0x528[4];
/* 0x52C */ m3d::anmChr_c mHeadAnmChr;
/* 0x564 */ m3d::smdl_c mHandsMdl;
/* 0x580 */ daPlBaseCalcWorldCallback_c mCalcWorldCallback;
/* 0x588 */ daPlBaseScnObjCallback_c mScnObjCallback;
/* 0x598 */ m3d::smdl_c mSwordMdl;
/* 0x5B4 */ m3d::anmMatClr_c mAnmMatClr;
/* 0x5E0 */ m3d::smdl_c mShieldMdl;
/* 0x5FC */ m3d::anmTexPat_c mUnkAnmTextPat1;
/* 0x628 */ m3d::anmTexPat_c mUnkAnmTextPat2;
/* 0x654 */ m3d::smdl_c mSheathMdl;
/* 0x670 */ m3d::smdl_c mUnkMdl1;
/* 0x68C */ m3d::anmChr_c mAnmChr;
/* 0x6C4 */ m3d::anmChrBlend_c mAnmChrBlend;
/* 0x6EC */ dScnCallback_c mScnCallback1;
/* 0x6F8 */ dScnCallback_c mScnCallback2;
/* 0x704 */ dScnCallback_c mScnCallback3;
/* 0x610 */ dScnCallback_c mScnCallback4;
/* 0x61C */ dScnCallback_c mScnCallback5;
/* 0x728 */ daPlBaseAnmChr_c mAnmChrs[6];
/* 0x878 */ dCcD_Cyl mCcCyls[3];
/* 0xC68 */ dCcD_Cps mCcCpss[3];
/* 0x10B8 */ dCcD_Cyl mCcCyl;
/* 0x1208 */ u8 _0x1208[0xA4];
/* 0x12AC */ mVec3_c mTranslationHand[2];
/* 0x12C4 */ mVec3_c mTranslationWeapon[2];
/* 0x12DC */ mVec3_c mToeTranslation[2];
/* 0x12F4 */ mVec3_c field_0x12F4;
/* 0x1300 */ UnkPlayerClass mUnk_0x1300[4];
/* 0x1340 */ mQuat_c mQuat1;
/* 0x1350 */ mQuat_c mQuat2;
/* 0x1360 */ dAcRef_c<dAcObjBase_c> mRef; // not sure about the class
};
// The split between daPlBase_c and dAcPy_c is somewhere after
// member offset 0x1368 and before 0x137C
class dAcPy_c : public daPlayerModelBase_c {
public:
dAcPy_c();
virtual ~dAcPy_c();
// argument is always false in existing code, true doesn't seem to make a difference
void bonk(bool unk = false);
bool fn_80202D90(bool);
/* overrides omitted */
/* vt 0x310 */ virtual void vt_0x310();
/* vt 0x314 */ virtual void vt_0x314();
/* vt 0x318 */ virtual void vt_0x318();
protected:
/* 0x136C */ u8 _0x136C[0x4564 - 0x136C];
/* 0x4564 */ f32 field_0x4564;
public:
f32 getField_0x4564() const {
return field_0x4564;
}
f32 getAnmMatClrFrame() const {
return mAnmMatClr.getFrame(0);
}
nw4r::g3d::ResFile getSwordResFile() const {
return mSwordRes;
}
inline bool checkFlags0x340(u32 mask) const {
return (someFlags_0x340 & mask) != 0;
}
inline void offFlags_0x340(u32 mask) {
someFlags_0x340 &= ~mask;
}
inline bool checkFlags0x350(u32 mask) const {
return (someFlags_0x350 & mask) != 0;
}
@@ -840,10 +732,6 @@ public:
return mCurrentAction == 0xAD || mCurrentAction == 0xAE;
}
inline bool checkSwordAndMoreStates(u32 mask) const {
return (mSwordAndMoreStates & mask) != 0;
}
inline bool checkActionFlags(u32 mask) const {
return (mActionFlags & mask) != 0;
}
@@ -855,6 +743,374 @@ public:
return mRidingActorType;
}
static bool isInEvent();
bool isAttackingLeft() const;
bool isAttackingRight() const;
bool isAttackingDown() const;
bool isAttackingUp() const;
bool isAttackingStab() const;
bool isAttackingSpinHorizontal() const;
bool isAttackingSpinVertical() const;
void setBonkRelatedAnimFlag(bool b);
void setPosYRot(const mVec3_c &pos, mAng rot, bool force, UNKWORD, UNKWORD);
void setTransform(const mMtx_c &mtx, bool force, UNKWORD, UNKWORD);
bool someTargetedActorCheck() const;
static mAng fn_8005BA90();
static mAng fn_8005BAA0();
static void updateCurrentSword();
static s32 getCurrentSwordType();
static const char *getSwordName(s32);
static s32 getCurrentlyEquippedShieldType();
static s32 getCurrentlyEquippedShieldId();
static u32 getCurrentShieldPouchSlot();
static const mColor &getEarringsColor();
static mVec3_c sPos1;
static mVec3_c sPos2;
static mAng sRot1;
static mAng sRot2;
static const f32 sPushRelatedConstant;
static u8 sCurrentSword;
protected:
/* 0x330 */ u8 unk_0x330[0x334 - 0x330];
/* 0x334 */ f32 field_0x334;
/* 0x338 */ u8 mAttackDirection;
/* 0x339 */ u8 mRidingActorType;
/* 0x33A */ u8 unk_0x33A[0x340 - 0x33A];
/* 0x340 */ u32 someFlags_0x340;
/* 0x344 */ u8 unk_0x344[0x348 - 0x344];
/* 0x348 */ u32 mSwordAndMoreStates;
/* 0x34C */ u32 mModelUpdateFlags;
/* 0x350 */ u32 someFlags_0x350;
/* 0x354 */ u32 someFlags_0x354;
/* 0x358 */ u32 someFlags_0x358;
/* 0x35C */ u32 mForceOrPreventActionFlags;
/* 0x360 */ u32 field_0x360;
/* 0x364 */ u32 mActionFlags;
/* 0x368 */ u32 mActionFlagsCont;
/* 0x36C */ int mCurrentAction; // TODO (Document Enum)
};
// Vtable at 8050da00, dtor reveals two superclasses
// until dAcObjBase_c
class daPlayerModelBase_c : public daPlayerActBase_c {
public:
daPlayerModelBase_c()
: mSwordRes(nullptr),
mAlinkRes(nullptr),
mPlCommonAnimeRes(nullptr),
mPlCommonSoundRes(nullptr),
mCurrentRes(nullptr),
mAlink2Res(nullptr),
mScnObjCallback(this),
mScnCallback1(this),
mScnCallback2(this),
mScnCallback3(this),
mScnCallback4(this),
mScnCallback5(this) {}
virtual ~daPlayerModelBase_c() {}
enum TunicType_e {
TUNIC_0,
TUNIC_1,
TUNIC_SILENT,
};
// Alink.arc > g3d > model.brres > 3DModels(NW4R) > al > Bones > ...
enum PlayerMainModelNode_e {
PLAYER_MAIN_NODE_CENTER = 0,
PLAYER_MAIN_NODE_BACKBONE_1 = 1,
PLAYER_MAIN_NODE_BACKBONE_2 = 2,
PLAYER_MAIN_NODE_HEAD = 4,
PLAYER_MAIN_NODE_POD = 5,
PLAYER_MAIN_NODE_ARM_L1 = 7,
PLAYER_MAIN_NODE_ARM_L2 = 8,
PLAYER_MAIN_NODE_HAND_L = 9,
PLAYER_MAIN_NODE_ARM_R1 = 12,
PLAYER_MAIN_NODE_ARM_R2 = 13,
PLAYER_MAIN_NODE_HAND_R = 14,
PLAYER_MAIN_NODE_WAIST = 16,
PLAYER_MAIN_NODE_FSKIRT_L1 = 27,
PLAYER_MAIN_NODE_FSKIRT_R1 = 29,
PLAYER_MAIN_NODE_RSKIRT_L1 = 31,
PLAYER_MAIN_NODE_RSKIRT_L2 = 32,
PLAYER_MAIN_NODE_RSKIRT_R1 = 33,
PLAYER_MAIN_NODE_RSKIRT_R2 = 34,
};
void fn_8005F890();
void fn_80061410();
static void freeFrmHeap(mHeapAllocator_c *allocator);
static void allocFrmHeap(mHeapAllocator_c *allocator, u32 size, const char *name);
void allocExternalDataBuffers();
void initModelHeaps();
void updateSwordShieldModelsIfNeeded();
m3d::anmTexSrt_c *createAnmTexSrt(const char *resName, m3d::bmdl_c &mdl);
static bool createGenericMdl(nw4r::g3d::ResMdl resMdl, m3d::mdl_c &mdl, mAllocator_c *alloc, u32 bufferOption);
static bool createGenericSmdl(nw4r::g3d::ResMdl resMdl, m3d::smdl_c &mdl, mAllocator_c *alloc, u32 bufferOption);
static void setTransformAndCalc(m3d::scnLeaf_c &lf, const mMtx_c *mtx);
static nw4r::g3d::ResFile getItemResFile(const char *name, mAllocator_c &allocator);
nw4r::g3d::ResFile getExternalCompressedFile(const char *name, const char *extension, void *dest, u32 maxSize);
nw4r::g3d::ResAnmChr getExternalAnmChr(const char *name, void *dest, u32 maxSize);
nw4r::g3d::ResAnmTexPat getExternalAnmTexPat(const char *name, void *dest, u32 maxSize);
nw4r::g3d::ResAnmTexSrt getExternalAnmTexSrt(const char *name, void *dest, u32 maxSize);
static bool isBodyAnmPart_0_2_4(s32 part);
void updateEarringsColor();
void loadBodyModels();
void loadBody();
void loadHandsModels();
void setSwordAnm(const char *name);
void initSwordModel();
void updateSwordModel();
void initShieldModel();
void updateShieldModel();
// Own virtual methods
/* vt 0x2E0 */ virtual void transformBackbone1(nw4r::g3d::WorldMtxManip *) {}
/* vt 0x2E4 */ virtual void transformModelCenter(mMtx_c *) {}
/* vt 0x2E8 */ virtual bool vt_0x2E8() {
return true;
}
/* vt 0x2EC */ virtual void isOnClawTargetMaybe(UNKWORD, mAng &a1, mAng &a2) {
a1.setR(0);
a2.setR(0);
}
/* vt 0x2F0 */ virtual bool isMPPose() {
return false;
}
/* vt 0x2F4 */ virtual bool isOnTightRope() {
return false;
}
/* vt 0x2F8 */ virtual bool isOnVines() {
return false;
}
/* vt 0x2FC */ virtual bool alwaysRet0() {
return 0;
}
/* vt 0x300 */ virtual bool canBlockAttack() {
return false;
}
/* vt 0x304 */ virtual const mVec3_c &vt_0x304() const {
return mVec3_c::Zero;
}
// r = 1, l = 0, backbone = 2
/* vt 0x308 */ virtual mAng getArmZRot(s32 which) {
return 0;
}
/* vt 0x30C */ virtual void vt_0x30C(mVec3_c &res) {
res = mVec3_c::Ex;
}
// Overrides
/* vt 0x0E4 */ virtual const mVec3_c &getCenterTranslation() const override {
return mCenterTranslation;
}
/* vt 0x0E8 */ virtual const mVec3_c &vt_0x0E8() const override {
return field_0x12F4;
}
/* vt 0x0EC */ virtual const mVec3_c &vt_0x0EC() const override {
return field_0x1294;
}
/* vt 0x0F0 */ virtual const mVec3_c &vt_0x0F0() const override {
return mTranslationHand[1];
}
/* vt 0x0F4 */ virtual const mVec3_c &vt_0x0F4() const override {
return mTranslationHand[0];
}
/* vt 0x114 */ virtual void somethingWithCarriedActorFlags() override;
/* vt 0x118 */ virtual dAcObjBase_c *getCurrentCarriedActor() override {
return mRef.get();
}
/* vt 0x18C */ virtual void getBodyMtx(mMtx_c *out_mtx, int boneIdx) override {
mMainMdl.getNodeWorldMtx(boneIdx, *out_mtx);
}
/* vt 0x190 */ virtual void getSheathModelMatrix(mMtx_c *out_mtx) override {
mSheathMdl.getLocalMtx();
}
/* vt 0x194 */ virtual void getSwordModelMatrix(mMtx_c *out_mtx) override {
mSwordMdl.getLocalMtx();
}
/* vt 0x198 */ virtual mAng vt_0x198() override {
return field_0x1268;
}
/* vt 0x19C */ virtual mAng vt_0x19C() override {
return field_0x126A;
}
u8 getHandMat(s32 idx) {
return field_0x1208[idx];
}
inline bool checkSwordAndMoreStates(u32 mask) const {
return (mSwordAndMoreStates & mask) != 0;
}
inline void offSwordAndMoreStates(u32 mask) {
mSwordAndMoreStates &= ~mask;
}
// Model callbacks - dropping the mdl argument, apparently
void mainModelTimingA(u32 nodeId, nw4r::g3d::ChrAnmResult *result);
void adjustMainModelChrAnm(PlayerMainModelNode_e nodeId, nw4r::g3d::ChrAnmResult *result);
void mainModelTimingB(u32 nodeId, nw4r::g3d::WorldMtxManip *result);
void adjustMainModelWorldMtx(PlayerMainModelNode_e nodeId, nw4r::g3d::WorldMtxManip *result);
void mainModelTimingC(nw4r::math::MTX34 *result);
void fn_8005E900(mMtx_c *, mAng, mAng, mAng, mVec3_c *, bool);
void fn_8005EA20(nw4r::g3d::WorldMtxManip*, mAng, mAng, mAng, mVec3_c *, bool);
static const PlayerAnimation sAnimations[443];
static const u8 sShieldDurabilities[10];
static const u8 sShieldRegenTimes[10];
protected:
/* 0x370 */ mHeapAllocator_c mModelAllocator;
/* 0x38C */ mHeapAllocator_c mSwordAllocator;
/* 0x3A8 */ mHeapAllocator_c mShieldAllocator;
/* 0x3C4 */ void *mpExternalAnmCharBuffer;
/* 0x3C8 */ nw4r::g3d::ResFile mSwordRes;
/* 0x3CC */ nw4r::g3d::ResFile mAlinkRes;
/* 0x3D0 */ nw4r::g3d::ResFile mPlCommonAnimeRes;
/* 0x3D4 */ nw4r::g3d::ResFile mPlCommonSoundRes;
/* 0x3D8 */ nw4r::g3d::ResFile mCurrentRes;
/* 0x3DC */ nw4r::g3d::ResFile mAlink2Res;
/* 0x3E0 */ daPlBaseMdl_c mMainMdl;
/* 0x440 */ daPlBaseMainCallback_c mMainBodyCallback;
/* 0x448 */ m3d::mdl_c mHeadMdl;
/* 0x46C */ daPlBaseHeadCallback_c mheadCallback;
/* 0x474 */ m3d::smdl_c mFaceMdl;
/* 0x490 */ m3d::anmChr_c mFaceAnmChr;
/* 0x4C8 */ void *mpAnmCharBuffer;
/* 0x4CC */ m3d::anmTexPat_c mFaceTexPat;
/* 0x4F8 */ void *mpTexPatBuffer;
/* 0x4FC */ m3d::anmTexSrt_c mFaceTexSrt;
/* 0x528 */ void *mpTexSrtBuffer;
/* 0x52C */ m3d::anmChr_c mHeadAnmChr;
/* 0x564 */ m3d::smdl_c mHandsMdl;
/* 0x580 */ daPlBaseCalcWorldCallback_c mCalcWorldCallback;
/* 0x588 */ daPlBaseScnObjCallback_c mScnObjCallback;
/* 0x598 */ m3d::smdl_c mSwordMdl;
/* 0x5B4 */ m3d::anmMatClr_c mSwordAnmMatClr;
/* 0x5E0 */ m3d::smdl_c mShieldMdl;
/* 0x5FC */ m3d::anmTexPat_c mShieldAnmTexPat1;
/* 0x628 */ m3d::anmTexPat_c mShieldAnmTexPat2;
/* 0x654 */ m3d::smdl_c mSheathMdl;
/* 0x670 */ m3d::smdl_c mUnkMdl1;
/* 0x68C */ m3d::anmChr_c mAnmChr;
/* 0x6C4 */ m3d::anmChrBlend_c mAnmChrBlend;
/* 0x6EC */ dScnCallback_c mScnCallback1;
/* 0x6F8 */ dScnCallback_c mScnCallback2;
/* 0x704 */ dScnCallback_c mScnCallback3;
/* 0x710 */ dScnCallback_c mScnCallback4;
/* 0x71C */ dScnCallback_c mScnCallback5;
/* 0x728 */ daPlBaseAnmChr_c mAnmChrs[6];
/* 0x878 */ dCcD_Cyl mCcCyls[3];
/* 0xC68 */ dCcD_Cps mCcCpss[3];
/* 0x10B8 */ dCcD_Cyl mCcCyl;
/* 0x1208 */ u8 field_0x1208[2];
/* 0x120A */ u8 field_0x120A;
/* 0x120B */ u8 mTunicType;
/* 0x120C */ u8 field_0x120C;
/* 0x120D */ u8 mShieldPouchSlot;
/* 0x120E */ s8 mPouchMatId;
/* 0x120F */ s8 mBeltMatId;
/* 0x1210 */ s8 mLowbodyMapId;
/* 0x1211 */ s8 mLowotherMapId;
/* 0x1212 */ s8 mPouch2MatId;
/* 0x1213 */ s8 mUpbodyMatId;
/* 0x1214 */ s8 mUpotherMatId;
/* 0x1215 */ s8 mBelt2MatId;
/* 0x1216 */ s8 mCapMatId;
/* 0x1217 */ s8 mSkinMatId;
/* 0x1218 */ u8 mSkywardStrikeChargeDuration;
/* 0x121A */ u16 mAnimations[6];
/* 0x1226 */ u16 mFaceAnmChrIdx1;
/* 0x1228 */ u16 mFaceAnmChrIdx2;
/* 0x122A */ u16 mFaceAnmTexPatIdx1;
/* 0x122C */ u16 mFaceAnmTexPatIdx2;
/* 0x122E */ u16 mFaceAnmTexSrtIdx1;
/* 0x1230 */ u16 mFaceAnmTexSrtIdx2;
/* 0x1232 */ u16 mBreakingEffect;
/* 0x1234 */ mAng mWaistZRot;
/* 0x1236 */ mAng mWaistYRot;
/* 0x1238 */ u8 _0x1238[0x125C - 0x1238];
/* 0x125C */ mAng mRSkirtR1Rot;
/* 0x125E */ mAng mRSkirtL1Rot;
/* 0x1260 */ mAng mRightHandRotation;
/* 0x1262 */ mAng mHeadZRot;
/* 0x1264 */ mAng mHeadYRot;
/* 0x1266 */ mAng mHeadXRot;
/* 0x1268 */ mAng field_0x1268;
/* 0x126A */ mAng field_0x126A;
/* 0x126C */ mAng field_0x126C;
/* 0x126E */ u8 _0x126C[0x1278 - 0x126E];
/* 0x1278 */ f32 field_0x1278;
/* 0x127C */ mVec3_c field_0x127C;
/* 0x1288 */ mVec3_c mCenterTranslation;
/* 0x1294 */ mVec3_c field_0x1294;
/* 0x12A0 */ mVec3_c field_0x12A0;
/* 0x12AC */ mVec3_c mTranslationHand[2];
/* 0x12C4 */ mVec3_c mTranslationWeapon[2];
/* 0x12DC */ mVec3_c mToeTranslation[2];
/* 0x12F4 */ mVec3_c field_0x12F4;
/* 0x1300 */ UnkPlayerClass mUnk_0x1300[4];
/* 0x1340 */ mQuat_c mQuat1;
/* 0x1350 */ mQuat_c mQuat2;
/* 0x1360 */ dAcRef_c<dAcObjBase_c> mRef; // not sure about the class
/* 0x136C */ mAng *field_0x136C;
/* 0x1370 */ mAng *field_0x1370;
};
// The split between daPlBase_c and dAcPy_c is somewhere after
// member offset 0x1368 and before 0x137C
class dAcPy_c : public daPlayerModelBase_c {
public:
dAcPy_c();
virtual ~dAcPy_c();
// argument is always false in existing code, true doesn't seem to make a difference
void bonk(bool unk = false);
bool fn_80202D90(bool);
/* overrides omitted */
/* vt 0x310 */ virtual void vt_0x310();
/* vt 0x314 */ virtual void vt_0x314();
/* vt 0x318 */ virtual void vt_0x318();
protected:
/* 0x1372 */ u8 _0x1374[0x4564 - 0x1374];
/* 0x4564 */ f32 field_0x4564;
public:
f32 getField_0x4564() const {
return field_0x4564;
}
f32 getSwordAnmFrame() const {
return mSwordAnmMatClr.getFrame(0);
}
nw4r::g3d::ResFile getSwordResFile() const {
return mSwordRes;
}
inline bool hasvt_0x1C0() const {
return vt_0x1C0() != nullptr;
}
@@ -867,8 +1123,6 @@ public:
return FileManager::GetInstance()->hasStaminaPotionPlus() && getRidingActorType() != RIDING_BOAT;
}
static nw4r::g3d::ResFile getItemResFile(const char *name, mAllocator_c &allocator);
static const dAcPy_c *GetLink() {
return LINK;
}
@@ -877,6 +1131,8 @@ public:
return LINK2;
}
void onShieldUpdate();
static dAcPy_c *LINK;
static dAcPy_c *LINK2;
@@ -884,7 +1140,6 @@ public:
static s32 getCurrentSlingshotType();
static s32 getCurrentBeetleType();
static s32 getCurrentBugNetType();
static s32 getCurrentlyEquippedShieldType();
static bool isInBambooCuttingMinigame();
+3
View File
@@ -3,6 +3,7 @@
#include "common.h"
#include "m/m_dvd.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "sized_string.h"
class ArcCallbackHandlerBase {
@@ -23,6 +24,8 @@ public:
static ArcCallbackHandler sInstance;
};
void BindSystemModelsAndLighting(nw4r::g3d::ResFile);
// TODO: loading status could be an enum (-2/-1/0/+1)
// Ghidra: ArcManagerEntry
+1
View File
@@ -136,6 +136,7 @@ public:
STATE_VIRTUAL_FUNC_DECLARE(dScGame_c, Stanby); // sic
STATE_VIRTUAL_FUNC_DECLARE(dScGame_c, Action);
static bool isHeroMode();
static bool isCurrentStage(const char *stageName);
static bool isStageSkyloftLayer20();
static bool isInCredits();
+12
View File
@@ -446,6 +446,18 @@ public:
}
}
static void setShieldMaxDurability(f32 durability) {
if (sInstance != nullptr) {
sInstance->mMain.mShield.setMaxDurability(durability);
}
}
static void setShieldId(s32 type) {
if (sInstance != nullptr) {
sInstance->mMain.mShield.setShieldId(type);
}
}
static f32 getShieldMaxDurability() {
if (sInstance != nullptr) {
return sInstance->mMain.mShield.getMaxDurability();
@@ -47,6 +47,14 @@ public:
return mMaxDurability;
}
void setMaxDurability(f32 durability) {
mMaxDurability = durability;
}
void setShieldId(s32 id) {
mShieldId = id;
}
private:
s32 getLytFrameForShield(s32) const;
void setLevel(f32 level);
@@ -77,7 +85,7 @@ private:
/* 0x30C */ u8 field_0x30C;
/* 0x30D */ u8 field_0x30D;
/* 0x30E */ u8 field_0x30E;
/* 0x310 */ s32 mShieldType;
/* 0x310 */ s32 mShieldId;
/* 0x314 */ s32 mSavedShieldType;
/* 0x318 */ s32 field_0x318;
/* 0x31C */ u8 field_0x31C;
+5
View File
@@ -21,6 +21,11 @@ public:
inline MEMAllocator *getHandle() {
return static_cast<MEMAllocator *>(this);
}
Heap *getHeap() {
return mHeap;
}
/* 0x14 */ Heap *mHeap;
/* 0x18 */ s32 align;
};
+17 -2
View File
@@ -5,13 +5,14 @@
#include "common.h"
#include "egg/core/eggDisposer.h"
#include "egg/core/eggThread.h"
#include "egg/egg_types.h"
#include "egg/prim/eggBitFlag.h"
#include "nw4r/ut.h"
#include "rvl/MEM.h"
#include "rvl/OS.h"
namespace EGG {
// class ExpHeap;
@@ -79,6 +80,20 @@ public:
return this;
}
static inline EGG::FrmHeap *toFrmHeap(EGG::Heap *heap) {
if (heap != nullptr && heap->getHeapKind() == HEAP_KIND_FRAME) {
return (FrmHeap *)heap;
}
return nullptr;
}
static inline EGG::ExpHeap *toExpHeap(EGG::Heap *heap) {
if (heap != nullptr && heap->getHeapKind() == HEAP_KIND_EXPANDED) {
return (ExpHeap *)heap;
}
return nullptr;
}
public:
// members
/* 0x10 */ MEMiHeapHead *mHeapHandle;
+4
View File
@@ -1,6 +1,7 @@
#ifndef M3D_M_ANMCHR_H
#define M3D_M_ANMCHR_H
#include "common.h"
#include "m/m3d/m_bmdl.h"
#include "m/m3d/m_fanm.h"
#include "nw4r/g3d/res/g3d_resanmchr.h"
@@ -13,6 +14,9 @@ public:
virtual int getType() const override;
bool create(nw4r::g3d::ResMdl mdl, nw4r::g3d::ResAnmChr anm, mAllocator_c *alloc) {
return create(mdl, anm, alloc, nullptr);
}
bool create(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmChr, mAllocator_c *, u32 *);
void setAnm(bmdl_c &, nw4r::g3d::ResAnmChr, playMode_e);
void setAnmAfter(bmdl_c &, nw4r::g3d::ResAnmChr, playMode_e);
+4
View File
@@ -1,6 +1,7 @@
#ifndef M3D_M_ANMCHRBLEND_H
#define M3D_M_ANMCHRBLEND_H
#include "common.h"
#include "m/m3d/m_anmchr.h"
#include "m/m3d/m_banm.h"
#include "m/m3d/m_bmdl.h"
@@ -14,6 +15,9 @@ public:
virtual int getType() const override;
bool create(nw4r::g3d::ResMdl mdl, int nView, mAllocator_c *alloc) {
return create(mdl, nView, alloc, nullptr);
}
bool create(nw4r::g3d::ResMdl, int, mAllocator_c *, u32 *);
void attach(int, nw4r::g3d::AnmObjChrRes *, f32);
void attach(int, anmChr_c *, f32);
+1 -1
View File
@@ -43,7 +43,7 @@ public:
mpBaseCallback = cb;
}
private:
protected:
/* 0x04 */ calcRatio_c mCalcRatio;
/* 0x20 */ int mNumNode;
/* 0x24 */ nw4r::g3d::ChrAnmResult *mpNodes;
+6
View File
@@ -32,6 +32,12 @@ public:
operator nw4r::math::MTX34 &() {
return *(nw4r::math::MTX34 *)(this);
}
operator const nw4r::math::MTX34 *() const {
return (nw4r::math::MTX34 *)(this);
}
operator const nw4r::math::MTX34 &() const {
return *(nw4r::math::MTX34 *)(this);
}
void XrotS(const mAng &angle); ///< Generates a rotation matrix for the X axis with the given angle.
void XrotM(const mAng &angle); ///< Rotates the matrix on the X axis by the given angle.
+5
View File
@@ -76,6 +76,11 @@ public:
}
}
// Not sure
void SetMtxUnchecked(const nw4r::math::MTX34 *arg) {
PSMTXCopy(*arg, *mpM);
}
private:
math::MTX34 *mpM; // at 0x0
math::VEC3 *mpS; // at 0x4
+9
View File
@@ -148,6 +148,15 @@ public:
return !(ref().flag & ResShpData::FLAG_INVISIBLE);
}
// Not sure, copied from ResNode
void SetVisibility(bool visible) {
if (visible) {
ptr()->flag &= ~ResShpData::FLAG_INVISIBLE;
} else {
ptr()->flag |= ResShpData::FLAG_INVISIBLE;
}
}
void DCStore(bool sync);
};
+8
View File
@@ -0,0 +1,8 @@
#ifndef CX_UTIL_H
#define CX_UTIL_H
#include "common.h"
bool lzSafeDecompress(const void *src, u32 maxSize, void *dest);
#endif
-1
View File
@@ -5,7 +5,6 @@
#include "m/m3d/m_scnleaf.h"
#include "nw4r/g3d/g3d_scnobj.h"
class dScnCallback_c : public nw4r::g3d::IScnObjCallback {
public:
dScnCallback_c(dAcObjBase_c *arg) : mpActor(arg) {}