include/raytracer.h
branchpyrit
changeset 46 6493fb65f0b1
parent 44 3763b26244f0
child 47 320d5d466864
equal deleted inserted replaced
45:76b254ce92cf 46:6493fb65f0b1
    34 #include "scene.h"
    34 #include "scene.h"
    35 
    35 
    36 using namespace std;
    36 using namespace std;
    37 
    37 
    38 class Raytracer;
    38 class Raytracer;
       
    39 
    39 struct RenderrowData {
    40 struct RenderrowData {
    40 	Raytracer *rt;
    41 	Raytracer *rt;
    41 	int w;
    42 	int w;
    42 	Vector3 eye, dfix, dx, dy;
    43 	Vector3 eye, dfix, dx, dy;
    43 	Float *iter;
    44 	Float *iter;
    44 };
    45 };
    45 
    46 
       
    47 /**
       
    48  * main ray tracer class
       
    49  */
    46 class Raytracer
    50 class Raytracer
    47 {
    51 {
    48 	Container *top;
    52 	Container *top;
       
    53 	Sampler *sampler;
    49 	Camera *camera;
    54 	Camera *camera;
    50 	vector<Light*> lights;
    55 	vector<Light*> lights;
    51 	Colour bg_colour;
    56 	Colour bg_colour;
    52 	int ao_samples;
    57 	int ao_samples;
    53 	Float ao_distance, ao_angle;
    58 	Float ao_distance, ao_angle;
    58 
    63 
    59 	Vector3 SphereDistribute(int i, int n, Float extent, Vector3 &normal);
    64 	Vector3 SphereDistribute(int i, int n, Float extent, Vector3 &normal);
    60 public:
    65 public:
    61 	Raytracer(): top(NULL), camera(NULL), lights(), bg_colour(0.0, 0.0, 0.0),
    66 	Raytracer(): top(NULL), camera(NULL), lights(), bg_colour(0.0, 0.0, 0.0),
    62 		ao_samples(0), num_threads(2), subsample(8), oversample(0), max_depth(3) {};
    67 		ao_samples(0), num_threads(2), subsample(8), oversample(0), max_depth(3) {};
    63 	void render(int w, int h, Float *buffer);
    68 	void render();
    64 	Colour raytrace(Ray &ray, int depth, Shape *origin_shape);
    69 	Colour raytrace(Ray &ray, int depth, Shape *origin_shape);
    65 	void addshape(Shape *shape) { top->addShape(shape); };
    70 	void addshape(Shape *shape) { top->addShape(shape); };
    66 	void addlight(Light *light);
    71 	void addlight(Light *light);
       
    72 	void setSampler(Sampler *sampl) { sampler = sampl; };
    67 	void setCamera(Camera *cam) { camera = cam; };
    73 	void setCamera(Camera *cam) { camera = cam; };
    68 	void setTop(Container *atop) { top = atop; };
    74 	void setTop(Container *atop) { top = atop; };
    69 	Container *getTop() { return top; };
    75 	Container *getTop() { return top; };
    70 	void setSubsample(int sub) { subsample = sub; };
    76 	void setSubsample(int sub) { subsample = sub; };
    71 	int getSubsample() { return subsample; };
    77 	int getSubsample() { return subsample; };