diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/00_Core/Item/ItemManager.cpp | 2 | ||||
| -rw-r--r-- | src/00_Core/Render/ModelRender.cpp | 195 | ||||
| -rw-r--r-- | src/04_Load/Actor/Navi/ActorNavi_04.cpp | 4 | ||||
| -rw-r--r-- | src/58_Bombchu/Player/EquipBombchu.cpp | 4 | ||||
| -rw-r--r-- | src/59_Hammer/Actor/Navi/ActorNaviBase_59.cpp | 2 |
5 files changed, 178 insertions, 29 deletions
diff --git a/src/00_Core/Item/ItemManager.cpp b/src/00_Core/Item/ItemManager.cpp index c15eafe4..2e1f3c01 100644 --- a/src/00_Core/Item/ItemManager.cpp +++ b/src/00_Core/Item/ItemManager.cpp @@ -556,7 +556,7 @@ THUMB void ItemManager::LoadFanfareItem(ItemId id) { strcat(textureName, sSpecialItemModelNames[6]);
model = LoadNsbTexturedModel(mFanfareItemModel, modelName, textureName, 0, 0, 0, true);
}
- mUnk_114->vfunc_0c(model);
+ mUnk_114->Init_ModelRender_UnkStruct_4(model);
}
THUMB bool ItemManager::GetFanfareItemScale(Vec3p *scale) const {
diff --git a/src/00_Core/Render/ModelRender.cpp b/src/00_Core/Render/ModelRender.cpp index 92d32375..cd984739 100644 --- a/src/00_Core/Render/ModelRender.cpp +++ b/src/00_Core/Render/ModelRender.cpp @@ -1,25 +1,174 @@ #include "Render/ModelRender.hpp" +#include "DTCM/UnkStruct_027e037c.hpp" -ModelRender::ModelRender(ItemModel *param1) {} -ModelRender::~ModelRender() {} -void *ModelRender::GetLcdcAddress() {} -void ModelRender::vfunc_0c(ItemModel *model) {} -void *ModelRender::func_ov000_020a9624(s32 param1) {} -void ModelRender::SetTransform(Vec3p *scale, Mat3p *rotation, Vec3p *translation) {} -void ModelRender::SetRotationTranslation(Mat3p *rotation, Vec3p *translation) {} -void ModelRender::SetTranslation(Vec3p *translation) {} -void ModelRender::PushGeometryCommands() {} -void ModelRender::vfunc_20() {} -void ModelRender::vfunc_24(UnkStruct_ov000_020c0c08 *param1) {} -void ModelRender::vfunc_28() {} -void ModelRender::vfunc_2c() {} -void ModelRender::vfunc_34() {} -void ModelRender::vfunc_30() {} -void ModelRender::func_ov000_020a98e8(unk32 param1) {} -void ModelRender::func_ov000_020a990c(unk32 param1) {} -void ModelRender::func_ov000_020a9938(unk32 param1) {} -void ModelRender::func_ov000_020a9960(void *param1) {} -void ModelRender::vfunc_38() {} -void ModelRender::vfunc_3c() {} -void ModelRender::func_ov000_020a9998(unk32 param1, unk32 param2) {} -void ModelRender::func_ov000_020a99c0() {} +extern "C" void func_020189dc(ModelRender_UnkStruct_4 *unkStruct4, ItemModel *model); +extern "C" void func_02018c3c(ModelRender_UnkStruct_4 *unkStruct4, void *param2); +extern "C" void UnkInit_ModelRender_Struct4_Params(ModelRender_UnkStruct_4 *unkStruct4, + void (*func)(ModelRenderCommandsData *), unk32 param3, u8 param4, + u8 param5); +extern "C" void ExecModelRenderCommands(ModelRender_UnkStruct_4 *unkStruct4); +extern "C" void CopySingle288(Mat3p *src, Mat3p *dest); +extern "C" void SetGeometryScale(Vec3p *scale); +extern "C" void SetGeometryTranslation(Vec3p *translation); +extern "C" void PushGeometryCommand(u32 command, void *data, s32 length); +extern "C" void func_ov000_020c0d70(UnkStruct_ov000_020c0c08 *param1, ModelRender_UnkStruct_4 *param2); +extern "C" void func_ov000_020b3ea8(void *param1); +extern "C" unk32 func_0201e388(void *param1, const char *param2); +extern "C" u8 *GetModelUnknownHeader(ModelRender *modelRender); +extern "C" Mat3p gGeomMatrix; +extern "C" Vec3p gGeomTranslation; +extern "C" Vec3p gGeomScale; +extern "C" UnkStruct_027e037c data_027e037c; +extern "C" void *data_027e03c8; +extern "C" Vec3p gDefaultScale; +extern "C" Mat3p gDefaultMatrix; +extern "C" u32 *data_027e0ce0[]; + +THUMB ModelRender::ModelRender(ItemModel *itemModel) { + this->unkBoneMatrixArray2 = NULL; + this->Init_ModelRender_UnkStruct_4(itemModel); +} + +THUMB ModelRender::~ModelRender() { + if (this->unkBoneMatrixArray2 != NULL) { + SysObject::operator delete[](this->unkBoneMatrixArray2); + } + func_ov000_020b3ea8(this); +} + +ARM void *ModelRender::GetLcdcAddress() { + return mUnk_04.mLcdcAddr; +} + +void ModelRender::Init_ModelRender_UnkStruct_4(ItemModel *model) { + func_020189dc(&this->mUnk_04, model); +} + +ModelRender_UnkBoneMatrixStruct *ModelRender::UnkGetBoneMatrix(s32 index) { + if (this->unkBoneMatrixArray2 != NULL) { + return &this->unkBoneMatrixArray2[index]; + } + if (this->mUnk_04.unkBoneMatrixArray1 != NULL) { + return &this->mUnk_04.unkBoneMatrixArray1[index]; + } + return NULL; +} + +void ModelRender::SetTransform(Vec3p *scale, Mat3p *rotation, Vec3p *translation) { + SetGeometryScale(scale); + CopySingle288(rotation, &gGeomMatrix); + data_027e037c.flags = data_027e037c.flags & 0xffffff5b; + SetGeometryTranslation(translation); + this->PushGeometryCommands(); + SetGeometryScale(&gDefaultScale); + CopySingle288(&gDefaultMatrix, &gGeomMatrix); + data_027e037c.flags = data_027e037c.flags & 0xffffff5b; +} + +void ModelRender::SetRotationTranslation(Mat3p *rotation, Vec3p *translation) { + CopySingle288(rotation, &gGeomMatrix); + data_027e037c.flags = data_027e037c.flags & 0xffffff5b; + SetGeometryTranslation(translation); + this->PushGeometryCommands(); + CopySingle288(&gDefaultMatrix, &gGeomMatrix); + data_027e037c.flags = data_027e037c.flags & 0xffffff5b; +} + +void ModelRender::SetTranslation(Vec3p *translation) { + SetGeometryTranslation(translation); + this->PushGeometryCommands(); +} + +void ModelRender::PushGeometryCommands() { + PushGeometryCommand(0x1c, &gGeomTranslation.x, 3); + PushGeometryCommand(0x1a, &gGeomMatrix, 9); + PushGeometryCommand(0x1b, &gGeomScale.x, 3); + this->ExecRenderCommands(); + PushGeometryCommand(0x17, &data_027e03c8, 0xc); +} + +void ModelRender::ExecRenderCommands() { + ExecModelRenderCommands(&this->mUnk_04); +} + +void ModelRender::vfunc_24(UnkStruct_ov000_020c0c08 *param1) { + func_ov000_020c0d70(param1, &this->mUnk_04); +} + +void ModelRender::vfunc_28() { + while (this->mUnk_04.mUnk_10 != NULL) { + func_02018c3c(&this->mUnk_04, this->mUnk_04.mUnk_10); + } + while (this->mUnk_04.mUnk_08 != NULL) { + func_02018c3c(&this->mUnk_04, this->mUnk_04.mUnk_08); + } + while (this->mUnk_04.mUnk_18 != NULL) { + func_02018c3c(&this->mUnk_04, this->mUnk_04.mUnk_18); + } +} + +void ModelRender::vfunc_2c() { + while (this->mUnk_04.mUnk_10 != NULL) { + func_02018c3c(&this->mUnk_04, this->mUnk_04.mUnk_10); + } +} + +void ModelRender::vfunc_34() { + while (this->mUnk_04.mUnk_18 != NULL) { + func_02018c3c(&this->mUnk_04, this->mUnk_04.mUnk_18); + } +} + +void ModelRender::vfunc_30() { + while (this->mUnk_04.mUnk_08 != NULL) { + func_02018c3c(&this->mUnk_04, this->mUnk_04.mUnk_08); + } +} + +// An object is a subdivision of a model e.g.: link's arm, link's head, etc. +ARM s32 ModelRender::GetObjectIndex(char *objectName) { + char *model = (char *) GetLcdcAddress(); + void *objectList = model + 0x40; + unk32 index = func_0201e388(objectList, objectName); + return index; +} + +ARM s32 ModelRender::GetMaterialIndex(char *materialName) { + char *model = (char *) GetLcdcAddress(); + u32 materialsOffset = *(u32 *) ((u32) model + 8); + void *materialList = (void *) ((u32) model + materialsOffset + 4); + unk32 index = func_0201e388(materialList, materialName); + return index; +} + +THUMB void ModelRender::InitBoneMatrixArrays(u32 idLength) { + u32 *id = data_027e0ce0[1]; + u8 *unkPtr = GetModelUnknownHeader(this); + u8 boneMatrixCount = *(unkPtr + 3); + + ModelRender_UnkBoneMatrixStruct *boneMatrixArray = + (ModelRender_UnkBoneMatrixStruct *) SysObject::operator new[](boneMatrixCount * 0x58, id, idLength); + this->unkBoneMatrixArray2 = boneMatrixArray; + this->mUnk_04.unkBoneMatrixArray1 = boneMatrixArray; +} + +ARM void ModelRender::SetUnkBoneMatrixArray1(ModelRender_UnkBoneMatrixStruct *boneMatrix) { + this->mUnk_04.unkBoneMatrixArray1 = boneMatrix; +} + +void ModelRender::vfunc_38() { + this->mUnk_04.flags |= 3; + ExecModelRenderCommands(&this->mUnk_04); + this->mUnk_04.flags &= 0xfffffffd; +} + +void ModelRender::vfunc_3c(ModelRenderCommandsData *renderData) {} + +void func_ov000_020a99c0(ModelRenderCommandsData *renderData) { + renderData->unkStruct4->mUnk_2c->vfunc_3c(renderData); +} + +void ModelRender::UnkInit_Struct4_Params(u8 param1, u8 param2) { + this->mUnk_04.mUnk_2c = this; + UnkInit_ModelRender_Struct4_Params(&this->mUnk_04, &func_ov000_020a99c0, 0, param1, param2); +}
\ No newline at end of file diff --git a/src/04_Load/Actor/Navi/ActorNavi_04.cpp b/src/04_Load/Actor/Navi/ActorNavi_04.cpp index 13bac706..d442f909 100644 --- a/src/04_Load/Actor/Navi/ActorNavi_04.cpp +++ b/src/04_Load/Actor/Navi/ActorNavi_04.cpp @@ -50,7 +50,7 @@ THUMB bool ActorNaviBase::Init() { ActorNaviBase_Unk3::ActorNaviBase_Unk3(ItemModel *param1) : ModelRender(param1) { - this->func_ov000_020a9998(6, 3); + this->UnkInit_Struct4_Params(6, 3); } THUMB ActorNavi::ActorNavi() : @@ -69,7 +69,7 @@ extern const ItemManager_Unk1 data_ov000_020dc7d0; THUMB bool ActorNavi::Init() { mUnk_2f0.func_ov000_020c0c44(gItemManager->func_ov00_020ad538(&data_ov000_020dc7d0)); mUnk_2f0.func_ov000_020c0e5c(0); - mUnk_294.func_ov000_020a9960(&mUnk_35c); + mUnk_294.SetUnkBoneMatrixArray1(&unkBoneMatrixStruct); mUnk_294.vfunc_24(&mUnk_2f0); mUnk_3c4 = ActorNaviBase::vfunc_c4(); mUnk_3c6 = ActorNaviBase::vfunc_c8(); diff --git a/src/58_Bombchu/Player/EquipBombchu.cpp b/src/58_Bombchu/Player/EquipBombchu.cpp index 8b28d754..d52dc6c7 100644 --- a/src/58_Bombchu/Player/EquipBombchu.cpp +++ b/src/58_Bombchu/Player/EquipBombchu.cpp @@ -87,8 +87,8 @@ static const ItemManager_Unk1 sEquipBombchu_Unk1 = { }; THUMB void EquipBombchu::vfunc_00() { - gModelRenderBombchu.vfunc_0c(gItemManager->GetItemModel(ItemModelId_Bombchu)); - gModelRenderBombchuPt.vfunc_0c(gItemManager->GetItemModel(ItemModelId_BombchuPt)); + gModelRenderBombchu.Init_ModelRender_UnkStruct_4(gItemManager->GetItemModel(ItemModelId_Bombchu)); + gModelRenderBombchuPt.Init_ModelRender_UnkStruct_4(gItemManager->GetItemModel(ItemModelId_BombchuPt)); data_ov058_0219b0a0.mUnk_08 = gItemManager->GetItemModel(ItemModelId_BombchuPt); data_ov058_0219b0a0.func_ov000_020c0c44(gItemManager->func_ov00_020ad538(&sEquipBombchu_Unk1)); data_ov058_0219b0a0.func_ov000_020c0e5c(0); diff --git a/src/59_Hammer/Actor/Navi/ActorNaviBase_59.cpp b/src/59_Hammer/Actor/Navi/ActorNaviBase_59.cpp index 07b8a4a5..9df98e3d 100644 --- a/src/59_Hammer/Actor/Navi/ActorNaviBase_59.cpp +++ b/src/59_Hammer/Actor/Navi/ActorNaviBase_59.cpp @@ -45,7 +45,7 @@ ARM void ActorNavi::func_ov059_0219aa08(bool param1) { this->mUnk_334.mUnk_00.x = ROUND_Q20(uVar4) | ((this->mUnk_344 >> 0x1F) * 0x666 + (lVar2 >> 0x20) + (~0x800 < uVar4)) * 0x100000; - Mat3p_MultiplyVec(&this->mUnk_334.mUnk_00, &this->mUnk_384, &this->mUnk_334.mUnk_00); + Mat3p_MultiplyVec(&this->mUnk_334.mUnk_00, &this->unkBoneMatrixStruct.mUnk_28, &this->mUnk_334.mUnk_00); Vec3p_RotateY(uVar3, &this->mUnk_334.mUnk_00); Vec3p_Add(&this->mUnk_334.mUnk_00, &VStack_24, &this->mUnk_334.mUnk_00); VStack_60.z = this->mUnk_334.mUnk_00.z; |
