42 */ |
42 */ |
43 class Texture |
43 class Texture |
44 { |
44 { |
45 public: |
45 public: |
46 virtual ~Texture() {}; |
46 virtual ~Texture() {}; |
|
47 |
|
48 /** evaluate texture colour in the point of space */ |
47 virtual Colour evaluate(const Vector &point) = 0; |
49 virtual Colour evaluate(const Vector &point) = 0; |
48 }; |
50 }; |
49 |
51 |
50 /** |
52 /** |
51 * general colour map |
53 * general colour map |
52 */ |
54 */ |
53 class ColourMap |
55 class ColourMap |
54 { |
56 { |
55 public: |
57 public: |
56 virtual ~ColourMap() {}; |
58 virtual ~ColourMap() {}; |
|
59 |
|
60 /** map float value to colour */ |
57 virtual Colour map(const Float &val) = 0; |
61 virtual Colour map(const Float &val) = 0; |
58 }; |
62 }; |
59 |
63 |
60 /** |
64 /** |
61 * linear colour map |
65 * linear colour map |
105 { |
109 { |
106 protected: |
110 protected: |
107 Vector center; |
111 Vector center; |
108 Float invsize; |
112 Float invsize; |
109 public: |
113 public: |
|
114 /** |
|
115 * texture map constructor |
|
116 * @param[in] acenter central point of texture mapping |
|
117 * @param[in] size Size of the texture. |
|
118 * One world space unit is mapped to one texture size |
|
119 * divided by this number. |
|
120 */ |
110 TextureMap(const Vector &acenter, const Float &size): |
121 TextureMap(const Vector &acenter, const Float &size): |
111 center(acenter), invsize(1.0f/size) {}; |
122 center(acenter), invsize(1.0f/size) {}; |
112 virtual ~TextureMap() {}; |
123 virtual ~TextureMap() {}; |
|
124 |
|
125 /** |
|
126 * map 3D space point to 2D u,v coordinates |
|
127 * @param[in] point a point in 3D space |
|
128 * @param[out] u horizontal texture coordinate |
|
129 * @param[out] v vertical texture coordinate |
|
130 */ |
113 virtual void map(const Vector &point, Float &u, Float &v) const = 0; |
131 virtual void map(const Vector &point, Float &u, Float &v) const = 0; |
114 }; |
132 }; |
115 |
133 |
116 /** |
134 /** |
117 * planar mapping |
135 * planar mapping |
307 reflectivity = 0.2f; |
325 reflectivity = 0.2f; |
308 transmissivity = 0.0f; |
326 transmissivity = 0.0f; |
309 refract_index = 1.3f; |
327 refract_index = 1.3f; |
310 } |
328 } |
311 |
329 |
|
330 /** set Phong parameters */ |
312 void setPhong(const Float amb, const Float dif, const Float spec, const Float shin) |
331 void setPhong(const Float amb, const Float dif, const Float spec, const Float shin) |
313 { ambient = amb; diffuse = dif; specular = spec; shininess = shin; }; |
332 { ambient = amb; diffuse = dif; specular = spec; shininess = shin; }; |
|
333 |
|
334 /** set fraction of light to be reflected */ |
314 void setReflectivity(const Float refl) { reflectivity = refl; }; |
335 void setReflectivity(const Float refl) { reflectivity = refl; }; |
|
336 |
|
337 /** set fraction of light to be refracted |
|
338 * @param[in] trans the transmissivity amount |
|
339 * @param[in] rinde index of refraction |
|
340 */ |
315 void setTransmissivity(const Float trans, const Float rindex) |
341 void setTransmissivity(const Float trans, const Float rindex) |
316 { transmissivity = trans; refract_index = rindex; }; |
342 { transmissivity = trans; refract_index = rindex; }; |
|
343 |
|
344 /** allow triangle smoothing */ |
317 void setSmooth(int sm) { smooth = sm; }; |
345 void setSmooth(int sm) { smooth = sm; }; |
|
346 |
|
347 /** set the texture */ |
318 void setTexture(Texture *tex) { texture = tex; }; |
348 void setTexture(Texture *tex) { texture = tex; }; |
319 }; |
349 }; |
320 |
350 |
321 #endif |
351 #endif |