//---------------------------------------------------------------------------- // William Baxter III's Ray Tracer // // Project for Comp 238, Raster Graphics // University of North Carolina at Chapel Hill // // $Id:$ //---------------------------------------------------------------------------- #ifndef WB3TEXTURE_H #define WB3TEXTURE_H // Colosseum Image Library Headers #include #include #include #include #include "wb3TextureImage.hpp" // Right now this texture class is hard coded to use an image, // and take only 2d coords. It would make sense for use to be // able to subclass one of these to make procedural textures. // if so then we would also want access to the 3d point, for doing // solid textures. class wb3Texture { public: wb3Texture(); ~wb3Texture(); void SetTextureImage(wb3TextureImage *pTex); wb3TextureImage* GetTextureImage(); void LoadFromFile(const char *filename); Vec3f& GetValue(Vec3f &ret, const Vec2f& UV); void SetBilerp(bool doBilerp); bool GetBilerp() const; protected: wb3TextureImage *m_pTex; bool m_bBilerp; // TODO: transform matricies and such go here... }; //---------------------------------------------------------------------------- inline void wb3Texture::SetTextureImage(wb3TextureImage *pTex) { m_pTex = pTex; } //---------------------------------------------------------------------------- inline wb3TextureImage* wb3Texture::GetTextureImage() { return m_pTex; } //---------------------------------------------------------------------------- inline void wb3Texture::LoadFromFile(const char *filename) { if (m_pTex == 0) m_pTex = new wb3TextureImage(); m_pTex->LoadFromFile(filename); } //---------------------------------------------------------------------------- inline Vec3f& wb3Texture::GetValue(Vec3f &ret, const Vec2f& UV) { if (m_pTex == 0) m_pTex = new wb3TextureImage(); return m_pTex->GetValue(ret, UV, m_bBilerp); } //---------------------------------------------------------------------------- inline void wb3Texture::SetBilerp(bool doBilerp) { m_bBilerp = doBilerp; } //---------------------------------------------------------------------------- inline bool wb3Texture::GetBilerp() const { return m_bBilerp; } //---------------------------------------------------------------------------- #endif