-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.h
43 lines (33 loc) · 1.31 KB
/
model.h
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
#ifndef MODEL_H
#define MODEL_H
#include <stdlib.h>
#include <string.h>
#include "matrix4.h"
#include "vertex.h"
#include "tri.h"
#include "obj_parse.h"
struct Model {
struct Tri *mesh;
int num_tris;
// Texture maps.
// int map_width;
// int map_height;
// unsigned char *map_kd;
// The mesh coordinates are local to the model.
// (i.e., the center of the model is (0, 0, 0)).
// The following is the model matrix, which
// maps the mesh to world space.
struct Matrix4 model_to_world;
};
// We move Model instances by heap pointer.
struct Model *Model_create(struct Tri *mesh, int num_tris, float x, float y, float z, float rx, float ry, float rz, float sx, float sy, float sz);
struct Model *Model_from_obj(const char *file_name, float x, float y, float z, float rx, float ry, float rz, float sx, float sy, float sz);
void Model_destroy(struct Model *m);
inline void Model_translate(struct Model *m, float delta_x, float delta_y, float delta_z);
inline void Model_rotate(struct Model *m, float delta_rx, float delta_ry, float delta_rz);
inline void Model_scale(struct Model *m, float delta_sx, float delta_sy, float delta_sz);
// Presets.
struct Model *Model_unit_cube();
struct Model *Model_unit_triangle();
struct Model *Model_unit_square();
#endif