NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
anm_vis.cpp
1#include <game/mLib/m_3d.hpp>
2
3bool m3d::anmVis_c::create(nw4r::g3d::ResMdl mdl, nw4r::g3d::ResAnmVis anmVis, mAllocator_c *allocator, size_t *objSize) {
4 if (allocator == nullptr) {
5 allocator = internal::l_allocator_p;
6 }
7
8 size_t size;
9 if (objSize == nullptr) {
10 objSize = &size;
11 }
12
13 nw4r::g3d::AnmObjVisRes::Construct(nullptr, objSize, anmVis, mdl);
14 if (!createAllocator(allocator, objSize)) {
15 return false;
16 }
17
18 mpObj = nw4r::g3d::AnmObjVisRes::Construct(&mAllocator, &size, anmVis, mdl);
19 if (!mpObj->Bind(mdl)) {
20 remove();
21 return false;
22 }
23 setFrmCtrlDefault(anmVis, PLAYMODE_INHERIT);
24 return true;
25}
26
27void m3d::anmVis_c::setAnm(m3d::bmdl_c &mdl, nw4r::g3d::ResAnmVis anmVis, m3d::playMode_e playMode) {
28 nw4r::g3d::ScnMdlSimple::AnmObjType anmType = (nw4r::g3d::ScnMdlSimple::AnmObjType) getType();
29 mdl.removeAnm(anmType);
30 mpObj->Release();
31 mpHeap->free(MEM_FRMHEAP_FREE_ALL);
32
33 size_t size;
34 mpObj = nw4r::g3d::AnmObjVisRes::Construct(&mAllocator, &size, anmVis, mdl.getResMdl());
35 mpObj->Bind(mdl.getResMdl());
36 setFrmCtrlDefault(anmVis, playMode);
37}
38
39void m3d::anmVis_c::setFrmCtrlDefault(nw4r::g3d::ResAnmVis &anmVis, m3d::playMode_e playMode) {
40 if (playMode == PLAYMODE_INHERIT) {
41 playMode = (anmVis.p->mAnimateType == nw4r::g3d::ANM_POLICY_ONCE) ? FORWARD_ONCE : FORWARD_LOOP;
42 }
43 fanm_c::set(anmVis.getDuration(), playMode, 1.0f, -1.0f);
44}
@ MEM_FRMHEAP_FREE_ALL
Deallocates all memory blocks from the heap.
Definition MEMFrmHeap.h:13
void set(float duration, m3d::playMode_e playMode, float updateRate, float startFrame)
Starts the animation with the given parameters.
Definition fanm.cpp:51
An allocator class that wraps an EGG:Allocator .
playMode_e
Definition banm.hpp:7
@ FORWARD_ONCE
Play the animation forward once.
Definition banm.hpp:9
@ FORWARD_LOOP
Play the animation forward in a loop.
Definition banm.hpp:8
@ PLAYMODE_INHERIT
Use the play mode of the parent.
Definition banm.hpp:12