src/raytracer.h
branchpyrit
changeset 19 4e0955fca797
parent 16 20bceb605f48
child 20 f22952603f29
equal deleted inserted replaced
18:25b7c445cf61 19:4e0955fca797
    17 
    17 
    18 class Raytracer;
    18 class Raytracer;
    19 struct RenderrowData {
    19 struct RenderrowData {
    20 	Raytracer *rt;
    20 	Raytracer *rt;
    21 	int w;
    21 	int w;
    22 	float vx, vy, dx, dy;
    22 	Vector3 eye, dfix, dx;
    23 	Vector3 eye;
    23 #if OVERSAMPLING
       
    24 	Vector3 dy;
       
    25 #endif
    24 	float *iter;
    26 	float *iter;
    25 };
    27 };
    26 //static void *renderrow(void *data);
       
    27 
    28 
    28 class Raytracer
    29 class Raytracer
    29 {
    30 {
    30 	Container *top;
    31 	Container *top;
       
    32 	Camera *camera;
    31 	vector<Light*> lights;
    33 	vector<Light*> lights;
    32 	Colour bg_colour;
    34 	Colour bg_colour;
    33 	int ao_samples;
    35 	int ao_samples;
    34 	float ao_distance, ao_angle;
    36 	float ao_distance, ao_angle;
    35 	int num_threads;
    37 	int num_threads;
    36 
    38 
    37 	Vector3 SphereDistribute(int i, int n, float extent, Vector3 &normal);
    39 	Vector3 SphereDistribute(int i, int n, float extent, Vector3 &normal);
    38 public:
    40 public:
    39 	Raytracer(): lights(), bg_colour(0.0, 0.0, 0.0), ao_samples(0), num_threads(4)
    41 	Raytracer(): camera(NULL), lights(), bg_colour(0.0, 0.0, 0.0),
    40 		{ top = new KdTree(); };
    42 		ao_samples(0), num_threads(4) { top = new KdTree(); };
    41 	~Raytracer() { delete top; };
    43 	~Raytracer() { delete top; };
    42 	float *render(int w, int h);
    44 	float *render(int w, int h);
    43 	Colour raytrace(Ray &ray, int depth, Shape *origin_shape);
    45 	Colour raytrace(Ray &ray, int depth, Shape *origin_shape);
    44 	void addshape(Shape *shape) { top->addShape(shape); };
    46 	void addshape(Shape *shape) { top->addShape(shape); };
    45 	void addlight(Light *light);
    47 	void addlight(Light *light);
       
    48 	void setCamera(Camera *cam) { camera = cam; };
    46 
    49 
    47 	void ambientocclusion(int samples, float distance, float angle);
    50 	void ambientocclusion(int samples, float distance, float angle);
    48 	void setThreads(int num) { num_threads = num; };
    51 	void setThreads(int num) { num_threads = num; };
    49 };
    52 };
    50 
    53