#ifndef light_h #define light_h #include <jgl/linearalgebra.h> #include <jgl/colour.h> #include "object.h" #include "collect_alloc.h" class ShadowFeeler; class rtl_light : public dyn_collectable { public: rtl_light(); virtual const jVec3& position() const { return p; } void position( const jVec3& _p ) { p = _p; } void position( const jMat4& T ) { p = p*T; } const jColour& colour( const jNorm3& ) const { return clr; } void colour( const jColour& _clr ) { clr = _clr; } virtual jNorm3 tolight( const jVec3& I, jFlt& t ) const { jVec3 d(p-I); t = d.length(); return jNorm3(d/t,false); } rtl_flags& flags() { return f; } const rtl_flags& flags() const { return f; } virtual bool areaLight() const { return false; } static rtl_light Default; static jULng InsideScene; protected: rtl_object* o; jVec3 p; jColour clr; rtl_flags f; friend class rtl_world; friend class rtl_shadowfeeler; }; class rtl_sphericallight : public rtl_light { public: /* Creates an area light with the given radius. */ rtl_sphericallight( jFlt ); virtual jNorm3 tolight( const jVec3&, jFlt& ) const; virtual bool areaLight() const { return true; } jFlt radius() const { return r; } protected: jFlt r; }; #endif