// *********************************************************
// Light Class
// Author : Tamy Boubekeur (boubek@gmail.com).
// Copyright (C) 2010 Tamy Boubekeur.
// All rights reserved.
// *********************************************************

#ifndef LIGHT_H
#define LIGHT_H

#include <iostream>
#include <vector>

#include "Vec3D.h"
#include "Color.h"
#include "BoundingBox.h"

class Light
{
public:
    Light () : color (1.0f, 1.0f, 1.0f), intensity (1.0f), extent(0), punctual(true) {}
    Light (const Vec3Df & pos, const Colorf& color, float intensity, float r = 0)
        : pos (pos), color (color), intensity (intensity), extent(r), punctual(r == 0) {}
    virtual ~Light () {}

    const Vec3Df & getPos () const { return pos; }
    const Colorf& getColor () const { return color; }
    float getIntensity () const { return intensity; }
    float getExtent() const { return extent; }
    bool isPunctual() const { return punctual; }

    void setPos (const Vec3Df & p) { pos = p; }
    void setColor (const Colorf& c) { color = c; }
    void setIntensity (float i) { intensity = i; }
    void setExtent(float r) { extent = r; }
    void setPunctual(bool p) { punctual = p; }

    float getIntensityAt(const Vec3Df& point) const
    {
        return intensity / (point - pos).getLength();
    }

    BoundingBox getBoundingBox() const
    {
        Vec3Df lmin = Vec3Df(pos[0] - extent / 2, pos[1] - extent / 2, pos[2] - extent / 2);
        Vec3Df lmax = Vec3Df(pos[0] + extent / 2, pos[1] + extent / 2, pos[2] + extent / 2);
        return BoundingBox(lmin, lmax);
    }


private:
    Vec3Df pos;
    Colorf color;
    float intensity;
    float extent;
    bool punctual;
};


#endif // LIGHT_H

// Some Emacs-Hints -- please don't remove:
//
//  Local Variables:
//  mode:C++
//  tab-width:4
//  End:
