charles/src/scene.h

65 lines
1.1 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"
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;
int get_height() const;
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);
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
// Ray tracing parameters.
int max_depth;
// Scene objects.
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