summaryrefslogtreecommitdiff
path: root/src/m/m3d/m_anmchrblend.cpp
blob: 8fa48f2e150d165d9843cb17c402efb669ad1b54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "m/m3d/m_anmchrblend.h"

#include "m/m3d/m3d.h"
#include "nw4r/g3d/g3d_anmchr.h"
#include "nw4r/g3d/res/g3d_resanmchr.h"

namespace m3d {

anmChrBlend_c::~anmChrBlend_c() {}

int anmChrBlend_c::getType() const {
    return nw4r::g3d::ScnMdlSimple::ANMOBJTYPE_CHR;
}

bool anmChrBlend_c::create(nw4r::g3d::ResMdl mdl, int num, mAllocator_c *alloc, u32 *pSize) {
    if (alloc == nullptr) {
        alloc = internal::l_allocator_p;
    }

    u32 size;
    if (pSize == nullptr) {
        pSize = &size;
    }

    nw4r::g3d::AnmObjChrBlend::Construct(nullptr, pSize, mdl, num);
    if (!createAllocator(alloc, pSize)) {
        return false;
    }

    mpAnmObj = nw4r::g3d::AnmObjChrBlend::Construct(&mAllocator, &size, mdl, num);
    return true;
}

void anmChrBlend_c::attach(int idx, nw4r::g3d::AnmObjChrRes *anm, f32 weight) {
    nw4r::g3d::AnmObjChrBlend *obj = nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjChrBlend>(mpAnmObj);
    obj->SetWeight(idx, weight);
    obj->Attach(idx, anm);
}

void anmChrBlend_c::attach(int idx, anmChr_c *anm, f32 weight) {
    nw4r::g3d::AnmObjChrRes *res = nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjChrRes>(anm->getAnimObj());
    attach(idx, res, weight);
}

void anmChrBlend_c::detach(int idx) {
    nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjChrBlend>(mpAnmObj)->Detach(idx);
}

void anmChrBlend_c::setWeight(int idx, f32 weight) {
    nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjChrBlend>(mpAnmObj)->SetWeight(idx, weight);
}

f32 anmChrBlend_c::getWeight(int idx) const {
    return nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjChrBlend>(mpAnmObj)->GetWeight(idx);
}

} // namespace m3d