summaryrefslogtreecommitdiff
path: root/model.h
blob: c114b5e2f8d4a7a1fb4d8dc46bbdb7d938e6c362 (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
#ifndef model_h
#define model_h

#include "prbm.h"
#include "arena.h"

#define pos_loc  0
#define norm_loc 1
#define texc_loc 2

#define proj_matrix_name "proj"
#define view_matrix_name "view"
#define model_matrix_name "model"

struct vertex {
    v3 pos;
    v3 norm;
    v2 texc;
};

struct mesh {
    v3 pos;
    v3 angles;
    v3 scale;
    i32 nvertices;
    struct vertex *vertices;
    i32 nindices;
    u32 *indices;
    struct texture *texture;
    u32 vao;
    u32 vbo;
    u32 ebo;
};

struct model {
    v3 pos;
    v3 angles;
    v3 scale;
    i32 nmeshes;
    struct mesh *meshes;
};

mat get_model_matrix(v3 pos, v3 angles, v3 scale);
struct mesh init_mesh(v3 pos, v3 angles, v3 scale,
                      i32 nvertices, struct vertex *vertices,
                      i32 nindices, u32 *indices, struct texture *texture);
void clear_mesh(struct mesh *mesh);
struct mesh gen_quad(struct arena *arena, v3 pos, v3 angles, v3 scale, f32 width, f32 height);
struct model init_model(v3 pos, v3 angles, v3 scale, i32 nmeshes, struct mesh *meshes);

#endif