//---------------------------------------------------------------------------- // William Baxter III's Ray Tracer // // Project for Comp 238, Raster Graphics // University of North Carolina at Chapel Hill // // $Id:$ //---------------------------------------------------------------------------- #ifndef WB3AREALIGHT_H #define WB3AREALIGHT_H #include #include "ray3f.hpp" #include "wb3Light.hpp" //---------------------------------------------------------------------------- class wb3Scene; class wb3Artifact; class wb3AreaLight : public wb3Light { public: wb3AreaLight(); wb3AreaLight(const Vec3f& color); wb3AreaLight(const Vec3f& color, const Vec3f& origin, const Vec3f& U, const Vec3f& V, unsigned int Usamp, unsigned int Vsamp); ~wb3AreaLight() {}; const Vec3f& GetOrigin() const; void SetOrigin(const Vec3f& pos); void GetUV(Vec3f& U, Vec3f& V) const; void SetUV(const Vec3f& U, const Vec3f& V); void GetSampling(unsigned int *uSamp, unsigned int *vSamp) const; void SetSampling(unsigned int uSamp, unsigned int vSamp); void PerturbSample(Vec3f& pt) const; virtual void Contribute( const wb3Scene *scene, const wb3Artifact *hit, const Ray3f& r, const Vec3f &isect, const Vec3f &N, Vec3f& color) const; protected: Vec3f m_O; // Coords of O, origin Vec3f m_U; // Coords of U Vec3f m_V; // Coords of V Vec3f m_OU; // vec from O to U Vec3f m_OV; // vec from O to V unsigned int m_iUSamp; unsigned int m_iVSamp; }; //---------------------------------------------------------------------------- inline const Vec3f& wb3AreaLight::GetOrigin() const { return m_O; } //---------------------------------------------------------------------------- inline void wb3AreaLight::SetOrigin(const Vec3f& orig) { m_O = orig; m_OU = m_U - m_O; m_OV = m_V - m_O; } //---------------------------------------------------------------------------- inline void wb3AreaLight::GetUV(Vec3f& U, Vec3f& V) const { U = m_U; V = m_V; } //---------------------------------------------------------------------------- inline void wb3AreaLight::SetUV(const Vec3f& U, const Vec3f& V) { m_U = U; m_V = V; m_OU = m_U - m_O; m_OV = m_V - m_O; } //---------------------------------------------------------------------------- inline void wb3AreaLight::GetSampling( unsigned int *uSamp, unsigned int *vSamp) const { *uSamp = m_iUSamp; *vSamp = m_iVSamp; } //---------------------------------------------------------------------------- inline void wb3AreaLight::SetSampling( unsigned int uSamp, unsigned int vSamp) { m_iUSamp = uSamp; m_iVSamp = vSamp; } //---------------------------------------------------------------------------- #endif