src/raytracer.h
author Radek Brich <radek.brich@devl.cz>
Mon, 26 Nov 2007 23:12:40 +0100
branchpyrit
changeset 19 4e0955fca797
parent 16 20bceb605f48
child 20 f22952603f29
permissions -rw-r--r--
added Camera, currently w/o Python binding new #define option: OVERSAMPLING fixed all demos to work with new camera (they had inverted z axis)

/*
 * 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;
	Vector3 eye, dfix, dx;
#if OVERSAMPLING
	Vector3 dy;
#endif
	float *iter;
};

class Raytracer
{
	Container *top;
	Camera *camera;
	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(): camera(NULL), 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 setCamera(Camera *cam) { camera = cam; };

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

#endif