-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.h
executable file
·115 lines (97 loc) · 2.03 KB
/
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
#ifndef __HW1__PARSER__
#define __HW1__PARSER__
#include <string>
#include <vector>
namespace parser
{
//Notice that all the structures are as simple as possible
//so that you are not enforced to adopt any style or design.
struct Vec3f
{
float x, y, z;
};
struct Vec3i
{
int x, y, z;
};
struct Vec4f
{
float x, y, z, w;
};
struct Camera
{
Vec3f position;
Vec3f gaze;
Vec3f up;
Vec4f near_plane;
float near_distance;
int image_width, image_height;
std::string image_name;
};
struct PointLight
{
Vec3f position;
Vec3f intensity;
};
struct Material
{
bool is_mirror;
Vec3f ambient;
Vec3f diffuse;
Vec3f specular;
Vec3f mirror;
float phong_exponent;
};
struct Face
{
int v0_id;
int v1_id;
int v2_id;
};
struct Mesh
{
int material_id;
std::vector<Face> faces;
};
struct Triangle
{
int material_id;
Face indices;
Vec3f norm;
};
struct Sphere
{
int material_id;
int center_vertex_id;
float radius;
};
struct Ray
{
Vec3f e;
Vec3f d;
};
struct Intersection
{
float discriminant;
float t1;
float t2;
};
struct Scene
{
//Data
Vec3i background_color;
float shadow_ray_epsilon;
int max_recursion_depth;
std::vector<Camera> cameras;
Vec3f ambient_light;
std::vector<PointLight> point_lights;
std::vector<Material> materials;
std::vector<Vec3f> vertex_data;
std::vector<Mesh> meshes;
std::vector<Triangle> triangles;
std::vector<Sphere> spheres;
//Functions
void loadFromXml(const std::string &filepath);
};
}
#endif