1 #ifndef TEXTUREDEYELIGHTSHADER_HXX
 2 #define TEXTUREDEYELIGHTSHADER_HXX
 3 
 4 #include "EyeLightShader.hxx"
 5 #include "Texture.hxx"
 6 
 7 class TexturedEyeLightShader : public EyeLightShader
 8 {
 9 public:
10   Texture texture;
11   
12   TexturedEyeLightShader(Scene *scene, Vec3f color=Vec3f(0.5,0.5,0.5), char *fileName = NULL)
13     : EyeLightShader(scene, color), texture(fileName)
14   {};
15   
16   // just because of compiler warning
17   virtual ~TexturedEyeLightShader()
18   {};
19   
20   virtual Vec3f Shade(Ray &ray)
21   {
22 	float u = 0,
23 	      v = 0;
24 
25 	ray.hit->GetUV(ray, u, v);
26 	v = 1.0f - v;
27 
28 	return Product(material->color, texture.GetTexel(u,v)) * fabs(Dot(ray.dir,ray.hit->GetNormal(ray)));
29   };
30 };
31 
32 #endif


syntax highlighted by Code2HTML, v. 0.9.1