2022-11-05 22:08:16 +01:00
|
|
|
#ifndef LIGHT_H
|
|
|
|
#define LIGHT_H
|
|
|
|
|
|
|
|
#include "common/color.h"
|
|
|
|
#include "common/ray.h"
|
|
|
|
|
|
|
|
// Forward declarations
|
|
|
|
class Scene;
|
|
|
|
|
|
|
|
class Light {
|
|
|
|
public:
|
|
|
|
// Illumination object
|
|
|
|
struct Illumination {
|
|
|
|
Color color;
|
|
|
|
Vector3d direction;
|
2023-01-24 22:03:33 +01:00
|
|
|
float distance;
|
2022-11-05 22:08:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Constructor / Destructor
|
|
|
|
Light(float intensity, Color const &color = Color(1, 1, 1)) : color(color), intensity(intensity) {}
|
|
|
|
virtual ~Light() = default;
|
|
|
|
|
|
|
|
// Set
|
|
|
|
void setColor(Color const &color) { this->color = color; }
|
|
|
|
void setIntensity(float intensity) { this->intensity = intensity; }
|
|
|
|
|
|
|
|
// Light functions
|
|
|
|
virtual Illumination illuminate(Scene const &scene, Ray const &ray) const = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Color color;
|
|
|
|
float intensity;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|