From 4470b7df8aec57c03d50f44f3e7673cb4c96ca4d Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 27 Dec 2024 12:23:32 -0800 Subject: [PATCH] d_a_demo00 work --- include/d/actor/d_a_demo00.h | 70 ++++++++++++--- include/d/d_demo.h | 4 +- include/d/d_kankyo.h | 6 -- include/d/d_kankyo_demo.h | 18 ++++ src/d/actor/d_a_demo00.cpp | 169 ++++++++++++++++++++++++++++++----- src/d/d_kankyo_demo.cpp | 1 + 6 files changed, 227 insertions(+), 41 deletions(-) create mode 100644 include/d/d_kankyo_demo.h diff --git a/include/d/actor/d_a_demo00.h b/include/d/actor/d_a_demo00.h index 861beaf6b..018b6799e 100644 --- a/include/d/actor/d_a_demo00.h +++ b/include/d/actor/d_a_demo00.h @@ -4,40 +4,88 @@ #include "f_op/f_op_actor.h" class dDemo_actor_c; +class mDoExt_McaMorf; +class J3DModel; +class mDoExt_invisibleModel; +class mDoExt_btpAnm; +class mDoExt_btkAnm; +class mDoExt_brkAnm; +struct DEMO_PLIGHT; +class dBgS_GndChk; -class daDemo00_model_c { +class daDemo00_shadow_c { +public: + /* 0x00 */ u32 shadowID; + /* 0x04 */ cXyz pos; + /* 0x10 */ f32 field_0x10; + /* 0x14 */ f32 field_0x14; +}; + +class daDemo00_resID_c { public: void reset(); public: - /* Place member variables here */ + /* 0x00 */ s32 modelID; + /* 0x04 */ s32 bckID; + /* 0x08 */ s32 field_0x08; + /* 0x0C */ s32 btpID; + /* 0x10 */ s32 btkID; + /* 0x14 */ s32 brkID; + /* 0x18 */ s32 field_0x18; + /* 0x1C */ s32 field_0x1C; + /* 0x20 */ s32 plightID; + /* 0x24 */ s32 shadowID; }; -class daDemo00_resID_c { +class daDemo00_model_c { public: void reset(); public: - /* Place member variables here */ + /* 0x00 */ daDemo00_resID_c resID; + /* 0x28 */ mDoExt_McaMorf* morf; + /* 0x2C */ J3DModel* model; + /* 0x30 */ mDoExt_invisibleModel* invisibleModel; + /* 0x34 */ mDoExt_btpAnm* btpAnm; + /* 0x38 */ mDoExt_btkAnm* btkAnm; + /* 0x3C */ mDoExt_brkAnm* brkAnm; + /* 0x40 */ void * field_0x40; + /* 0x44 */ daDemo00_shadow_c* shadow; + /* 0x48 */ DEMO_PLIGHT* plight; +}; + +class daDemo00_bgc_c { }; class daDemo00_c : public fopAc_ac_c { public: - void action(dDemo_actor_c*) {} - void setAction(int (daDemo00_c::*)(dDemo_actor_c*)) {} + ~daDemo00_c(); + + typedef BOOL (daDemo00_c::*ActionFunc)(dDemo_actor_c* act); + + BOOL action(dDemo_actor_c* act) { return (this->*actionFunc)(act); } + void setAction(ActionFunc func) { actionFunc = func; } void setBaseMtx(); void setShadowSize(); - void createHeap(); - void actStandby(dDemo_actor_c*); - void actPerformance(dDemo_actor_c*); - void actLeaving(dDemo_actor_c*); + BOOL createHeap(); + BOOL actStandby(dDemo_actor_c*); + BOOL actPerformance(dDemo_actor_c*); + BOOL actLeaving(dDemo_actor_c*); inline BOOL create(); BOOL draw(); BOOL execute(); public: - /* Place member variables here */ + /* 0x290 */ ActionFunc actionFunc; + /* 0x29C */ u8 field_0x29c; + /* 0x29D */ s8 field_0x29d; + /* 0x29E */ u8 field_0x29e; + /* 0x29F */ u8 field_0x29f; + /* 0x2A0 */ daDemo00_resID_c nextRes; + /* 0x2C8 */ daDemo00_model_c model; + /* 0x314 */ dBgS_GndChk* chk; }; #endif /* D_A_DEMO00_H */ diff --git a/include/d/d_demo.h b/include/d/d_demo.h index 9245d5e32..2927c715d 100644 --- a/include/d/d_demo.h +++ b/include/d/d_demo.h @@ -80,8 +80,8 @@ class dDemo_actor_c : public JStage::TActor { void getScale() {} void getTrans() {} void onEnable(u16) {} - void setAnmFrameMax(f32) {} - void setModel(J3DModel*) {} + void setAnmFrameMax(f32 v) { mAnimationFrameMax = v; } + void setModel(J3DModel* model) { mModel = model; } void setOldAnmId(u32) {} void setOldScrId(u32) {} void setOldTevId(u32) {} diff --git a/include/d/d_kankyo.h b/include/d/d_kankyo.h index 88c1bfa96..bc61f8c2f 100644 --- a/include/d/d_kankyo.h +++ b/include/d/d_kankyo.h @@ -106,12 +106,6 @@ struct WAVE_INFO { /* 0x14 */ f32 field_0x14; }; -struct DEMO_PLIGHT { - /* 0x00 */ int field_0x00; - /* 0x04 */ int field_0x04; - /* 0x08 */ LIGHT_INFLUENCE mLightInfluence; -}; - class dKy_tevstr_c { public: /* 0x00 */ J3DLightObj mLightObj; diff --git a/include/d/d_kankyo_demo.h b/include/d/d_kankyo_demo.h new file mode 100644 index 000000000..58b449e82 --- /dev/null +++ b/include/d/d_kankyo_demo.h @@ -0,0 +1,18 @@ +#ifndef D_KANKYO_DEMO_H +#define D_KANKYO_DEMO_H + +#include "d/d_kankyo.h" + +struct cXyz; + +struct DEMO_PLIGHT { + /* 0x00 */ int field_0x00; + /* 0x04 */ int field_0x04; + /* 0x08 */ LIGHT_INFLUENCE mLightInfluence; +}; + +void dKydm_demo_plight_entry(DEMO_PLIGHT* i_plight, cXyz* i_pos, int param_2, u8 param_3); +void dKydm_demo_plight_delete(DEMO_PLIGHT* i_plight); +void dKydm_demo_plight_execute(DEMO_PLIGHT* i_plight); + +#endif /* D_KANKYO_DEMO_H */ diff --git a/src/d/actor/d_a_demo00.cpp b/src/d/actor/d_a_demo00.cpp index b5a981039..570257a03 100644 --- a/src/d/actor/d_a_demo00.cpp +++ b/src/d/actor/d_a_demo00.cpp @@ -4,61 +4,179 @@ // #include "d/actor/d_a_demo00.h" +#include "JSystem/J3DGraphAnimator/J3DSkinDeform.h" +#include "JSystem/J3DGraphBase/J3DSys.h" +#include "JSystem/J3DGraphBase/J3DTexture.h" +#include "JSystem/JUtility/JUTNameTab.h" +#include "SSystem/SComponent/c_phase.h" +#include "d/d_com_inf_game.h" +#include "d/d_demo.h" +#include "d/d_kankyo.h" +#include "d/d_kankyo_demo.h" #include "d/d_procname.h" +#include "f_op/f_op_actor_mng.h" +#include "m_Do/m_Do_ext.h" +#include "m_Do/m_Do_graphic.h" +#include "m_Do/m_Do_mtx.h" +#include "JSystem/J3DGraphAnimator/J3DModel.h" +#include "JSystem/J3DGraphAnimator/J3DModelData.h" +#include "string.h" /* 800E595C-800E598C .text reset__16daDemo00_resID_cFv */ void daDemo00_resID_c::reset() { - /* Nonmatching */ + modelID = -1; + bckID = -1; + field_0x08 = -1; + btpID = -1; + btkID = -1; + brkID = -1; + field_0x18 = -1; + field_0x1C = -1; + plightID = -1; + shadowID = -1; } /* 800E598C-800E59EC .text reset__16daDemo00_model_cFv */ void daDemo00_model_c::reset() { - /* Nonmatching */ + resID.reset(); + model = NULL; + btpAnm = NULL; + btkAnm = NULL; + brkAnm = NULL; + if (plight != NULL) { + dKydm_demo_plight_delete(plight); + plight = NULL; + } + shadow = NULL; +} + +daDemo00_c::~daDemo00_c() { + if (heap != NULL && model.morf != NULL) { + model.morf->stopZelAnime(); + } } /* 800E5A60-800E5AFC .text setBaseMtx__10daDemo00_cFv */ void daDemo00_c::setBaseMtx() { - /* Nonmatching */ + mDoMtx_stack_c::transS(current.pos); + mDoMtx_stack_c::XYZrotM(shape_angle); + model.model->setBaseTRMtx(mDoMtx_stack_c::get()); + model.model->setBaseScale(scale); + model.model->calc(); } /* 800E5AFC-800E5DEC .text setShadowSize__10daDemo00_cFv */ void daDemo00_c::setShadowSize() { - /* Nonmatching */ + J3DModelData* modelData = model.model->getModelData(); + + cXyz min(1000000000.0f, 1000000000.0f, 1000000000.0f); + cXyz max(-1000000000.0f, -1000000000.0f, -1000000000.0f); + + for (u16 i = 0; i < modelData->getJointNum(); i++) { + J3DJoint* joint = modelData->getJointNodePointer(i); + if (joint->getKind() == 0) { + cXyz jntMin; + cXyz jntMax; + + mDoMtx_multVec(model.model->getAnmMtx(i), joint->getMin(), &jntMin); + mDoMtx_multVec(model.model->getAnmMtx(i), joint->getMax(), &jntMax); + min.x = jntMin.x < min.x ? jntMin.x : min.x; + min.y = jntMin.y < min.y ? jntMin.y : min.y; + min.z = jntMin.z < min.z ? jntMin.z : min.z; + max.x = jntMax.x > max.x ? jntMax.x : max.x; + max.y = jntMax.y > max.y ? jntMax.y : max.y; + max.z = jntMax.z > max.z ? jntMax.z : max.z; + } + } + + model.shadow->pos.x = (max.x + min.x) * 0.5f; + model.shadow->pos.y = (max.y + min.y) * 0.5f; + model.shadow->pos.z = (max.z + min.z) * 0.5f; + + cXyz extents = max - min; + model.shadow->field_0x10 = extents.abs() * 3.0f; + model.shadow->field_0x14 = extents.absXZ() * 0.25f; } /* 800E5DEC-800E5FF4 .text awaCheck__FP8J3DModel */ -void awaCheck(J3DModel*) { - /* Nonmatching */ +BOOL awaCheck(J3DModel* model) { + J3DModelData* modelData = model->getModelData(); + J3DTexture* tex = modelData->getTexture(); + if (tex != NULL) { + JUTNameTab* texName = modelData->getTextureName(); + if (texName != NULL) { + for (u16 i = 0; i < tex->getNum(); i++) { + const char* name = texName->getName(i); + if (strcmp(name, "B_dummy") == 0 || strcmp(name, "cy_kankyo") == 0) { + J3DSkinDeform* deform = new J3DSkinDeform(); + if (deform == NULL) + return FALSE; + + if (model->setSkinDeform(deform, 1) != J3DErrType_Success) + return FALSE; + + if (strcmp(name, "B_dummy") == 0) { + tex->setResTIMG(i, *mDoGph_gInf_c::getFrameBufferTimg()); + mDoExt_modelTexturePatch(modelData); + } + } + } + } + } + return TRUE; } /* 800E5FF4-800E6014 .text createHeapCallBack__FP10fopAc_ac_c */ -static BOOL createHeapCallBack(fopAc_ac_c*) { - /* Nonmatching */ +static BOOL createHeapCallBack(fopAc_ac_c* i_this) { + return ((daDemo00_c*)i_this)->createHeap(); } /* 800E6014-800E6620 .text createHeap__10daDemo00_cFv */ -void daDemo00_c::createHeap() { +BOOL daDemo00_c::createHeap() { /* Nonmatching */ } /* 800E6620-800E6758 .text actStandby__10daDemo00_cFP13dDemo_actor_c */ -void daDemo00_c::actStandby(dDemo_actor_c*) { +BOOL daDemo00_c::actStandby(dDemo_actor_c* act) { /* Nonmatching */ + if (nextRes.modelID != 0xFFFF || nextRes.plightID != 0xFFFF) { + model.resID = nextRes; + if (fopAcM_entrySolidHeap(this, createHeapCallBack, 0x4000) != 0) { + if (model.model != NULL) { + setBaseMtx(); + fopAcM_SetMtx(this, model.model->getBaseTRMtx()); + act->setModel(model.model); + if (model.morf != NULL) + act->setAnmFrameMax(model.morf->getEndFrame()); + } + + setAction(&daDemo00_c::actPerformance); + } + } + + return TRUE; } /* 800E6758-800E6E2C .text actPerformance__10daDemo00_cFP13dDemo_actor_c */ -void daDemo00_c::actPerformance(dDemo_actor_c*) { +BOOL daDemo00_c::actPerformance(dDemo_actor_c*) { /* Nonmatching */ } /* 800E6E2C-800E6E90 .text actLeaving__10daDemo00_cFP13dDemo_actor_c */ -void daDemo00_c::actLeaving(dDemo_actor_c*) { +BOOL daDemo00_c::actLeaving(dDemo_actor_c* act) { /* Nonmatching */ + if (model.morf != NULL) { + model.morf->stopZelAnime(); + } + + fopAcM_DeleteHeap(this); + setAction(&daDemo00_c::actStandby); + return TRUE; } /* 800E6E90-800E6EB0 .text daDemo00_Draw__FP10daDemo00_c */ -static BOOL daDemo00_Draw(daDemo00_c*) { - /* Nonmatching */ +static BOOL daDemo00_Draw(daDemo00_c* i_this) { + return i_this->draw(); } /* 800E6EB0-800E7204 .text draw__10daDemo00_cFv */ @@ -67,8 +185,8 @@ BOOL daDemo00_c::draw() { } /* 800E7204-800E7224 .text daDemo00_Execute__FP10daDemo00_c */ -static BOOL daDemo00_Execute(daDemo00_c*) { - /* Nonmatching */ +static BOOL daDemo00_Execute(daDemo00_c* i_this) { + return i_this->execute(); } /* 800E7224-800E78A0 .text execute__10daDemo00_cFv */ @@ -77,18 +195,25 @@ BOOL daDemo00_c::execute() { } /* 800E78A0-800E78A8 .text daDemo00_IsDelete__FP10daDemo00_c */ -static BOOL daDemo00_IsDelete(daDemo00_c*) { - /* Nonmatching */ +static BOOL daDemo00_IsDelete(daDemo00_c* i_this) { + return TRUE; } /* 800E78A8-800E78D0 .text daDemo00_Delete__FP10daDemo00_c */ -static BOOL daDemo00_Delete(daDemo00_c*) { - /* Nonmatching */ +static BOOL daDemo00_Delete(daDemo00_c* i_this) { + i_this->~daDemo00_c(); + return TRUE; } /* 800E78D0-800E7964 .text daDemo00_Create__FP10fopAc_ac_c */ -static s32 daDemo00_Create(fopAc_ac_c*) { - /* Nonmatching */ +static s32 daDemo00_Create(fopAc_ac_c* i_ac) { + daDemo00_c* i_this = (daDemo00_c*)i_ac; + fopAcM_SetupActor(i_this, daDemo00_c); + dKy_tevstr_init(&i_this->tevStr, dComIfGp_roomControl_getStayNo(), 0xFF); + i_this->setAction(&daDemo00_c::actStandby); + i_this->nextRes.reset(); + i_this->field_0x29d = -1; + return cPhs_COMPLEATE_e; } static actor_method_class l_daDemo00_Method = { diff --git a/src/d/d_kankyo_demo.cpp b/src/d/d_kankyo_demo.cpp index dcc10a2be..9caf5c5d2 100644 --- a/src/d/d_kankyo_demo.cpp +++ b/src/d/d_kankyo_demo.cpp @@ -4,6 +4,7 @@ */ #include "d/d_kankyo.h" +#include "d/d_kankyo_demo.h" /* 8009BE64-8009BF6C .text dKydm_demo_plight_entry__FP11DEMO_PLIGHTP4cXyziUc */ void dKydm_demo_plight_entry(DEMO_PLIGHT* i_plight, cXyz* i_pos, int param_2, u8 param_3) {