-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobj_parser.h
133 lines (104 loc) · 2.86 KB
/
obj_parser.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
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
125
126
127
128
129
130
131
132
#ifndef OBJ_PARSER_H
#define OBJ_PARSER_H
#include "list.h"
#define OBJ_FILENAME_LENGTH 2048
#define MATERIAL_NAME_SIZE 1024
#define OBJ_LINE_SIZE 1024
#define MAX_VERTEX_COUNT 4 //can only handle quads or triangles
struct obj_face {
int vertex_index[MAX_VERTEX_COUNT];
int normal_index[MAX_VERTEX_COUNT];
int texture_index[MAX_VERTEX_COUNT];
int vertex_count;
int material_index;
};
struct obj_sphere {
int pos_index;
int up_normal_index;
int equator_normal_index;
int texture_index[MAX_VERTEX_COUNT];
int material_index;
};
struct obj_plane {
int pos_index;
int normal_index;
int rotation_normal_index;
int texture_index[MAX_VERTEX_COUNT];
int material_index;
};
struct obj_vector {
double e[3];
};
struct obj_material {
char name[MATERIAL_NAME_SIZE];
char texture_filename[OBJ_FILENAME_LENGTH];
double amb[3];
double diff[3];
double spec[3];
double reflect;
double refract;
double trans;
double shiny;
double glossy;
double refract_index;
};
struct obj_camera {
int camera_pos_index;
int camera_look_point_index;
int camera_up_norm_index;
};
struct obj_light_point {
int pos_index;
int material_index;
};
struct obj_light_disc {
int pos_index;
int normal_index;
int material_index;
};
struct obj_light_quad {
int vertex_index[MAX_VERTEX_COUNT];
int material_index;
};
struct obj_growable_scene_data {
// vector extreme_dimensions[2];
char scene_filename[OBJ_FILENAME_LENGTH];
char material_filename[OBJ_FILENAME_LENGTH];
list vertex_list;
list vertex_normal_list;
list vertex_texture_list;
list face_list;
list sphere_list;
list plane_list;
list light_point_list;
list light_quad_list;
list light_disc_list;
list material_list;
obj_camera *camera;
};
struct obj_scene_data {
obj_vector **vertex_list;
obj_vector **vertex_normal_list;
obj_vector **vertex_texture_list;
obj_face **face_list;
obj_sphere **sphere_list;
obj_plane **plane_list;
obj_light_point **light_point_list;
obj_light_quad **light_quad_list;
obj_light_disc **light_disc_list;
obj_material **material_list;
int vertex_count;
int vertex_normal_count;
int vertex_texture_count;
int face_count;
int sphere_count;
int plane_count;
int light_point_count;
int light_quad_count;
int light_disc_count;
int material_count;
obj_camera *camera;
};
int parse_obj_scene(obj_scene_data *data_out, char *filename);
void delete_obj_data(obj_scene_data *data_out);
#endif