A simple pathtracer program, capable of producing renderings of simple bodies. The program computes global illumination, by intersecting scene objects, such as luminaries and solid bodies, with idealised surface properies.
#include "./defines.hpp"
#include "./vec3.hpp"
#include "./camera.hpp"
namespace raytracer{
camera::camera(const vec3& pos, const vec3& upVect, const vec3& lookAt)
{
this->pos_= pos;
this->up_vect_= upVect;
recalc(&pos, &lookAt);
};
void camera::recalc(const vec3* pos, const vec3* lookAt)
{
if(pos== NULL) return;
pos_= vec3(pos->x, pos->y, pos->z).add(vec3(ACCURACY, 0, ACCURACY));//camera position
//the accuracy addition insures that the cross product between camdir and Y is non zero
vec3 diff_btw= pos_.add(lookAt->negative());//distance origin-camera
//camera direction vectors
this->dir_= diff_btw.negative().normalize();
this->right_= this->up_vect_.cross(dir_).normalize();//Y is up direction
this->down_= right_.cross(dir_);
};
}