Skip to content

Commit

Permalink
d_a_obj_lpalm work
Browse files Browse the repository at this point in the history
  • Loading branch information
magcius committed Aug 3, 2024
1 parent 0f1eae5 commit d2b9d15
Show file tree
Hide file tree
Showing 2 changed files with 167 additions and 25 deletions.
21 changes: 14 additions & 7 deletions include/d/actor/d_a_obj_lpalm.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,31 @@
class daObjLpalm_c : public fopAc_ac_c {
public:
inline s32 _create();
inline BOOL _delete();
inline BOOL _draw();
inline BOOL _execute();
void attr() const {}
inline bool _delete();
inline bool _draw();
inline bool _execute();
void set_mtx() {}

void CreateHeap();
BOOL CreateHeap();
void CreateInit();

struct Attr_c {
u8 flag0;
u8 flag1;
};
static const Attr_c M_attr;
inline const Attr_c& attr() const { return M_attr; }
static const char M_arcname[];

public:
/* 0x290 */ u8 m290[0x294 - 0x290];
/* 0x294 */ Quaternion mBaseQuat;
/* 0x2A4 */ Quaternion mBaseQuatTarget;
/* 0x2B4 */ Quaternion mAnmMtxQuat[2];
/* 0x2D4 */ s16 mAnimDir[2];
/* 0x2D8 */ s16 mAnimWave[2];
/* 0x2DC */ request_of_phase_process_class mpPhaseLoad;
/* 0x2E4 */ J3DModel* mpModel;
/* 0x2DC */ request_of_phase_process_class mPhs;
/* 0x2E4 */ J3DModel* mModel;
/* 0x2E8 */ dBgW* mpBgW;
};

Expand Down
171 changes: 153 additions & 18 deletions src/d/actor/d_a_obj_lpalm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,192 @@
//

#include "d/actor/d_a_obj_lpalm.h"
#include "m_Do/m_Do_ext.h"
#include "d/d_com_inf_game.h"
#include "d/d_kankyo_wether.h"
#include "d/d_procname.h"
#include "d/res/res_oyashi.h"
#include "m_Do/m_Do_ext.h"

const char daObjLpalm_c::M_arcname[7] = "Oyashi";
daObjLpalm_c::Attr_c const daObjLpalm_c::M_attr = { 0, 0 };

