//---------------------------------------------------------------------------- // William Baxter III's Ray Tracer // // Project for Comp 238, Raster Graphics // University of North Carolina at Chapel Hill // // $Id:$ //---------------------------------------------------------------------------- #ifndef WB3ARTIFACT_H #define WB3ARTIFACT_H #include "ray3f.hpp" #include "wb3Shader.hpp" #include "wb3Material.hpp" class wb3Artifact { public: wb3Artifact(); ~wb3Artifact(); virtual const wb3Artifact* Intersect(const Ray3f& r, float *idist, const wb3Artifact* ignore =0) const = 0; virtual void GetNormal(const Ray3f& r, const Vec3f &isect, Vec3f& normal) const = 0; virtual void Shade(const wb3Scene* scene, const wb3Artifact* from, const wb3Artifact* hit, const Ray3f& r, const Vec3f &isect, Vec3f& color, Vec3f& attenuation, int hits) const; virtual float GetIndex() const; // index of refraction wb3Shader* GetShader() const; void SetShader(wb3Shader *pShader); wb3Material* GetMaterial() const; void SetMaterial(wb3Material *pMaterial); protected: wb3Shader *m_pShader; wb3Material *m_pMaterial; static const float ms_fEps; }; //---------------------------------------------------------------------------- inline void wb3Artifact::Shade( const wb3Scene *scene, const wb3Artifact *from, const wb3Artifact *hit, const Ray3f& r, const Vec3f &isect, Vec3f& color, Vec3f& attenuation, int hits) const { if (m_pShader) m_pShader->Shade(scene, from, hit, r, isect, color, attenuation, hits); } //---------------------------------------------------------------------------- inline float wb3Artifact::GetIndex() const { if (m_pMaterial) return m_pMaterial->GetIndex(); else return 1.0; } //---------------------------------------------------------------------------- inline wb3Shader* wb3Artifact::GetShader() const { return m_pShader; } //---------------------------------------------------------------------------- inline void wb3Artifact::SetShader(wb3Shader *pShader) { m_pShader = pShader; } //---------------------------------------------------------------------------- inline wb3Material* wb3Artifact::GetMaterial() const { return m_pMaterial; } //---------------------------------------------------------------------------- inline void wb3Artifact::SetMaterial(wb3Material *pMaterial) { m_pMaterial = pMaterial; } #endif