From ae9477dd66138abe19c43803940ddc33036b4148 Mon Sep 17 00:00:00 2001 From: robojumper Date: Fri, 21 Jun 2024 22:57:10 +0200 Subject: [PATCH] anmTexPat_c OK --- config/SOUE01/splits.txt | 8 ++ config/SOUE01/symbols.txt | 36 +++--- configure.py | 2 + include/m/m3d/m_anmchr.h | 2 +- include/m/m3d/m_anmchrblend.h | 2 +- include/m/m3d/m_anmmatclr.h | 4 +- include/m/m3d/m_anmtexpat.h | 52 ++++++++ include/m/m3d/m_anmtexsrt.h | 4 +- include/m/m3d/m_anmvis.h | 2 +- include/m/m3d/m_banm.h | 2 +- include/m/m3d/m_fanm.h | 2 +- include/nw4r/g3d/g3d_anmtexpat.h | 70 ++++++++++ include/nw4r/g3d/g3d_resanmtexpat.h | 12 ++ src/m/m3d/m_anmchr.cpp | 2 +- src/m/m3d/m_anmchrblend.cpp | 2 +- src/m/m3d/m_anmmatclr.cpp | 4 +- src/m/m3d/m_anmtexpat.cpp | 191 ++++++++++++++++++++++++++++ src/m/m3d/m_anmtexsrt.cpp | 4 +- src/m/m3d/m_anmvis.cpp | 2 +- 19 files changed, 369 insertions(+), 34 deletions(-) create mode 100644 include/m/m3d/m_anmtexpat.h create mode 100644 src/m/m3d/m_anmtexpat.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 374697d0..f82cb497 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -271,6 +271,9 @@ m/m3d/m3d.cpp: .text start:0x802E3E50 end:0x802E4714 .sbss start:0x80575BD0 end:0x80575BE8 +m/m3d/m_proc.cpp: + .text start:0x802E4720 end:0x802E48D4 + m/m3d/m_anmchr.cpp: .text start:0x802E48E0 end:0x802E4D98 .data start:0x805424D0 end:0x805424E8 @@ -285,6 +288,11 @@ m/m3d/m_anmmatclr.cpp: .data start:0x80542500 end:0x80542530 .sdata2 start:0x8057CCD0 end:0x8057CCE0 +m/m3d/m_anmtexpat.cpp: + .text start:0x802E63C0 end:0x802E6EB4 + .data start:0x80542568 end:0x80542598 + .sdata2 start:0x8057CCF8 end:0x8057CD08 + m/m3d/m_anmtexsrt.cpp: .text start:0x802E6EC0 end:0x802E7A54 .data start:0x80542598 end:0x805425C8 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 6c020fc7..2661d69c 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -17441,13 +17441,13 @@ fn_802E47C0 = .text:0x802E47C0; // type:function size:0x4 fn_802E47D0 = .text:0x802E47D0; // type:function size:0x4 create__Q23m3d6proc_cFP12mAllocator_cPUl = .text:0x802E47E0; // type:function size:0xF4 __dt__Q23m3d8anmChr_cFv = .text:0x802E48E0; // type:function size:0x58 -getType__Q23m3d8anmChr_cFv = .text:0x802E4940; // type:function size:0x8 +getType__Q23m3d8anmChr_cCFv = .text:0x802E4940; // type:function size:0x8 create__Q23m3d8anmChr_cFQ34nw4r3g3d6ResMdlQ34nw4r3g3d9ResAnmChrP12mAllocator_cPUl = .text:0x802E4950; // type:function size:0x120 setAnm__Q23m3d8anmChr_cFRQ23m3d6bmdl_cQ34nw4r3g3d9ResAnmChrQ23m3d10playMode_e = .text:0x802E4A70; // type:function size:0x84 setAnmAfter__Q23m3d8anmChr_cFRQ23m3d6bmdl_cQ34nw4r3g3d9ResAnmChrQ23m3d10playMode_e = .text:0x802E4B00; // type:function size:0x22C setFrmCtrlDefault__Q23m3d8anmChr_cFRQ34nw4r3g3d9ResAnmChrQ23m3d10playMode_e = .text:0x802E4D30; // type:function size:0x68 __dt__Q23m3d13anmChrBlend_cFv = .text:0x802E4DA0; // type:function size:0x58 -getType__Q23m3d13anmChrBlend_cFv = .text:0x802E4E00; // type:function size:0x8 +getType__Q23m3d13anmChrBlend_cCFv = .text:0x802E4E00; // type:function size:0x8 create__Q23m3d13anmChrBlend_cFQ34nw4r3g3d6ResMdliP12mAllocator_cPUl = .text:0x802E4E10; // type:function size:0xB8 attach__Q23m3d13anmChrBlend_cFiPQ34nw4r3g3d12AnmObjChrResf = .text:0x802E4ED0; // type:function size:0xD8 attach__Q23m3d13anmChrBlend_cFiPQ23m3d8anmChr_cf = .text:0x802E4FB0; // type:function size:0xB4 @@ -17455,7 +17455,7 @@ detach__Q23m3d13anmChrBlend_cFi = .text:0x802E5070; // type:function size:0xA0 setWeight__Q23m3d13anmChrBlend_cFif = .text:0x802E5110; // type:function size:0xB0 getWeight__Q23m3d13anmChrBlend_cCFi = .text:0x802E51C0; // type:function size:0xA0 __dt__Q33m3d11anmMatClr_c7child_cFv = .text:0x802E5260; // type:function size:0x58 -getType__Q33m3d11anmMatClr_c7child_cFv = .text:0x802E52C0; // type:function size:0x8 +getType__Q33m3d11anmMatClr_c7child_cCFv = .text:0x802E52C0; // type:function size:0x8 heapCost__Q33m3d11anmMatClr_c7child_cFQ34nw4r3g3d6ResMdlQ34nw4r3g3d9ResAnmClrb = .text:0x802E52D0; // type:function size:0x7C create__Q33m3d11anmMatClr_c7child_cFQ34nw4r3g3d6ResMdlQ34nw4r3g3d9ResAnmClrP12mAllocator_cPUl = .text:0x802E5350; // type:function size:0x11C setAnm__Q33m3d11anmMatClr_c7child_cFRQ23m3d6bmdl_cQ34nw4r3g3d9ResAnmClrQ23m3d10playMode_e = .text:0x802E5470; // type:function size:0xB4 @@ -17464,7 +17464,7 @@ setFrmCtrlDefault__Q33m3d11anmMatClr_c7child_cFRQ34nw4r3g3d9ResAnmClrQ23m3d10pla heapCost__Q23m3d11anmMatClr_cFQ34nw4r3g3d6ResMdlQ34nw4r3g3d9ResAnmClrlb = .text:0x802E5600; // type:function size:0xE0 create__Q23m3d11anmMatClr_cFQ34nw4r3g3d6ResMdlQ34nw4r3g3d9ResAnmClrP12mAllocator_cPUll = .text:0x802E56E0; // type:function size:0x23C __dt__Q23m3d11anmMatClr_cFv = .text:0x802E5920; // type:function size:0x6C -getType__Q23m3d11anmMatClr_cFv = .text:0x802E5990; // type:function size:0x8 +getType__Q23m3d11anmMatClr_cCFv = .text:0x802E5990; // type:function size:0x8 remove__Q23m3d11anmMatClr_cFv = .text:0x802E59A0; // type:function size:0xEC setAnm__Q23m3d11anmMatClr_cFRQ23m3d6bmdl_cQ34nw4r3g3d9ResAnmClrlQ23m3d10playMode_e = .text:0x802E5A90; // type:function size:0x140 play__Q23m3d11anmMatClr_cFv = .text:0x802E5BD0; // type:function size:0xAC @@ -17493,17 +17493,17 @@ fn_802E6130 = .text:0x802E6130; // type:function size:0x8 fn_802E6140 = .text:0x802E6140; // type:function size:0x120 fn_802E6260 = .text:0x802E6260; // type:function size:0xEC fn_802E6350 = .text:0x802E6350; // type:function size:0x68 -fn_802E63C0 = .text:0x802E63C0; // type:function size:0x8 -fn_802E63D0 = .text:0x802E63D0; // type:function size:0x58 +getType__Q33m3d11anmTexPat_c7child_cCFv = .text:0x802E63C0; // type:function size:0x8 +__dt__Q33m3d11anmTexPat_c7child_cFv = .text:0x802E63D0; // type:function size:0x58 heapCost__Q33m3d11anmTexPat_c7child_cFQ34nw4r3g3d6ResMdlQ34nw4r3g3d12ResAnmTexPatb = .text:0x802E6430; // type:function size:0x7C create__Q33m3d11anmTexPat_c7child_cFQ34nw4r3g3d6ResMdlQ34nw4r3g3d12ResAnmTexPatP12mAllocator_cPUl = .text:0x802E64B0; // type:function size:0x11C -fn_802E65D0 = .text:0x802E65D0; // type:function size:0xB4 +setAnm__Q33m3d11anmTexPat_c7child_cFRQ23m3d6bmdl_cQ34nw4r3g3d12ResAnmTexPatQ23m3d10playMode_e = .text:0x802E65D0; // type:function size:0xB4 releaseAnm__Q33m3d11anmTexPat_c7child_cFv = .text:0x802E6690; // type:function size:0x5C setFrmCtrlDefault__Q33m3d11anmTexPat_c7child_cFRQ34nw4r3g3d12ResAnmTexPatQ23m3d10playMode_e = .text:0x802E66F0; // type:function size:0x68 heapCost__Q23m3d11anmTexPat_cFQ34nw4r3g3d6ResMdlQ34nw4r3g3d12ResAnmTexPatlb = .text:0x802E6760; // type:function size:0xE0 create__Q23m3d11anmTexPat_cFQ34nw4r3g3d6ResMdlQ34nw4r3g3d12ResAnmTexPatP12mAllocator_cPUll = .text:0x802E6840; // type:function size:0x23C __dt__Q23m3d11anmTexPat_cFv = .text:0x802E6A80; // type:function size:0x6C -fn_802E6AF0 = .text:0x802E6AF0; // type:function size:0x8 +getType__Q23m3d11anmTexPat_cCFv = .text:0x802E6AF0; // type:function size:0x8 remove__Q23m3d11anmTexPat_cFv = .text:0x802E6B00; // type:function size:0xEC setAnm__Q23m3d11anmTexPat_cFRQ23m3d6bmdl_cQ34nw4r3g3d12ResAnmTexPatlQ23m3d10playMode_e = .text:0x802E6BF0; // type:function size:0x140 play__Q23m3d11anmTexPat_cFv = .text:0x802E6D30; // type:function size:0xAC @@ -17513,8 +17513,8 @@ setFrame__Q23m3d11anmTexPat_cFfl = .text:0x802E6E50; // type:function size:0x10 setRate__Q23m3d11anmTexPat_cFfl = .text:0x802E6E60; // type:function size:0x10 isStop__Q23m3d11anmTexPat_cCFl = .text:0x802E6E70; // type:function size:0x10 getFrameMax__Q23m3d11anmTexPat_cCFl = .text:0x802E6E80; // type:function size:0x14 -fn_802E6EA0 = .text:0x802E6EA0; // type:function size:0x14 -getType__Q33m3d11anmTexSrt_c7child_cFv = .text:0x802E6EC0; // type:function size:0x8 +setFrameStart__Q23m3d11anmTexPat_cFfl = .text:0x802E6EA0; // type:function size:0x14 +getType__Q33m3d11anmTexSrt_c7child_cCFv = .text:0x802E6EC0; // type:function size:0x8 __dt__Q33m3d11anmTexSrt_c7child_cFv = .text:0x802E6ED0; // type:function size:0x58 heapCost__Q33m3d11anmTexSrt_c7child_cFQ34nw4r3g3d6ResMdlQ34nw4r3g3d12ResAnmTexSrtb = .text:0x802E6F30; // type:function size:0x7C create__Q33m3d11anmTexSrt_c7child_cFQ34nw4r3g3d6ResMdlQ34nw4r3g3d12ResAnmTexSrtP12mAllocator_cPUl = .text:0x802E6FB0; // type:function size:0x12C @@ -17524,7 +17524,7 @@ setFrmCtrlDefault__Q33m3d11anmTexSrt_c7child_cFRQ34nw4r3g3d12ResAnmTexSrtQ23m3d1 heapCost__Q23m3d11anmTexSrt_cFQ34nw4r3g3d6ResMdlQ34nw4r3g3d12ResAnmTexSrtlb = .text:0x802E7270; // type:function size:0xE0 create__Q23m3d11anmTexSrt_cFQ34nw4r3g3d6ResMdlQ34nw4r3g3d12ResAnmTexSrtP12mAllocator_cPUll = .text:0x802E7350; // type:function size:0x27C __dt__Q23m3d11anmTexSrt_cFv = .text:0x802E75D0; // type:function size:0x6C -getType__Q23m3d11anmTexSrt_cFv = .text:0x802E7640; // type:function size:0x8 +getType__Q23m3d11anmTexSrt_cCFv = .text:0x802E7640; // type:function size:0x8 remove__Q23m3d11anmTexSrt_cFv = .text:0x802E7650; // type:function size:0xEC setAnm__Q23m3d11anmTexSrt_cFRQ23m3d6bmdl_cQ34nw4r3g3d12ResAnmTexSrtlQ23m3d10playMode_e = .text:0x802E7740; // type:function size:0x140 play__Q23m3d11anmTexSrt_cFv = .text:0x802E7880; // type:function size:0xAC @@ -17539,7 +17539,7 @@ getFrameMax__Q23m3d11anmTexSrt_cCFl = .text:0x802E7A00; // type:function size:0x setFrameStart__Q23m3d11anmTexSrt_cFfl = .text:0x802E7A20; // type:function size:0x14 getFrameStart__Q23m3d11anmTexSrt_cCFl = .text:0x802E7A40; // type:function size:0x14 __dt__Q23m3d8anmVis_cFv = .text:0x802E7A60; // type:function size:0x58 -getType__Q23m3d8anmVis_cFv = .text:0x802E7AC0; // type:function size:0x8 +getType__Q23m3d8anmVis_cCFv = .text:0x802E7AC0; // type:function size:0x8 create__Q23m3d8anmVis_cFQ34nw4r3g3d6ResMdlQ34nw4r3g3d9ResAnmVisP12mAllocator_cPUl = .text:0x802E7AD0; // type:function size:0x118 setAnm__Q23m3d8anmVis_cFRQ23m3d6bmdl_cQ34nw4r3g3d9ResAnmVisQ23m3d10playMode_e = .text:0x802E7BF0; // type:function size:0xE8 setFrmCtrlDefault__Q23m3d8anmVis_cFRQ34nw4r3g3d9ResAnmVisQ23m3d10playMode_e = .text:0x802E7CE0; // type:function size:0x68 @@ -24517,9 +24517,9 @@ fn_80445310 = .text:0x80445310; // type:function size:0x54 fn_80445370 = .text:0x80445370; // type:function size:0xF4 fn_80445470 = .text:0x80445470; // type:function size:0xB8 fn_80445530 = .text:0x80445530; // type:function size:0x7C -fn_804455B0 = .text:0x804455B0; // type:function size:0x134 +Construct__Q34nw4r3g3d20AnmObjTexPatOverrideFP12MEMAllocatorPUlQ34nw4r3g3d6ResMdli = .text:0x804455B0; // type:function size:0x134 fn_804456F0 = .text:0x804456F0; // type:function size:0xC0 -fn_804457B0 = .text:0x804457B0; // type:function size:0x1F0 +Construct__Q34nw4r3g3d15AnmObjTexPatResFP12MEMAllocatorPUlQ34nw4r3g3d12ResAnmTexPatQ34nw4r3g3d6ResMdlb = .text:0x804457B0; // type:function size:0x1F0 fn_804459A0 = .text:0x804459A0; // type:function size:0xC0 fn_80445A60 = .text:0x80445A60; // type:function size:0x8 fn_80445A70 = .text:0x80445A70; // type:function size:0xB4 @@ -29095,8 +29095,8 @@ TYPE_NAME__Q34nw4r3g3d20AnmObjMatClrOverride = .rodata:0x804F70C8; // type:objec TYPE_NAME__Q34nw4r3g3d15AnmObjMatClrRes = .rodata:0x804F70E8; // type:object size:0x18 lbl_804F7100 = .rodata:0x804F7100; // type:object size:0x18 lbl_804F7118 = .rodata:0x804F7118; // type:object size:0x18 -lbl_804F7130 = .rodata:0x804F7130; // type:object size:0x20 -lbl_804F7150 = .rodata:0x804F7150; // type:object size:0x18 +TYPE_NAME__Q34nw4r3g3d20AnmObjTexPatOverride = .rodata:0x804F7130; // type:object size:0x20 +TYPE_NAME__Q34nw4r3g3d15AnmObjTexPatRes = .rodata:0x804F7150; // type:object size:0x18 lbl_804F7168 = .rodata:0x804F7168; // type:object size:0x18 lbl_804F7180 = .rodata:0x804F7180; // type:object size:0x18 TYPE_NAME__Q34nw4r3g3d20AnmObjTexSrtOverride = .rodata:0x804F7198; // type:object size:0x20 @@ -35688,8 +35688,8 @@ __vt__Q23m3d11anmMatClr_c = .data:0x80542500; // type:object size:0x18 __vt__Q33m3d11anmMatClr_c7child_c = .data:0x80542518; // type:object size:0x18 lbl_80542530 = .data:0x80542530; // type:object size:0x20 lbl_80542550 = .data:0x80542550; // type:object size:0x18 -lbl_80542568 = .data:0x80542568; // type:object size:0x18 -lbl_80542580 = .data:0x80542580; // type:object size:0x18 +__vt__Q23m3d11anmTexPat_c = .data:0x80542568; // type:object size:0x18 +__vt__Q33m3d11anmTexPat_c7child_c = .data:0x80542580; // type:object size:0x18 __vt__Q23m3d11anmTexSrt_c = .data:0x80542598; // type:object size:0x18 __vt__Q33m3d11anmTexSrt_c7child_c = .data:0x805425B0; // type:object size:0x18 __vt__Q23m3d8anmVis_c = .data:0x805425C8; // type:object size:0x18 diff --git a/configure.py b/configure.py index 1b00a4b9..661c6a4f 100644 --- a/configure.py +++ b/configure.py @@ -335,8 +335,10 @@ def nw4rLib(lib_name, objects, extra_cflags=[]): Object(Matching, "f/f_list.cpp"), Object(Matching, "f/f_manager.cpp"), Object(NonMatching, "m/m3d/m3d.cpp"), + Object(NonMatching, "m/m3d/m_proc.cpp"), Object(Matching, "m/m3d/m_anmchr.cpp"), Object(Matching, "m/m3d/m_anmchrblend.cpp"), + Object(Matching, "m/m3d/m_anmtexpat.cpp"), Object(Matching, "m/m3d/m_anmtexsrt.cpp"), Object(Matching, "m/m3d/m_anmmatclr.cpp"), Object(Matching, "m/m3d/m_anmvis.cpp"), diff --git a/include/m/m3d/m_anmchr.h b/include/m/m3d/m_anmchr.h index 4dab7f75..f451bfb7 100644 --- a/include/m/m3d/m_anmchr.h +++ b/include/m/m3d/m_anmchr.h @@ -12,7 +12,7 @@ class anmChr_c : public fanm_c { public: virtual ~anmChr_c(); - virtual int getType() override; + virtual int getType() const override; bool create(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmChr, mAllocator_c*, u32*); void setAnm(bmdl_c &, nw4r::g3d::ResAnmChr, playMode_e); diff --git a/include/m/m3d/m_anmchrblend.h b/include/m/m3d/m_anmchrblend.h index 0852d2c5..bcb9464a 100644 --- a/include/m/m3d/m_anmchrblend.h +++ b/include/m/m3d/m_anmchrblend.h @@ -12,7 +12,7 @@ class anmChrBlend_c : public banm_c { public: virtual ~anmChrBlend_c(); - virtual int getType() override; + virtual int getType() const override; bool create(nw4r::g3d::ResMdl, int, mAllocator_c *, u32 *); bool attach(int, nw4r::g3d::AnmObjChrRes *, f32); diff --git a/include/m/m3d/m_anmmatclr.h b/include/m/m3d/m_anmmatclr.h index c12bf296..7b48cd5a 100644 --- a/include/m/m3d/m_anmmatclr.h +++ b/include/m/m3d/m_anmmatclr.h @@ -12,7 +12,7 @@ class anmMatClr_c : public banm_c { public: child_c() {} virtual ~child_c(); - virtual int getType() override; + virtual int getType() const override; static u32 heapCost(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmClr, bool); bool create(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmClr, mAllocator_c *, u32 *); @@ -25,7 +25,7 @@ class anmMatClr_c : public banm_c { anmMatClr_c() : mpChildren(nullptr) {} virtual ~anmMatClr_c(); - virtual int getType() override; + virtual int getType() const override; virtual void remove() override; virtual void play() override; diff --git a/include/m/m3d/m_anmtexpat.h b/include/m/m3d/m_anmtexpat.h new file mode 100644 index 00000000..923bbbc8 --- /dev/null +++ b/include/m/m3d/m_anmtexpat.h @@ -0,0 +1,52 @@ +#ifndef M3D_M_ANMTEXPAT_H +#define M3D_M_ANMTEXPAT_H + +#include +#include +#include + +namespace m3d { + +class anmTexPat_c : public banm_c { + class child_c : public fanm_c { + public: + child_c() {} + virtual ~child_c(); + virtual int getType() const override; + + static u32 heapCost(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmTexPat, bool); + bool create(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmTexPat, mAllocator_c*, u32*); + void setAnm(m3d::bmdl_c&, nw4r::g3d::ResAnmTexPat, m3d::playMode_e); + void releaseAnm(); + void setFrmCtrlDefault(nw4r::g3d::ResAnmTexPat&, playMode_e); + }; + +public: + anmTexPat_c(): mpChildren(nullptr) {} + virtual ~anmTexPat_c(); + + virtual int getType() const override; + virtual void remove() override; + virtual void play() override; + + bool create(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmTexPat, mAllocator_c*, u32*, s32); + static u32 heapCost(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmTexPat, s32, bool); + + void setAnm(bmdl_c&, nw4r::g3d::ResAnmTexPat, s32, playMode_e); + + void play(s32); + f32 getFrame(s32) const; + void setFrame(f32, s32); + void setRate(f32, s32); + bool isStop(s32) const; + + f32 getFrameMax(s32) const; + void setFrameStart(f32, s32); + +private: + child_c *mpChildren; +}; + +} // namespace m3d + +#endif diff --git a/include/m/m3d/m_anmtexsrt.h b/include/m/m3d/m_anmtexsrt.h index 151f87ad..4aed956e 100644 --- a/include/m/m3d/m_anmtexsrt.h +++ b/include/m/m3d/m_anmtexsrt.h @@ -12,7 +12,7 @@ class anmTexSrt_c : public banm_c { public: child_c() {} virtual ~child_c(); - virtual int getType() override; + virtual int getType() const override; static u32 heapCost(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmTexSrt, bool); bool create(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmTexSrt, mAllocator_c*, u32*); @@ -25,7 +25,7 @@ class anmTexSrt_c : public banm_c { anmTexSrt_c(): mpChildren(nullptr) {} virtual ~anmTexSrt_c(); - virtual int getType() override; + virtual int getType() const override; virtual void remove() override; virtual void play() override; diff --git a/include/m/m3d/m_anmvis.h b/include/m/m3d/m_anmvis.h index 1787a278..0f3fc80d 100644 --- a/include/m/m3d/m_anmvis.h +++ b/include/m/m3d/m_anmvis.h @@ -11,7 +11,7 @@ class anmVis_c : public fanm_c { public: virtual ~anmVis_c(); - virtual int getType() override; + virtual int getType() const override; bool create(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmVis, mAllocator_c *, u32 *); void setAnm(m3d::bmdl_c &, nw4r::g3d::ResAnmVis, m3d::playMode_e); diff --git a/include/m/m3d/m_banm.h b/include/m/m3d/m_banm.h index d5647a71..35b1b896 100644 --- a/include/m/m3d/m_banm.h +++ b/include/m/m3d/m_banm.h @@ -12,7 +12,7 @@ class banm_c { banm_c() : mpAnmObj(nullptr), mpFrameHeap(nullptr) {} virtual ~banm_c(); - virtual int getType() = 0; + virtual int getType() const = 0; virtual void remove(); virtual void play(); diff --git a/include/m/m3d/m_fanm.h b/include/m/m3d/m_fanm.h index fb756cfb..4f047ca4 100644 --- a/include/m/m3d/m_fanm.h +++ b/include/m/m3d/m_fanm.h @@ -18,7 +18,7 @@ class fanm_c : public banm_c { fanm_c(); virtual ~fanm_c(); - virtual int getType() = 0; + virtual int getType() const = 0; virtual void play(); void set(f32, playMode_e, f32, f32); diff --git a/include/nw4r/g3d/g3d_anmtexpat.h b/include/nw4r/g3d/g3d_anmtexpat.h index 031c3264..9506d745 100644 --- a/include/nw4r/g3d/g3d_anmtexpat.h +++ b/include/nw4r/g3d/g3d_anmtexpat.h @@ -1,6 +1,8 @@ #ifndef NW4R_G3D_ANMTEXPAT_H #define NW4R_G3D_ANMTEXPAT_H +#include "nw4r/g3d/g3d_anmobj.h" #include "nw4r/g3d/g3d_restex.h" +#include "nw4r/g3d/g3d_resanmtexpat.h" namespace nw4r { @@ -18,6 +20,74 @@ namespace nw4r ResTex mTexs[ANM_COUNT]; // at 0x4 ResPltt mPltts[ANM_COUNT]; // at 0x24 }; + + class AnmObjTexPatRes; + + class AnmObjTexPat : public AnmObj { + public: + static const G3dObj::TypeObj GetTypeObjStatic() { + return TypeObj(TYPE_NAME); + } + + virtual TexPatAnmResult *GetResult(); // at 0x38 + virtual void Attach(s32, AnmObjTexPatRes *res); // at 0x3C + virtual void Detach(s32); // at 0x40 + + private: + int mChildrenArraySize; + u16 *mpChildrenArray; + + NW4R_G3D_TYPE_OBJ_DECL(AnmObjTexPat); + }; + + class AnmObjTexPatNode : public AnmObjTexPat { + public: + static const G3dObj::TypeObj GetTypeObjStatic() { + return TypeObj(TYPE_NAME); + } + + + inline int Size() { + return mNodeArraySize; + } + + AnmObjTexPatRes *GetNode(int i) { + return mpNodes[i]; + } + + private: + int mNodeArraySize; + AnmObjTexPatRes **mpNodes; + + NW4R_G3D_TYPE_OBJ_DECL(AnmObjTexPatNode); + }; + + class AnmObjTexPatRes : public AnmObjTexPat, public FrameCtrl { + public: + static const G3dObj::TypeObj GetTypeObjStatic() { + return TypeObj(TYPE_NAME); + } + + + static AnmObjTexPatRes *Construct(MEMAllocator*, u32*, ResAnmTexPat, ResMdl, bool); + private: + ResAnmTexPat mRes; + TexPatAnmResult *mpResultCache; + + NW4R_G3D_TYPE_OBJ_DECL(AnmObjTexPatRes); + }; + + class AnmObjTexPatOverride : public AnmObjTexPatNode { + public: + static const G3dObj::TypeObj GetTypeObjStatic() { + return TypeObj(TYPE_NAME); + } + + static AnmObjTexPatOverride *Construct(MEMAllocator*, u32*, ResMdl, int); + + NW4R_G3D_TYPE_OBJ_DECL(AnmObjTexPatOverride); + }; + } } diff --git a/include/nw4r/g3d/g3d_resanmtexpat.h b/include/nw4r/g3d/g3d_resanmtexpat.h index 09b362de..d7fac863 100644 --- a/include/nw4r/g3d/g3d_resanmtexpat.h +++ b/include/nw4r/g3d/g3d_resanmtexpat.h @@ -52,6 +52,8 @@ namespace nw4r char UNK_0x24[0xC]; u16 mTexCount; // at 0x30 u16 mPlttCount; // at 0x32 + char UNK_0x34[0x4]; + AnmPolicy mAnmPolicy; // at 0x38 }; struct ResAnmTexPat @@ -79,6 +81,16 @@ namespace nw4r { return static_cast(mAnmTexPat.ofs_to_obj(ref().mMatDictOffset)[i]); } + + AnmPolicy GetAnmPolicy() const + { + return ref().mAnmPolicy; + } + + int GetNumFrame() const + { + return ref().mTexCount; + } void GetAnmResult(TexPatAnmResult *, u32, float) const; diff --git a/src/m/m3d/m_anmchr.cpp b/src/m/m3d/m_anmchr.cpp index 7ec4baaa..5eb519b6 100644 --- a/src/m/m3d/m_anmchr.cpp +++ b/src/m/m3d/m_anmchr.cpp @@ -7,7 +7,7 @@ namespace m3d { anmChr_c::~anmChr_c() {} -int anmChr_c::getType() { +int anmChr_c::getType() const { return 0; } diff --git a/src/m/m3d/m_anmchrblend.cpp b/src/m/m3d/m_anmchrblend.cpp index a0313840..4959df4b 100644 --- a/src/m/m3d/m_anmchrblend.cpp +++ b/src/m/m3d/m_anmchrblend.cpp @@ -7,7 +7,7 @@ namespace m3d { anmChrBlend_c::~anmChrBlend_c() {} -int anmChrBlend_c::getType() { +int anmChrBlend_c::getType() const { return 0; } diff --git a/src/m/m3d/m_anmmatclr.cpp b/src/m/m3d/m_anmmatclr.cpp index 64012032..dc741412 100644 --- a/src/m/m3d/m_anmmatclr.cpp +++ b/src/m/m3d/m_anmmatclr.cpp @@ -7,7 +7,7 @@ namespace m3d { anmMatClr_c::child_c::~child_c() {} -int anmMatClr_c::child_c::getType() { +int anmMatClr_c::child_c::getType() const { return 0x02; } @@ -124,7 +124,7 @@ anmMatClr_c::~anmMatClr_c() { anmMatClr_c::remove(); } -int anmMatClr_c::getType() { +int anmMatClr_c::getType() const { return 0x02; } diff --git a/src/m/m3d/m_anmtexpat.cpp b/src/m/m3d/m_anmtexpat.cpp new file mode 100644 index 00000000..2b790e90 --- /dev/null +++ b/src/m/m3d/m_anmtexpat.cpp @@ -0,0 +1,191 @@ +#include +#include +#include +#include + +namespace m3d { + +int anmTexPat_c::child_c::getType() const { + return 0x03; +} + +anmTexPat_c::child_c::~child_c() {} + +u32 anmTexPat_c::child_c::heapCost(nw4r::g3d::ResMdl mdl, nw4r::g3d::ResAnmTexPat pat, bool b) { + u32 size = 0; + nw4r::g3d::AnmObjTexPatRes::Construct(nullptr, &size, pat, mdl, false); + if (b) { + size = ROUND_UP(mHeap::frmHeapCost(size, 0x20), 0x20); + } + return size; +} + +bool anmTexPat_c::child_c::create(nw4r::g3d::ResMdl mdl, nw4r::g3d::ResAnmTexPat pat, mAllocator_c* alloc, u32* pSize) { + if (alloc == nullptr) { + alloc = internal::l_allocator_p; + } + + u32 size; + if (pSize == nullptr) { + pSize = &size; + } + + *pSize = child_c::heapCost(mdl, pat, false); + if (!createAllocator(alloc, pSize)) { + return false; + } + + mpAnmObj = nw4r::g3d::AnmObjTexPatRes::Construct(&mAllocator, nullptr, pat, mdl, false); + + if (!mpAnmObj->Bind(mdl)) { + remove(); + return false; + } + setFrmCtrlDefault(pat, PLAY_MODE_4); + return true; +} + +void anmTexPat_c::child_c::setAnm(m3d::bmdl_c &mdl, nw4r::g3d::ResAnmTexPat pat, m3d::playMode_e mode) { + releaseAnm(); + mpAnmObj = nw4r::g3d::AnmObjTexPatRes::Construct(&mAllocator, nullptr, pat, mdl.getResMdl(), false); + mpAnmObj->Bind(mdl.getResMdl()); + setFrmCtrlDefault(pat, mode); +} + +void anmTexPat_c::child_c::releaseAnm() { + if (mpAnmObj != nullptr) { + mpAnmObj->Release(); + mpFrameHeap->free(3); + mpAnmObj = nullptr; + } +} + +void anmTexPat_c::child_c::setFrmCtrlDefault(nw4r::g3d::ResAnmTexPat &pat, playMode_e mode) { + if (mode == PLAY_MODE_4) { + mode = pat.GetAnmPolicy() == nw4r::g3d::ANM_POLICY_ONETIME ? PLAY_MODE_1 : PLAY_MODE_0; + } + set(pat.GetNumFrame(), mode, 1.0f, -1.0f); +} + +u32 anmTexPat_c::heapCost(nw4r::g3d::ResMdl mdl, nw4r::g3d::ResAnmTexPat pat, s32 num, bool b) { + u32 size = 0; + nw4r::g3d::AnmObjTexPatOverride::Construct(nullptr, &size, mdl, num); + size += ROUND_UP(num * sizeof(child_c), 0x20); + u32 childCost = child_c::heapCost(mdl, pat, true); + size += num * ROUND_UP(childCost, 0x20); + + if (b) { + size = ROUND_UP(mHeap::frmHeapCost(size, 0x20), 0x20); + } + return size; +} + +bool anmTexPat_c::create(nw4r::g3d::ResMdl mdl, nw4r::g3d::ResAnmTexPat pat, mAllocator_c* alloc, u32* pSize, s32 num) { + if (alloc == nullptr) { + alloc = internal::l_allocator_p; + } + + u32 size = 0; + if (pSize == nullptr) { + pSize = &size; + } + + *pSize = heapCost(mdl, pat, num, false); + if (!createAllocator(alloc, pSize)) { + return false; + } + + mpAnmObj = nw4r::g3d::AnmObjTexPatOverride::Construct(&mAllocator, nullptr, mdl, num); + + // TODO inline? + mpChildren = (child_c*)MEMAllocFromAllocator(&mAllocator, ROUND_UP(num * sizeof(child_c), 0x20)); + + nw4r::g3d::AnmObjTexPatOverride *obj = nw4r::g3d::G3dObj::DynamicCast(mpAnmObj); + child_c *child = mpChildren; + for (int i = 0; i < num; i++) { + new (child) child_c(); + if (!child->create(mdl, pat, &mAllocator, nullptr)) { + mHeap::destroyFrmHeap(mpFrameHeap); + return false; + } + + if (i == 0) { + obj->Attach(i, nw4r::g3d::G3dObj::DynamicCast(child->getAnimObj())); + } else { + child->releaseAnm(); + } + child++; + } + + return true; +} + +anmTexPat_c::~anmTexPat_c() { + anmTexPat_c::remove(); +} + +int anmTexPat_c::getType() const { + return 0x03; +} + +void anmTexPat_c::remove() { + nw4r::g3d::AnmObjTexPatOverride *o = nw4r::g3d::G3dObj::DynamicCast(mpAnmObj); + if (o != nullptr && mpChildren != 0) { + int size = o->Size(); + for (int i = 0; i < size; i++) { + mpChildren[i].remove(); + } + mpChildren = nullptr; + } + banm_c::remove(); +} + +void anmTexPat_c::setAnm(bmdl_c &mdl, nw4r::g3d::ResAnmTexPat pat, s32 idx, playMode_e mode) { + nw4r::g3d::AnmObjTexPatOverride *o = nw4r::g3d::G3dObj::DynamicCast(mpAnmObj); + o->Detach(idx); + mpChildren[idx].setAnm(mdl, pat, mode); + + nw4r::g3d::AnmObjTexPatRes *res = + nw4r::g3d::G3dObj::DynamicCast(mpChildren[idx].getAnimObj()); + o->Attach(idx, res); +} + +void anmTexPat_c::play() { + nw4r::g3d::AnmObjTexPatOverride *o = nw4r::g3d::G3dObj::DynamicCast(mpAnmObj); + int size = o->Size(); + for (int i = 0; i < size; i++) { + play(i); + } +} + +void anmTexPat_c::play(s32 idx) { + if (mpChildren[idx].IsBound()) { + mpChildren[idx].play(); + } +} + +f32 anmTexPat_c::getFrame(s32 idx) const { + return mpChildren[idx].getFrame(); +} + +void anmTexPat_c::setFrame(f32 f, s32 idx) { + mpChildren[idx].setFrameOnly(f); +} + +void anmTexPat_c::setRate(f32 f, s32 idx) { + mpChildren[idx].setRate(f); +} + +bool anmTexPat_c::isStop(s32 idx) const { + return mpChildren[idx].isStop(); +} + +f32 anmTexPat_c::getFrameMax(s32 idx) const { + return mpChildren[idx].getEndFrame(); +} + +void anmTexPat_c::setFrameStart(f32 f, s32 idx) { + mpChildren[idx].setStartFrame(f); +} + +} // namespace m3d diff --git a/src/m/m3d/m_anmtexsrt.cpp b/src/m/m3d/m_anmtexsrt.cpp index df4ea1e5..e712e958 100644 --- a/src/m/m3d/m_anmtexsrt.cpp +++ b/src/m/m3d/m_anmtexsrt.cpp @@ -5,7 +5,7 @@ namespace m3d { -int anmTexSrt_c::child_c::getType() { +int anmTexSrt_c::child_c::getType() const { return 0x04; } @@ -135,7 +135,7 @@ anmTexSrt_c::~anmTexSrt_c() { anmTexSrt_c::remove(); } -int anmTexSrt_c::getType() { +int anmTexSrt_c::getType() const { return 0x04; } diff --git a/src/m/m3d/m_anmvis.cpp b/src/m/m3d/m_anmvis.cpp index 84a30edf..2d3f8ad2 100644 --- a/src/m/m3d/m_anmvis.cpp +++ b/src/m/m3d/m_anmvis.cpp @@ -9,7 +9,7 @@ namespace m3d { anmVis_c::~anmVis_c() {} -int anmVis_c::getType() { +int anmVis_c::getType() const { return 1; }