mesh, obj loading, sorting, shitty normals...
[dos_low3d] / src / mesh.h
1 #ifndef MESH_H_
2 #define MESH_H_
3
4 #include "3dgfx.h"
5
6 struct vec3 {
7         int32_t x, y, z;
8 };
9 struct meshface {
10         short prim;     /* 3 - triangle / 4 - quad */
11         unsigned short vidx[4];
12         unsigned char color;
13         struct vec3 norm;
14 };
15
16 struct mesh {
17         struct g3d_vertex *varr;
18         struct meshface *faces;
19         int nverts, nfaces;
20         unsigned short *zorder;
21 };
22
23 int load_mesh(struct mesh *m, const char *fname);
24 void destroy_mesh(struct mesh *m);
25
26 void flip_mesh_winding(struct mesh *m);
27 int conv_nonidx_mesh(struct mesh *m);
28 void calc_face_normals(struct mesh *m);
29
30 void sort_mesh(struct mesh *m, const int32_t *mvmat);
31 void draw_mesh(struct mesh *m);
32 void draw_mesh_zorder(struct mesh *m);
33
34 #endif  /* MESH_H_ */