initial commit
[o2demo] / src / mesh.h
1 #ifndef MESH_H_
2 #define MESH_H_
3
4 #include <inttypes.h>
5
6 struct g3d_vertex {
7         float x, y, z;
8         float nx, ny, nz;
9         float u, v;
10         unsigned char r, g, b, a;
11 };
12
13
14 struct g3d_mesh {
15         int prim;
16         struct g3d_vertex *varr;
17         uint16_t *iarr;
18         int vcount, icount;
19 };
20
21 int load_mesh(struct g3d_mesh *mesh, const char *fname);
22 int save_mesh(struct g3d_mesh *mesh, const char *fname);
23
24 void draw_mesh(struct g3d_mesh *mesh);
25
26 void apply_mesh_xform(struct g3d_mesh *mesh, const float *xform);
27 int append_mesh(struct g3d_mesh *ma, struct g3d_mesh *mb);
28 int indexify_mesh(struct g3d_mesh *mesh);
29
30 void normalize_mesh_normals(struct g3d_mesh *mesh);
31
32 int gen_sphere_mesh(struct g3d_mesh *mesh, float rad, int usub, int vsub);
33 int gen_plane_mesh(struct g3d_mesh *mesh, float width, float height, int usub, int vsub);
34 int gen_torus_mesh(struct g3d_mesh *mesh, float rad, float ringrad, int usub, int vsub);
35
36 #endif  /* MESH_H_ */