summaryrefslogtreecommitdiff
path: root/src/nw4r/g3d/g3d_calcmaterial.cpp
blob: 710098b9b4b8efb4fc6493558ca3368ea814138d (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
58
#include "nw4r/g3d.h" // IWYU pragma: export

namespace nw4r {
namespace g3d {

void CalcMaterialDirectly(ResMdl mdl, AnmObjTexPat *pAnmTexPat, AnmObjTexSrt *pAnmTexSrt, AnmObjMatClr *pAnmMatClr) {
    u32 i;
    u32 numMatID = mdl.GetResMatNumEntries();

    for (i = 0; i < numMatID; i++) {
        ResMat mat = mdl.GetResMat(i);

        if (pAnmTexPat != NULL && pAnmTexPat->TestExistence(i)) {
            TexPatAnmResult result;
            const TexPatAnmResult *pResult;

            pResult = pAnmTexPat->GetResult(&result, i);

            ApplyTexPatAnmResult(mat.GetResTexObj(), mat.GetResTlutObj(), pResult);

            mat.GetResTexObj().EndEdit();
            mat.GetResTlutObj().EndEdit();
        }

        if (pAnmTexSrt != NULL && pAnmTexSrt->TestExistence(i)) {
            TexSrtAnmResult result;
            const TexSrtAnmResult *pResult;

            ResTexSrt srt = mat.GetResTexSrt();
            ResMatIndMtxAndScale ind = mat.GetResMatIndMtxAndScale();

            pResult = pAnmTexSrt->GetResult(&result, i);

            ApplyTexSrtAnmResult(srt, ind, pResult);

            ind.EndEdit();
            srt.EndEdit();
        }

        if (pAnmMatClr != NULL && pAnmMatClr->TestExistence(i)) {
            ClrAnmResult result;
            const ClrAnmResult *pResult;

            ResMatTevColor tevColor = mat.GetResMatTevColor();
            ResMatChan chan = mat.GetResMatChan();

            pResult = pAnmMatClr->GetResult(&result, i);

            ApplyClrAnmResult(chan, tevColor, pResult);

            chan.EndEdit();
            tevColor.EndEdit();
        }
    }
}

} // namespace g3d
} // namespace nw4r