src/raytracer.h
branchpyrit
changeset 4 c73bc405ee7a
parent 0 3547b885df7e
child 5 2d97ea5e711a
equal deleted inserted replaced
3:8f9cb0526c47 4:c73bc405ee7a
    22 class ShapeList: public vector<Shape*>
    22 class ShapeList: public vector<Shape*>
    23 {
    23 {
    24 	AABB extends() { return AABB(); };
    24 	AABB extends() { return AABB(); };
    25 };
    25 };
    26 
    26 
       
    27 class Raytracer;
       
    28 struct RenderrowData {
       
    29 	Raytracer *rt;
       
    30 	int w;
       
    31 	float vx, vy, dx, dy;
       
    32 	Vector3 eye;
       
    33 	float *iter;
       
    34 };
       
    35 static void *renderrow(void *data);
       
    36 
    27 class Raytracer
    37 class Raytracer
    28 {
    38 {
    29 	ShapeList shapes;
    39 	ShapeList shapes;
    30 	vector<Light*> lights;
    40 	vector<Light*> lights;
    31 	Colour bg_colour;
    41 	Colour bg_colour;
    33 	float ao_distance, ao_angle;
    43 	float ao_distance, ao_angle;
    34 
    44 
    35 	Vector3 SphereDistribute(int i, int n, float extent, Vector3 &normal);
    45 	Vector3 SphereDistribute(int i, int n, float extent, Vector3 &normal);
    36 	inline Shape *nearest_intersection(const Shape *origin_shape, const Ray &ray,
    46 	inline Shape *nearest_intersection(const Shape *origin_shape, const Ray &ray,
    37 		float &nearest_distance);
    47 		float &nearest_distance);
    38 	Colour raytrace(Ray &ray, int depth, Shape *origin_shape);
       
    39 public:
    48 public:
    40 	Raytracer(): shapes(), lights(), bg_colour(0.0, 0.0, 0.0), ao_samples(0) {};
    49 	Raytracer(): shapes(), lights(), bg_colour(0.0, 0.0, 0.0), ao_samples(0) {};
    41 	~Raytracer() {};
    50 	~Raytracer() {};
    42 	float *render(int w, int h);
    51 	float *render(int w, int h);
       
    52 	Colour raytrace(Ray &ray, int depth, Shape *origin_shape);
    43 	void addshape(Shape *shape);
    53 	void addshape(Shape *shape);
    44 	void addlight(Light *light);
    54 	void addlight(Light *light);
    45 
    55 
    46 	void ambientocclusion(int samples, float distance, float angle);
    56 	void ambientocclusion(int samples, float distance, float angle);
    47 };
    57 };