-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.cpp
132 lines (131 loc) · 4.55 KB
/
util.cpp
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
#include "util.h"
#include <iostream>
/*
Overloads << operator for Vec3f object, allowing it to be more human readable.
*/
std::ostream& operator<<(std::ostream& os, const parser::Vec3f& vec)
{
os << '(' << vec.x << ", " << vec.y << ", " << vec.z << ')';
return os;
}
/*
Overloads << operator for Vec3i object, allowing it to be more human readable.
*/
std::ostream& operator<<(std::ostream& os, const parser::Vec3i& vec)
{
os << '(' << vec.x << ", " << vec.y << ", " << vec.z << ')';
return os;
}
/*
Overloads << operator for Vec4f object, allowing it to be more human readable.
*/
std::ostream& operator<<(std::ostream& os, const parser::Vec4f& plane)
{
os << '(' << plane.x << ", " << plane.y << ", " << plane.z << ", " << plane.w << ')';
return os;
}
/*
Overloads << operator for Camera object, allowing it to be more human readable.
*/
std::ostream& operator<<(std::ostream& os, const parser::Camera& cam)
{
os << "Image name: " << cam.image_name << '\n'
<< "H:"<< cam.image_height << ", W: "<< cam.image_width << '\n'
<< "Near plane: " << cam.near_plane << '\n'
<< "Near distance:" << cam.near_distance << '\n'
<< "Position: " << cam.position << '\n'
<< "Up vector: " << cam.up << '\n'
<< "Gaze vector: " << cam.gaze << '\n';
return os;
}
/*
Overloads << operator for PointLight object, allowing it to be more human readable.
*/
std::ostream& operator<<(std::ostream& os, const parser::PointLight& pl)
{
os << "Intensity: " << pl.intensity << '\n'
<< "Position:"<< pl.position << '\n';
return os;
}
/*
Overloads << operator for Material object, allowing it to be more human readable.
*/
std::ostream& operator<<(std::ostream& os, const parser::Material& mat)
{
os << "Ambient: " << mat.ambient << '\n'
<< "Diffuse: " << mat.diffuse << '\n'
<< "Specular: " << mat.specular << '\n'
<< "Mirror: " << mat.mirror << '\n'
<< "Phong exponent: " << mat.phong_exponent << '\n';
return os;
}
/*
Overloads << operator for Sphere object, allowing it to be more human readable.
*/
std::ostream& operator<<(std::ostream& os, const parser::Sphere& sph)
{
os << "Material ID: " << sph.material_id << '\n'
<< "Center vertex ID: " << sph.center_vertex_id << '\n'
<< "Radius: " << sph.radius << '\n';
return os;
}
/*
Overloads << operator for Scene object, allowing it to be more human readable.
*/
std::ostream& operator<<(std::ostream& os, const parser::Scene& scene)
{
int counter = 0;
os
<< "------------------------------\n"
<< " SCENE PROPERTIES \n"
<< "------------------------------\n"
<< "Background color: " << scene.background_color << '\n'
<< "Shadow ray epsilon: " << scene.shadow_ray_epsilon << '\n'
<< "Maximum recursion depth: " << scene.max_recursion_depth << '\n'
<< "Ambient light: " << scene.ambient_light << '\n'
<< "Vertex count: " << scene.vertex_data.size() << '\n'
<< "Mesh count: " << scene.meshes.size() << '\n'
<< "Triangle count: " << scene.triangles.size() << '\n'
<< "------------------------------\n"
<< " Camera(s) \n"
<< "------------------------------\n";
for (parser::Camera c : scene.cameras)
{
os << "Camera " << counter++ << ":\n---------\n" << c;
}
counter = 1;
os
<< "------------------------------\n"
<< " Point light(s) \n"
<< "------------------------------\n";
for (parser::PointLight pl : scene.point_lights)
{
os << "Point Light " << counter++ << ":\n--------------\n" << pl;
}
counter = 1;
os
<< "------------------------------\n"
<< " Material(s) \n"
<< "------------------------------\n";
for (parser::Material mat : scene.materials)
{
os << "Material " << counter++ << ":\n-----------\n" << mat;
}
counter = 1;
os
<< "------------------------------\n"
<< " Spheres \n"
<< "------------------------------\n";
for (parser::Sphere sph : scene.spheres)
{
os << "Sphere " << counter++ << ":\n---------\n" << sph;
}
return os;
}
/*
Prints the scene configuration in a human readable format.
*/
void util::Util::PrintSceneDetails(parser::Scene scene)
{
std::cout << scene << std::endl;
}