1 #ifndef TEXTUREDSMOOTHTRIANGLE_HXX
2 #define TEXTUREDSMOOTHTRIANGLE_HXX
3
4 #include "SmoothTriangle.hxx"
5
6 class TexturedSmoothTriangle : public SmoothTriangle
7 {
8 // Vec3f a, b, c; // vtx positions inherited from Triangle
9 // Vec3f na,nb,nc; // vtx normals inherited from SmoothTriangle
10 Vec3f ta, tb, tc; // vertex texture coordinates
11 public:
12 TexturedSmoothTriangle(Vec3f a, Vec3f b, Vec3f c,
13 Vec3f na, Vec3f nb, Vec3f nc,
14 Vec3f ta, Vec3f tb, Vec3f tc,
15 Shader *shader, PhotonDistributor *photon_distributor)
16 : SmoothTriangle(a,b,c,na,nb,nc,shader,photon_distributor),ta(ta),tb(tb),tc(tc)
17 {};
18
19 // virtual bool Intersect(Ray &ray); // inherited from Triangle
20 // virtual Box CalcBounds(); // inherited from Triangle
21 // virtual Vec3f GetNormal(Ray &ray) // inherited from Triangle
22
23 virtual void GetUV(Ray &ray, float &u, float &v)
24 {
25 Vec3f pixelcoord = ray.u * (tb - ta) + ray.v * (tc - ta) + ta;
26 u = pixelcoord.x;
27 v = pixelcoord.y;
28 };
29 };
30
31 #endif
syntax highlighted by Code2HTML, v. 0.9.1