summaryrefslogtreecommitdiff
path: root/include/egg/gfx/eggG3DUtility.h
blob: df57002000af3ee3cddba99e3a9f45decd267c37 (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
#ifndef EGG_G3D_UTILITY_H
#define EGG_G3D_UTILITY_H

#include "egg/egg_types.h"
#include "nw4r/g3d/g3d_scnmdl.h"
#include "nw4r/g3d/res/g3d_resmat.h"
#include "nw4r/math/math_types.h"
#include "rvl/MEM/mem_allocator.h"

namespace EGG {

class G3DUtility {
public:
    static MEMAllocator *getAllocator() {
        return sAllocator;
    }

    struct SetTextureResult {
        /* 0x00 */ u8 _0x00[2];
        /* 0x02 */ s8 texMapId;
        /* 0x03 */ s8 texCoordId;
    };

    struct SearchResult {
        /* 0x00 */ u16 nodeIdx;
        /* 0x04 */ const char *name;
    };

    static u16 SetTexture(
        nw4r::g3d::ResMat resMat, nw4r::g3d::ScnMdl::CopiedMatAccess *param_2, const char *name, const GXTexObj *texObj,
        bool copy, SetTextureResult *pResult, int maxNumResults, int param_8
    );

    static int ApplyLightMat(nw4r::g3d::ResMdl mdl, const char *prefix);

    static bool setUpLightSet(nw4r::g3d::LightSetting &, nw4r::g3d::ResAnmScn, int);

    static void *BumpAlloc(u32 size, u32 align);
    static void ResetBumpAlloc() {
        sOffset = 0;
    }

    static void create(u32 size, Heap *pHeap);

    static int searchStringResNode(nw4r::g3d::ResMdl mdl, const char * name, bool exactMatch, SearchResult *pResults, int maxNumResults);
    static int searchStringResMat(nw4r::g3d::ResMdl mdl, const char * name, bool exactMatch, SearchResult *pResults, int maxNumResults);
    static int searchStringResTexPlttInfo(nw4r::g3d::ResMdl mdl, const char * name, bool exactMatch, SearchResult *pResults, int maxNumResults);

    typedef int (*MdlSearch)(nw4r::g3d::ResMdl mdl, const char * name, bool exactMatch, SearchResult *pResults, int maxNumResults);

private:
    static void defaultTexMtxFunc(nw4r::math::MTX34 *pMtx, s8 camRef, s8 lightRef);

    static MEMAllocator *sAllocator;
    static void *sBuf;
    static u32 sSize;
    static u32 sOffset;
    static u8 sId;
};

} // namespace EGG

#endif