charles/src/scene.h

76 lines
1.5 KiB
C
Raw Normal View History

/* scene.h
*
2013-09-10 16:28:32 -07:00
* Definition of the Scene class.
*
* Scenes are the top level object in charles. Scenes contain objects, lights, a camera,
* etc. and can be rendered to pixel data and written to a file.
*
* Eryn Wells <eryn@erynwells.me>
*/
#ifndef __SCENE_H__
#define __SCENE_H__
2013-09-10 16:28:32 -07:00
#include <list>
2013-09-10 21:04:56 -07:00
#include <string>
#include "basics.h"
#include "camera.h"
2013-09-10 21:04:56 -07:00
2013-09-05 22:57:03 -07:00
class AmbientLight;
class PointLight;
2013-09-10 16:28:32 -07:00
class Shape;
2013-09-10 21:04:56 -07:00
class Writer;
2013-09-07 16:10:50 -07:00
2013-09-10 16:28:32 -07:00
class Scene
{
2013-09-10 16:28:32 -07:00
public:
Scene();
~Scene();
2013-09-10 16:28:32 -07:00
bool is_rendered() const;
2013-09-10 21:04:56 -07:00
int get_width() const;
void set_width(int w) { width = w; }
2013-09-10 21:04:56 -07:00
int get_height() const;
void set_height(int h) { height = h; }
2013-09-13 18:25:09 -07:00
AmbientLight &get_ambient() const;
2013-09-10 21:04:56 -07:00
const Color *get_pixels() const;
2013-09-07 16:10:50 -07:00
2013-09-10 21:04:56 -07:00
void read(const std::string &filename);
void write(Writer &writer, const std::string &filename);
2013-09-10 16:28:32 -07:00
void render();
void add_shape(Shape *obj);
void add_light(PointLight *light);
2013-09-10 16:28:32 -07:00
private:
Color trace_ray(const Ray &ray, const int depth = 0, const float weight = 1.0);
2013-09-11 10:33:16 -07:00
// Pixel dimensions of the image.
2013-09-10 21:04:56 -07:00
int width, height;
2013-09-11 10:33:16 -07:00
Camera *camera;
2013-09-21 17:01:11 -07:00
/*
* Ray tracing parameters. max_depth indicates the maximum depth of the ray tree. min_weight indicates the minimum
* specular weight to apply before giving up.
*/
2013-09-11 10:33:16 -07:00
int max_depth;
2013-09-21 17:01:11 -07:00
float min_weight;
2013-09-11 10:33:16 -07:00
// Scene objects.
2013-09-13 14:15:34 -07:00
AmbientLight *ambient;
2013-09-10 16:28:32 -07:00
std::list<Shape *> shapes;
std::list<PointLight *> lights;
2013-09-12 09:10:22 -07:00
// Rendering stats
unsigned int nrays;
2013-09-11 10:33:16 -07:00
// Rendering output.
2013-09-10 16:28:32 -07:00
bool _is_rendered;
Color *pixels;
};
#endif