summaryrefslogtreecommitdiff
path: root/src/d/actor/d_a_obj_gong.cpp
blob: 6f28ea052056d8b275e91a45295339e3ad509d2d (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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/**
 * d_a_obj_gong.cpp
 * Object - Gong (Tetra's Ship)
 */

#include "d/dolzel_rel.h" // IWYU pragma: keep
#include "d/actor/d_a_obj_gong.h"
#include "res/Object/Vdora.h"
#include "f_op/f_op_actor_mng.h"
#include "JSystem/JUtility/JUTAssert.h"
#include "d/d_a_obj.h"
#include "d/d_bg_w.h"
#include "d/d_com_inf_game.h"
#include "d/d_drawlist.h"
#include "m_Do/m_Do_ext.h"
#include "m_Do/m_Do_mtx.h"

namespace daObjGong {
    namespace {
        struct Attr_c {
            /* 0x00 */ f32 spec;
            /* 0x04 */ f32 offsetY;
        };

        static const Attr_c L_attr = {
            0.75f, 125.0f,
        };

        inline const Attr_c & attr() { return L_attr; }
    }
}

const char daObjGong::Act_c::M_arcname[6] = "Vdora";

/* 00000078-0000009C       .text solidHeapCB__Q29daObjGong5Act_cFP10fopAc_ac_c */
BOOL daObjGong::Act_c::solidHeapCB(fopAc_ac_c* i_this) {
    return ((Act_c*)i_this)->create_heap();
}

/* 0000009C-0000028C       .text create_heap__Q29daObjGong5Act_cFv */
bool daObjGong::Act_c::create_heap() {
    J3DModelData* modelData = static_cast<J3DModelData*>(dComIfG_getObjectRes(M_arcname, dRes_INDEX_VDORA_BDL_VDORA_e));
    J3DAnmTransformKey* bck = static_cast<J3DAnmTransformKey*>(dComIfG_getObjectRes(M_arcname, dRes_INDEX_VDORA_BCK_05_VDORA_CUT02_HIT_e));
    JUT_ASSERT(0xbd, (modelData != NULL) && (bck != NULL));

    mpMorf = new mDoExt_McaMorf(
        modelData,
        NULL, NULL,
        bck,
        J3DFrameCtrl::EMode_LOOP, 1.0f, 0, -1, 0,
        NULL,
        0x00000000,
        0x11020203
    );
    J3DModel * model = mpMorf != NULL ? mpMorf->getModel() : NULL;

    bool ret = false;
    if (model != NULL) {
        J3DSkinDeform * deform = new J3DSkinDeform();
        if (deform != NULL) {
            s32 err = model->setSkinDeform(deform, 1);
            JUT_ASSERT(0xd7, (err == J3DErrType_Success) || (err == J3DErrType_OutOfMemory));
            if (err == J3DErrType_Success)
                ret = true;
        }
    }

    return model != NULL && ret;
}

/* 0000028C-00000374       .text _create__Q29daObjGong5Act_cFv */
cPhs_State daObjGong::Act_c::_create() {
    fopAcM_ct(this, Act_c);

    cPhs_State ret = dComIfG_resLoad(&mPhs, M_arcname);

    if (ret == cPhs_COMPLEATE_e) {
        if (fopAcM_entrySolidHeap(this, solidHeapCB, 0x0)) {
            fopAcM_SetMtx(this, mpMorf->getModel()->getBaseTRMtx());
            init_mtx();
            fopAcM_setCullSizeBox(this, -100.0f, -1.0f, -50.0f, 100.0f, 230.0f, 50.0f);
            eyePos.y += attr().offsetY;
        } else {
            ret = cPhs_ERROR_e;
        }
    }

    return ret;
}

/* 00000374-000003A4       .text _delete__Q29daObjGong5Act_cFv */
bool daObjGong::Act_c::_delete() {
    dComIfG_resDeleteDemo(&mPhs, M_arcname);
    return true;
}

/* 000003A4-00000414       .text set_mtx__Q29daObjGong5Act_cFv */
void daObjGong::Act_c::set_mtx() {
    mDoMtx_stack_c::transS(current.pos);
    mDoMtx_stack_c::ZXYrotM(shape_angle);
    mpMorf->getModel()->setBaseTRMtx(mDoMtx_stack_c::get());
}

/* 00000414-00000454       .text init_mtx__Q29daObjGong5Act_cFv */
void daObjGong::Act_c::init_mtx() {
    mpMorf->getModel()->setBaseScale(scale);
    set_mtx();
}

/* 00000454-000004A4       .text demo_move__Q29daObjGong5Act_cFv */
bool daObjGong::Act_c::demo_move() {
    return dDemo_setDemoData(
        this,
        dDemo_actor_c::ENABLE_TRANS_e | dDemo_actor_c::ENABLE_ROTATE_e | dDemo_actor_c::ENABLE_ANM_e | dDemo_actor_c::ENABLE_ANM_FRAME_e,
        mpMorf, "Vdora"
    );
}

/* 000004A4-000004F0       .text _execute__Q29daObjGong5Act_cFv */
bool daObjGong::Act_c::_execute() {
    demo_move();
    mpMorf->play(NULL, 0, 0);
    set_mtx();
    return true;
}

/* 000004F0-00000580       .text _draw__Q29daObjGong5Act_cFv */
bool daObjGong::Act_c::_draw() {
    J3DModel* model = (J3DModel*)mpMorf->getModel();
    J3DModelData* modelData = (J3DModelData*)model->getModelData();
    g_env_light.settingTevStruct(TEV_TYPE_ACTOR, &current.pos, &tevStr);
    g_env_light.setLightTevColorType(model, &tevStr);
    dDlst_texSpecmapST(&eyePos, &tevStr, modelData, attr().spec);
    mpMorf->updateDL();
    return true;
}

namespace daObjGong {
    namespace {
        /* 00000580-000005A0       .text Mthd_Create__Q29daObjGong26@unnamed@d_a_obj_gong_cpp@FPv */
        cPhs_State Mthd_Create(void* i_this) {
            return ((Act_c*)i_this)->_create();
        }

        /* 000005A0-000005C4       .text Mthd_Delete__Q29daObjGong26@unnamed@d_a_obj_gong_cpp@FPv */
        BOOL Mthd_Delete(void* i_this) {
            return ((Act_c*)i_this)->_delete();
        }

        /* 000005C4-000005E8       .text Mthd_Execute__Q29daObjGong26@unnamed@d_a_obj_gong_cpp@FPv */
        BOOL Mthd_Execute(void* i_this) {
            return ((Act_c*)i_this)->_execute();
        }

        /* 000005E8-0000060C       .text Mthd_Draw__Q29daObjGong26@unnamed@d_a_obj_gong_cpp@FPv */
        BOOL Mthd_Draw(void* i_this) {
            return ((Act_c*)i_this)->_draw();
        }

        /* 0000060C-00000614       .text Mthd_IsDelete__Q29daObjGong26@unnamed@d_a_obj_gong_cpp@FPv */
        BOOL Mthd_IsDelete(void* i_this) {
            return TRUE;
        }

        static actor_method_class Mthd_Table = {
            (process_method_func)Mthd_Create,
            (process_method_func)Mthd_Delete,
            (process_method_func)Mthd_Execute,
            (process_method_func)Mthd_IsDelete,
            (process_method_func)Mthd_Draw,
        };
    }
}

actor_process_profile_definition g_profile_Obj_Gong = {
    /* Layer ID     */ fpcLy_CURRENT_e,
    /* List ID      */ 0x0007,
    /* List Prio    */ fpcPi_CURRENT_e,
    /* Proc Name    */ fpcNm_Obj_Gong_e,
    /* Proc SubMtd  */ &g_fpcLf_Method.base,
    /* Size         */ sizeof(daObjGong::Act_c),
    /* Size Other   */ 0,
    /* Parameters   */ 0,
    /* Leaf SubMtd  */ &g_fopAc_Method.base,
    /* Draw Prio    */ fpcDwPi_Obj_Gong_e,
    /* Actor SubMtd */ &daObjGong::Mthd_Table,
    /* Status       */ fopAcStts_NOCULLEXEC_e | fopAcStts_CULL_e | fopAcStts_UNK40000_e,
    /* Group        */ fopAc_ACTOR_e,
    /* Cull Type    */ fopAc_CULLBOX_CUSTOM_e,
};