summaryrefslogtreecommitdiff
path: root/src/m/m3d/m_anmvis.cpp
diff options
context:
space:
mode:
authorrobojumper <robojumper@gmail.com>2024-09-12 22:36:34 +0200
committerGitHub <noreply@github.com>2024-09-12 16:36:34 -0400
commit1180e1f4860d62bccd64bfa2a29eaeebd2c4b019 (patch)
treece6e231ef46aacbdad52ad7f6cbcd9d02dba555e /src/m/m3d/m_anmvis.cpp
parente2c4bb7be7fa731a335bce4bc22283d899133e39 (diff)
m3d (#13)
* Initial M3d Pass * `m_bmdl` and `m_bline` left --------- Co-authored-by: elijah-thomas774 <elijahthomas774@gmail.com> Co-authored-by: Elijah Thomas <42302100+elijah-thomas774@users.noreply.github.com>
Diffstat (limited to 'src/m/m3d/m_anmvis.cpp')
-rw-r--r--src/m/m3d/m_anmvis.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/m/m3d/m_anmvis.cpp b/src/m/m3d/m_anmvis.cpp
new file mode 100644
index 00000000..68d4bd21
--- /dev/null
+++ b/src/m/m3d/m_anmvis.cpp
@@ -0,0 +1,57 @@
+#include <m/m3d/m3d.h>
+#include <m/m3d/m_anmvis.h>
+#include <nw4r/g3d/g3d_anmvis.h>
+#include <nw4r/g3d/g3d_resanmvis.h>
+#include <nw4r/g3d/g3d_resmdl.h>
+
+namespace m3d {
+
+anmVis_c::~anmVis_c() {}
+
+int anmVis_c::getType() const {
+ return nw4r::g3d::ScnMdlSimple::ANMOBJTYPE_VIS;
+}
+
+bool anmVis_c::create(nw4r::g3d::ResMdl mdl, nw4r::g3d::ResAnmVis anm, mAllocator_c *alloc, u32 *pSize) {
+ if (alloc == nullptr) {
+ alloc = internal::l_allocator_p;
+ }
+
+ u32 tmp;
+ if (pSize == nullptr) {
+ pSize = &tmp;
+ }
+
+ nw4r::g3d::AnmObjVisRes::Construct(nullptr, pSize, anm, mdl);
+ if (!createAllocator(alloc, pSize)) {
+ return false;
+ }
+
+ mpAnmObj = nw4r::g3d::AnmObjVisRes::Construct(&mAllocator, &tmp, anm, mdl);
+ if (!mpAnmObj->Bind(mdl)) {
+ remove();
+ return false;
+ } else {
+ setFrmCtrlDefault(anm, PLAY_MODE_4);
+ return true;
+ }
+}
+
+void anmVis_c::setAnm(m3d::bmdl_c &mdl, nw4r::g3d::ResAnmVis anm, m3d::playMode_e mode) {
+ mdl.removeAnm((nw4r::g3d::ScnMdlSimple::AnmObjType)getType());
+ mpAnmObj->Release();
+ mpFrameHeap->free(0x3);
+ u32 tmp;
+ mpAnmObj = nw4r::g3d::AnmObjVisRes::Construct(&mAllocator, &tmp, anm, mdl.getResMdl());
+ mpAnmObj->Bind(mdl.getResMdl());
+ setFrmCtrlDefault(anm, mode);
+}
+
+void anmVis_c::setFrmCtrlDefault(nw4r::g3d::ResAnmVis &anm, m3d::playMode_e mode) {
+ if (mode == PLAY_MODE_4) {
+ mode = anm.GetAnmPolicy() == nw4r::g3d::ANM_POLICY_ONETIME ? PLAY_MODE_1 : PLAY_MODE_0;
+ }
+ set(anm.GetNumFrame(), mode, 1.0f, -1.0f);
+}
+
+} // namespace m3d