src/raytracer.h
branchpyrit
changeset 20 f22952603f29
parent 19 4e0955fca797
child 21 79b516a3803d
equal deleted inserted replaced
19:4e0955fca797 20:f22952603f29
     8 #ifndef RAYTRACER_H
     8 #ifndef RAYTRACER_H
     9 #define RAYTRACER_H
     9 #define RAYTRACER_H
    10 
    10 
    11 #include <vector>
    11 #include <vector>
    12 
    12 
       
    13 #include "common.h"
    13 #include "kdtree.h"
    14 #include "kdtree.h"
    14 #include "scene.h"
    15 #include "scene.h"
    15 
    16 
    16 using namespace std;
    17 using namespace std;
    17 
    18 
    36 	float ao_distance, ao_angle;
    37 	float ao_distance, ao_angle;
    37 	int num_threads;
    38 	int num_threads;
    38 
    39 
    39 	Vector3 SphereDistribute(int i, int n, float extent, Vector3 &normal);
    40 	Vector3 SphereDistribute(int i, int n, float extent, Vector3 &normal);
    40 public:
    41 public:
    41 	Raytracer(): camera(NULL), lights(), bg_colour(0.0, 0.0, 0.0),
    42 	Raytracer(): top(NULL), camera(NULL), lights(), bg_colour(0.0, 0.0, 0.0),
    42 		ao_samples(0), num_threads(4) { top = new KdTree(); };
    43 		ao_samples(0), num_threads(4) {};
    43 	~Raytracer() { delete top; };
    44 	void render(int w, int h, float *buffer);
    44 	float *render(int w, int h);
       
    45 	Colour raytrace(Ray &ray, int depth, Shape *origin_shape);
    45 	Colour raytrace(Ray &ray, int depth, Shape *origin_shape);
    46 	void addshape(Shape *shape) { top->addShape(shape); };
    46 	void addshape(Shape *shape) { top->addShape(shape); };
    47 	void addlight(Light *light);
    47 	void addlight(Light *light);
    48 	void setCamera(Camera *cam) { camera = cam; };
    48 	void setCamera(Camera *cam) { camera = cam; };
       
    49 	void setTop(Container *atop) { top = atop; };
       
    50 	Container *getTop() { return top; };
    49 
    51 
    50 	void ambientocclusion(int samples, float distance, float angle);
    52 	void ambientocclusion(int samples, float distance, float angle);
    51 	void setThreads(int num) { num_threads = num; };
    53 	void setThreads(int num) { num_threads = num; };
    52 };
    54 };
    53 
    55