summaryrefslogtreecommitdiff
path: root/libs/JSystem/J3DGraphAnimator/J3DMaterialAnm.cpp
blob: 56fd04300c4cbd60acf43deb294993a13620648a (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include "JSystem/J3DGraphAnimator/J3DMaterialAnm.h"
#include "JSystem/J3DGraphBase/J3DMaterial.h"
#include "dol2asm.h"

//
// Forward References:
//

extern "C" void calc__14J3DMaterialAnmCFP11J3DMaterial();

//
// External References:
//

extern "C" void __dt__14J3DMaterialAnmFv();

//
// Declarations:
//

void J3DMaterialAnm::initialize() {
    for (int i = 0; i < ARRAY_SIZE(mMatColorAnm); i++) {
        mMatColorAnm[i].setAnmFlag(false);
    }

    for (int i = 0; i < ARRAY_SIZE(mTexNoAnm); i++) {
        mTexNoAnm[i].setAnmFlag(false);
    }

    for (int i = 0; i < ARRAY_SIZE(mTevColorAnm); i++) {
        mTevColorAnm[i].setAnmFlag(false);
    }

    for (int i = 0; i < ARRAY_SIZE(mTevKColorAnm); i++) {
        mTevKColorAnm[i].setAnmFlag(false);
    }

    for (int i = 0; i < ARRAY_SIZE(mTexMtxAnm); i++) {
        mTexMtxAnm[i].setAnmFlag(false);
    }
}

void J3DMaterialAnm::calc(J3DMaterial* pMat) const {
    for (u32 i = 0; i < ARRAY_SIZE(mMatColorAnm); i++) {
        if (mMatColorAnm[i].getAnmFlag()) {
            _GXColor* color = pMat->getColorBlock()->getMatColor(i);
            mMatColorAnm[i].calc(color);
        }
    }

    u16 tmp;
    for (u32 i = 0; i < ARRAY_SIZE(mTexNoAnm); i++) {
        if (mTexNoAnm[i].getAnmFlag()) {
            mTexNoAnm[i].calc(&tmp);
            pMat->getTevBlock()->setTexNo(i, tmp);
        }
    }

    for (u32 i = 0; i < 3; i++) {
        if (mTevColorAnm[i].getAnmFlag()) {
            _GXColorS10* color = pMat->getTevBlock()->getTevColor(i);
            mTevColorAnm[i].calc(color);
        }
    }

    for (u32 i = 0; i < ARRAY_SIZE(mTevKColorAnm); i++) {
        if (mTevKColorAnm[i].getAnmFlag()) {
            _GXColor* color = pMat->getTevBlock()->getTevKColor(i);
            mTevKColorAnm[i].calc(color);
        }
    }

    for (u32 i = 0; i < ARRAY_SIZE(mTexMtxAnm); i++) {
        if (mTexMtxAnm[i].getAnmFlag()) {
            J3DTexMtx* texMtx = pMat->getTexGenBlock()->getTexMtx(i);
            mTexMtxAnm[i].calc(&texMtx->getTexMtxInfo().mSRT);
        }
    }
}

void J3DMaterialAnm::setMatColorAnm(int idx, J3DMatColorAnm* p_matColorAnm) {
    if (p_matColorAnm == NULL) {
        mMatColorAnm[idx].setAnmFlag(false);
    } else {
        mMatColorAnm[idx] = *p_matColorAnm;
    }
}

void J3DMaterialAnm::setTexMtxAnm(int idx, J3DTexMtxAnm* p_texMtxAnm) {
    if (p_texMtxAnm == NULL) {
        mTexMtxAnm[idx].setAnmFlag(false);
    } else {
        mTexMtxAnm[idx] = *p_texMtxAnm;
    }
}

void J3DMaterialAnm::setTexNoAnm(int idx, J3DTexNoAnm* p_texNoAnm) {
    if (p_texNoAnm == NULL) {
        mTexNoAnm[idx].setAnmFlag(false);
    } else {
        mTexNoAnm[idx] = *p_texNoAnm;
    }
}

void J3DMaterialAnm::setTevColorAnm(int idx, J3DTevColorAnm* p_tevColorAnm) {
    if (p_tevColorAnm == NULL) {
        mTevColorAnm[idx].setAnmFlag(false);
    } else {
        mTevColorAnm[idx] = *p_tevColorAnm;
    }
}

void J3DMaterialAnm::setTevKColorAnm(int idx, J3DTevKColorAnm* p_tevKColorAnm) {
    if (p_tevKColorAnm == NULL) {
        mTevKColorAnm[idx].setAnmFlag(false);
    } else {
        mTevKColorAnm[idx] = *p_tevKColorAnm;
    }
}

/* ############################################################################################## */
/* 803CEE60-803CEE70 02BF80 0010+00 0/0 10/10 74/74 .data            __vt__14J3DMaterialAnm */
SECTION_DATA extern void* __vt__14J3DMaterialAnm[4] = {
    (void*)NULL /* RTTI */,
    (void*)NULL,
    (void*)__dt__14J3DMaterialAnmFv,
    (void*)calc__14J3DMaterialAnmCFP11J3DMaterial,
};