src/raytracer.h
author Radek Brich <radek.brich@devl.cz>
Sun, 25 Nov 2007 21:47:10 +0100
branchpyrit
changeset 16 20bceb605f48
parent 11 4d192e13ee84
child 19 4e0955fca797
permissions -rw-r--r--
add Raytracer::setThreads() resolved all memory leaks during rendering

/*
 * C++ RayTracer
 * file: raytracer.h
 *
 * Radek Brich, 2006
 */

#ifndef RAYTRACER_H
#define RAYTRACER_H

#include <vector>

#include "kdtree.h"
#include "scene.h"

using namespace std;

class Raytracer;
struct RenderrowData {
	Raytracer *rt;
	int w;
	float vx, vy, dx, dy;
	Vector3 eye;
	float *iter;
};
//static void *renderrow(void *data);

class Raytracer
{
	Container *top;
	vector<Light*> lights;
	Colour bg_colour;
	int ao_samples;
	float ao_distance, ao_angle;
	int num_threads;

	Vector3 SphereDistribute(int i, int n, float extent, Vector3 &normal);
public:
	Raytracer(): lights(), bg_colour(0.0, 0.0, 0.0), ao_samples(0), num_threads(4)
		{ top = new KdTree(); };
	~Raytracer() { delete top; };
	float *render(int w, int h);
	Colour raytrace(Ray &ray, int depth, Shape *origin_shape);
	void addshape(Shape *shape) { top->addShape(shape); };
	void addlight(Light *light);

	void ambientocclusion(int samples, float distance, float angle);
	void setThreads(int num) { num_threads = num; };
};

#endif