1 #ifndef PROCEDURALGRANITE_HXX
2 #define PROCEDURALGRANITE_HXX
3
4 #include "Procedural.hxx"
5 #include "Noise.hxx"
6
7 // Granite simply thresholds a turbulence function. This looks quite okay...
8 class ProceduralGranite : public Procedural
9 {
10 private:
11 Noise *noise;
12
13 float factor;
14
15 Vec3f LightColor,
16 DarkColor;
17
18 public:
19 ProceduralGranite(bool useTexture, bool useBumpMap, float factor, Vec3f LightColor = Vec3f(0.6), Vec3f DarkColor = Vec3f(0.4))
20 : Procedural(useTexture, useBumpMap, true, false), factor(factor),
21 LightColor(LightColor), DarkColor(DarkColor)
22 {
23 noise = new Noise(Vec3f(64));
24 };
25
26 virtual ~ProceduralGranite()
27 {
28 delete noise;
29 };
30
31 // Thresholding, return the respective color
32 virtual Vec3f GetColor (Vec3f coordinate)
33 {
34 if (noise->Turbulence(coordinate*factor, 0.01f) > 1.0)
35 return LightColor;
36 else
37 return DarkColor;
38 };
39
40 // We are talking about polished granite...
41 virtual void BumpMap(Vec3f &normal, Vec3f coordinate)
42 {
43 };
44 };
45
46 #endif
syntax highlighted by Code2HTML, v. 0.9.1