/* 00000078-00000098 .text CheckCreateHeap__FP10fopAc_ac_c */
static BOOL CheckCreateHeap(fopAc_ac_c*) {
/* Nonmatching */
static BOOL CheckCreateHeap(fopAc_ac_c* i_this) {
return ((daObjLpalm_c*)i_this)->CreateHeap();
}

/* 00000098-00000164 .text nodeCallBack__FP7J3DNodei */
static BOOL nodeCallBack(J3DNode*, int) {
/* Nonmatching */
static BOOL nodeCallBack(J3DNode* joint, int timing) {
J3DModel* model = j3dSys.getModel();
s32 jntNo = ((J3DJoint*)joint)->getJntNo();
daObjLpalm_c* i_this = (daObjLpalm_c*)model->getUserArea();
if (timing == 0 && (jntNo == 2 || jntNo == 3)) {
mDoMtx_stack_c::copy(model->getAnmMtx(jntNo));
mDoMtx_stack_c::ZrotM(-0x4000);
mDoMtx_stack_c::quatM(&i_this->mBaseQuat);
if (jntNo == 2)
mDoMtx_stack_c::quatM(&i_this->mAnmMtxQuat[0]);
else
mDoMtx_stack_c::quatM(&i_this->mAnmMtxQuat[1]);
mDoMtx_stack_c::ZrotM(0x4000);
model->setAnmMtx(jntNo, mDoMtx_stack_c::get());
}

return TRUE;
}

/* 00000164-00000268 .text CreateHeap__12daObjLpalm_cFv */
void daObjLpalm_c::CreateHeap() {
/* Nonmatching */
BOOL daObjLpalm_c::CreateHeap() {
J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes(M_arcname, OYASHI_BDL_OYASHI);
for (u16 i = 0; i < modelData->getJointNum(); i++)
modelData->getJointNodePointer(i)->setCallBack(nodeCallBack);
if (modelData == NULL)
return false;

mModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000002);
if (mModel == NULL)
return false;

mModel->setUserArea((u32)this);
Mtx* mtx = &mModel->getBaseTRMtx();
cBgD_t* bgp = (cBgD_t*)dComIfG_getObjectRes(M_arcname, OYASHI_DZB_OYASHI);
mpBgW = dBgW_NewSet(bgp, dBgW::MOVE_BG_e, mtx);
if (mpBgW == NULL)
return false;

return true;
}

/* 00000268-00000404 .text CreateInit__12daObjLpalm_cFv */
void daObjLpalm_c::CreateInit() {
/* Nonmatching */
Quaternion q = { 0.0f, 0.0f, 0.0f, 1.0f };
mBaseQuatTarget = q;
mBaseQuat = q;
mAnmMtxQuat[1] = mAnmMtxQuat[0] = q;
mAnimDir[0] = 0;
mAnimDir[1] = 0;
mAnimWave[0] = 0;
mAnimWave[1] = cM_rndFX(32768.0f);
fopAcM_SetMtx(this, mModel->getBaseTRMtx());
fopAcM_setCullSizeBox(this,-350.0f, -50.0f, -350.0f, 350.0f, 1300.0f, 350.0f);
fopAcM_setCullSizeFar(this, 2.37f);
dComIfG_Bgsp()->Regist(mpBgW, this);
mModel->setBaseScale(scale);
mDoMtx_stack_c::transS(current.pos);
mDoMtx_stack_c::ZXYrotM(shape_angle);
mModel->setBaseTRMtx(mDoMtx_stack_c::get());
}

s32 daObjLpalm_c::_create() {
fopAcM_SetupActor(this, daObjLpalm_c);

s32 ret = dComIfG_resLoad(&mPhs, M_arcname);

if (ret == cPhs_COMPLEATE_e) {
if (fopAcM_entrySolidHeap(this, CheckCreateHeap, 0xf00) == 0) {
ret = cPhs_ERROR_e;
} else {
CreateInit();
}
}

return ret;
}

bool daObjLpalm_c::_delete() {
if (heap != NULL && mpBgW->ChkUsed()) {
dComIfG_Bgsp()->Release(mpBgW);
}

dComIfG_resDelete(&mPhs, M_arcname);
return true;
}

/* 00000404-000004A4 .text daObjLpalmCreate__FPv */
static s32 daObjLpalmCreate(void*) {
/* Nonmatching */
static s32 daObjLpalmCreate(void* i_this) {
return ((daObjLpalm_c*)i_this)->_create();
}

/* 000004A4-00000528 .text daObjLpalmDelete__FPv */
static BOOL daObjLpalmDelete(void*) {
/* Nonmatching */
static BOOL daObjLpalmDelete(void* i_this) {
return ((daObjLpalm_c*)i_this)->_delete();
}

/* 00000528-0000054C .text daObjLpalmExecute__FPv */
static BOOL daObjLpalmExecute(void*) {
/* Nonmatching */
static BOOL daObjLpalmExecute(void* i_this) {
return ((daObjLpalm_c*)i_this)->_execute();
}

/* 0000054C-000008C4 .text _execute__12daObjLpalm_cFv */
BOOL daObjLpalm_c::_execute() {
bool daObjLpalm_c::_execute() {
/* Nonmatching */
if (attr().flag0)
return true;

Quaternion q;
cXyz up(0.0f, 1.0f, 0.0f);
cXyz windDir;

mDoMtx_YrotS(*calc_mtx, -current.angle.y);
MtxPosition(dKyw_get_wind_vec(), &windDir);
f32 windPow = dKyw_get_wind_pow();
s16 angle = windPow * 0x600;
cXyz dir = up.outprod(windDir);
f32 mag = dir.abs();
if (mag < 8e-09) {
mBaseQuatTarget.x = 0.0f;
mBaseQuatTarget.y = 0.0f;
mBaseQuatTarget.z = 0.0f;
mBaseQuatTarget.w = 1.0f;
} else {
f32 sin = cM_ssin(angle);
dir = dir.normZP();
mBaseQuatTarget.x = sin * dir.x;
mBaseQuatTarget.y = sin * dir.y;
mBaseQuatTarget.z = sin * dir.z;
mBaseQuatTarget.w = cM_scos(angle);
}

mDoMtx_quatSlerp(&mBaseQuat, &mBaseQuatTarget, &q, 0.25f);
mBaseQuat = q;

for (s32 i = 0; i < 2; i++) {
s16 target = windPow * 0x180;
if (target > 0x100)
target = 0x100;
cLib_addCalcAngleS2(&mAnimDir[i], target, 4, 0x20);
s32 add = (windPow * 0x800) + cM_rndFX(128.0f);
mAnimWave[i] += add;
f32 w = cM_ssin(mAnimDir[i]);
mAnmMtxQuat[i].x = cM_ssin(mAnimWave[i]) * w;
mAnmMtxQuat[i].y = 0.0f;
mAnmMtxQuat[i].z = cM_ssin(mAnimWave[i]) * w;
mAnmMtxQuat[i].w = cM_scos(mAnimDir[i]);
}

mpBgW->Move();
return false;
}

bool daObjLpalm_c::_draw() {
if (attr().flag1)
return true;

g_env_light.settingTevStruct(TEV_TYPE_BG0, &current.pos, &tevStr);
g_env_light.setLightTevColorType(mModel, &tevStr);
mDoExt_modelUpdateDL(mModel);
return true;
}

/* 000008C4-00000950 .text daObjLpalmDraw__FPv */
static BOOL daObjLpalmDraw(void*) {
/* Nonmatching */
static BOOL daObjLpalmDraw(void* i_this) {
return ((daObjLpalm_c*)i_this)->_draw();
}

/* 00000950-00000958 .text daObjLpalmIsDelete__FPv */
static BOOL daObjLpalmIsDelete(void*) {
/* Nonmatching */
static BOOL daObjLpalmIsDelete(void* i_this) {
return TRUE;
}

static actor_method_class daObjLpalmMethodTable = {
Expand Down

0 comments on commit d2b9d15

Please sign in to comment.