67 lines
1.6 KiB
C++
67 lines
1.6 KiB
C++
|
|
#ifndef SCENE_H
|
|
#define SCENE_H SCENE_H
|
|
|
|
#include <string>
|
|
#include <map>
|
|
#include <vector>
|
|
#include <utility>
|
|
#include "util/Ray.h"
|
|
#include "shapes/Shape.h"
|
|
#include "Light.h"
|
|
|
|
#define SCENE_MAX_TRANSPARENT_HITS 8
|
|
#define SCENE_TRANSPARENCY_THRESHOLD 0.01
|
|
|
|
class Scene
|
|
{
|
|
public:
|
|
/* types */
|
|
class ShapeDistance : public std::pair<Shape *, double>
|
|
{
|
|
public:
|
|
ShapeDistance(Shape * shape, double dist)
|
|
: std::pair<Shape *, double>(shape, dist)
|
|
{
|
|
};
|
|
};
|
|
|
|
Scene(std::map<std::string, const char *> options,
|
|
const char * filename);
|
|
~Scene();
|
|
void render();
|
|
|
|
private:
|
|
/* private methods */
|
|
void load(const char * filename);
|
|
void renderPixel(int x, int y, unsigned char * pixel);
|
|
Vector traceRay(const Ray & ray);
|
|
std::vector<ShapeDistance> getRayHits(const Ray & ray);
|
|
|
|
/* rendering parameters */
|
|
int m_width;
|
|
int m_height;
|
|
int m_multisample_level;
|
|
std::string m_output_file_name;
|
|
bool m_verbose;
|
|
double m_vfov;
|
|
|
|
/* private data */
|
|
std::vector<Shape *> m_shapes;
|
|
std::vector<Light *> m_lights;
|
|
Transform m_transform;
|
|
double m_view_plane_dist;
|
|
int m_multisample_level_squared;
|
|
double m_sample_span;
|
|
double m_half_sample_span;
|
|
|
|
/* framebuffer */
|
|
unsigned char * m_data;
|
|
};
|
|
|
|
bool operator<(const Scene::ShapeDistance & sd1,
|
|
const Scene::ShapeDistance & sd2);
|
|
|
|
#endif
|
|
|