summaryrefslogtreecommitdiff
path: root/oldStuff/3dlib/treeki3d.h
blob: c88f91cc925b4bcb3609f644b5c642272401d9c0 (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
/* Treeki's 3D Library for Wii */

#ifndef TREEKI3D_H
#define TREEKI3D_H

/*******************************************************************************
* IMPORTS/ENGINE HOOKS
*******************************************************************************/

#define GEKKO

#include <common.h>
#include "rvl/mtx.h"
#include "rvl/GXEnum.h"
#include "rvl/GXStruct.h"
#include "rvl/GXTransform.h"
#include "rvl/GXGeometry.h"
#include "rvl/GXDispList.h"
#include "rvl/GXLighting.h"
#include "rvl/GXTev.h"
#include "rvl/GXTexture.h"
#include "rvl/GXCull.h"
#include "rvl/GXPixel.h"
#include "rvl/GXBump.h"
#include "rvl/OSCache.h"
#include "rvl/tpl.h"
#include "rvl/vifuncs.h"
#include "rvl/arc.h"

GXRenderModeObj *Hook_GetGXRenderModeObj();



namespace T3D {

/*******************************************************************************
* RESOURCE STRUCTS
*******************************************************************************/


struct tmdl_header {
	u32 magic;				// always TMDL
	u32 version;			// currently 2
	u32 shape_count;
};
// [[Followed by an array of u32s for each shape offset]]

struct tmdl_shape {
	u32 dl_offset;			// must be aligned to 0x20
	u32 dl_size;			// must be aligned to 0x20
	u32 mat_offset;
	u32 pos_arr_offset;		// must be aligned to 0x20
	u32 pos_arr_size;		// must be aligned to 0x20
	u32 nrm_arr_offset;		// must be aligned to 0x20
	u32 nrm_arr_size;		// must be aligned to 0x20
	u32 uv_arr_offset;		// must be aligned to 0x20
	u32 uv_arr_size;		// must be aligned to 0x20
};

struct tmdl_material {
	u32 texture_id;			// once the model is bound, points to tpl
	GXColor mat_colour;
};

/*******************************************************************************
* INTERNAL STRUCTS
*******************************************************************************/

class Model; // don't you just love circular references

struct RenderInfo {
	Model *model;
	Mtx matrix;
};

struct CameraInfo {
	GXProjectionType projection;
	Mtx44 projection_matrix;
	Mtx view_matrix;
};

/*******************************************************************************
* PUBLIC CLASSES
*******************************************************************************/

class Model {
private:
	tmdl_header *model_res;
	TPLPalette *texture_res;
	
	void setupMaterialGX(tmdl_material *material);
	void drawShape(RenderInfo *info, int shape_id);
	
public:
	bool bind(void *data, const char *mdlname);
	void addToDrawList(Mtx matrix);
	void draw(RenderInfo *info);
	
};

/*******************************************************************************
* CONVENIENT STUFF
*******************************************************************************/

extern const GXColor Black, White;

/*******************************************************************************
* GLOBAL T3D VARIABLES/FUNCTIONS
*******************************************************************************/

#define OBJ_COUNT 10

extern u32 HasBeenInited;
extern RenderInfo *RenderQueue;
extern int RenderQueuePos;

extern CameraInfo Camera;

bool Init(bool test);
void DrawQueue();

};

#endif