-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCamera.h
More file actions
160 lines (119 loc) · 3.38 KB
/
Copy pathCamera.h
File metadata and controls
160 lines (119 loc) · 3.38 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// Tyrus Malmstrom
// Header file for the Camera.cpp
#ifndef CAMERA_H_INCLUDE
#define CAMERA_H_INCLUDE
// directives:
#include <iostream>
#include <string>
#include <vector>
#include <limits>
#include <tuple>
#include <omp.h>
// Third Party Libraries:
#include <Eigen/Dense>
#include <Eigen/Geometry> // for cross product of vectors.
#include <PNGPP_FILES/png.hpp> // for using png++
// My custom header files:
#include "ModelObject.h"
#include "Ray.h"
#include "Face.h"
#include "Color.h"
#include "LightSource.h"
#include "Sphere.h"
using Eigen::Vector3d;
using Eigen::Vector3i;
using Eigen::RowVector3i;
// Structure that returns best_pt, best_sphere, best_t
typedef struct a{
a(): bs( nullptr ), best_t( numeric_limits<double>::infinity() ),
best_point( Vector3d(0.0,0.0,0.0) ), ics( false ){};
Sphere* bs;
double best_t;
Vector3d best_point;
bool ics;
}bestSphere;
class Camera{
public:
// Defining some list types to hold multiple:
typedef vector<ModelObject> ModelObjects;
typedef vector<LightSource> LightSources;
typedef vector<Sphere> SphereList;
// constructor:
Camera(){};
// member functions:
void parseScene( const string& scene_file );
void buildRM();
void calculateRays();
// bestSphere closestIntersect( const Ray& ray, const vector<spheres>& spheres);
// Where the magic happens:
RowVector3i mapColour(const Color& bc);
void writeMasterScene();
void writeSpheresAndModels( const string& out_file );
void writeSpheres(const string& out_file);
void writeModels( const string& out_file );
void rayTriangleIntersection();
void computeDist( const Face& current_face );
void closestIntersect( const Ray& ray, Sphere& current_sphere, bestSphere& ret );
void find_rayBSPH( const Ray& ray, bestSphere& ret );
/* Where all the magic happens! */
Color rayTrace( const Ray& ray, Color& accum, Color& refatt, int level);
void print_ptof();
// Methods for adding objects:~~~~~~~~~~~~~~~~~~~~~
void addLightSources( const LightSource& light ){
lightSource_list.push_back( light );
}
void addModels( const ModelObject& model ){
modelObject_list.push_back( model );
}
void addSphere( const Sphere& sphere ){
spheres.push_back( sphere );
}
// done for adding objects~~~~~~~~~~~~~~~~~~~~~~~~
const int numberOfSpheres() const{
return static_cast<int>(spheres.size());
}
const int numberOfModels() const{
return static_cast<int>(modelObject_list.size());
}
// class instance variables:
protected:
// location of the focal point
string eye_header;
// the look at point
string look_header;
// up vector
string supv;
// distacne from ip:
string dist_header;
// bounds
string bounds_header;
// res
string res_header;
// Camera specs:
Vector3d EYE;
Vector3d LOOKAP;
Vector3d UPV;
// RM basis vectors:
Vector3d WV;
Vector3d UV;
Vector3d VV;
double dist;
double bottom;
double left;
double top;
double right;
double width; // had to change this to double to have correct division
double height;
// array of rays hey...
vector< vector< Ray > > Rays;
// 2d array to hold all t's:
vector< vector< double > > ts;
vector< vector< Color > > ptof;
// ambient illumination in the scene:
Color ambient_color;
// Actual Lists:
ModelObjects modelObject_list;
LightSources lightSource_list;
SphereList spheres;
};
#endif // CAMERA_H_INCLUDE