Files
PhotonMF/tracer.hpp

42 lines
955 B
C++
Raw Normal View History

2016-12-26 15:41:29 -04:00
#pragma once
#ifndef TRACER_HPP
#define TRACER_HPP
#include <vector>
#include <glm/glm.hpp>
#include "figure.hpp"
#include "light.hpp"
#include "ray.hpp"
using std::vector;
using glm::vec2;
2017-01-02 02:39:24 -04:00
using glm::vec3;
using glm::mat4x4;
2016-12-26 15:41:29 -04:00
class Tracer {
public:
int m_h;
int m_w;
float m_fov;
float m_a_ratio;
2017-01-05 06:16:14 -04:00
bool indirect_l;
2016-12-26 15:41:29 -04:00
2017-01-05 06:16:14 -04:00
Tracer(): m_h(480), m_w(640), m_fov(90.0f), m_a_ratio(640.0f / 480.0f), indirect_l(false) { }
2016-12-27 15:26:49 -04:00
2017-01-05 06:16:14 -04:00
Tracer(int h, int w, float fov, bool il): m_h(h), m_w(w), m_fov(fov), indirect_l(il) {
m_a_ratio = static_cast<float>(w) / static_cast<float>(h);
};
2016-12-26 15:41:29 -04:00
vec2 sample_pixel(int i, int j) const;
vec3 trace_ray(Ray & r, vector<Figure *> & v_figures, vector<Light *> & v_lights, unsigned int rec_level) const;
2017-01-05 06:16:14 -04:00
private:
void create_coords_system(const vec3 &n, vec3 &nt, vec3 &nb) const;
vec3 sample_hemisphere(const float r1, const float r2) const;
void rotate_sample(vec3 & sample, const vec3 & n) const;
2016-12-26 15:41:29 -04:00
};
#endif