112 pos(position), colour(acolour), cast_shadows(true) {}; |
96 pos(position), colour(acolour), cast_shadows(true) {}; |
113 void castShadows(bool cast) { cast_shadows = cast; }; |
97 void castShadows(bool cast) { cast_shadows = cast; }; |
114 }; |
98 }; |
115 |
99 |
116 /** |
100 /** |
117 * texture |
101 * axis-aligned bounding box |
118 */ |
102 */ |
119 class Texture |
103 class BBox |
120 { |
104 { |
121 public: |
105 public: |
122 virtual ~Texture() {}; |
106 Vector3 L; |
123 virtual Colour evaluate(Vector3 point) = 0; |
107 Vector3 H; |
124 }; |
108 BBox(): L(), H() {}; |
125 |
109 BBox(const Vector3 aL, const Vector3 aH): L(aL), H(aH) {}; |
126 /** |
110 Float w() { return H.x-L.x; }; |
127 * material |
111 Float h() { return H.y-L.y; }; |
128 */ |
112 Float d() { return H.z-L.z; }; |
129 class Material |
113 bool intersect(const Ray &ray, Float &a, Float &b); |
130 { |
|
131 public: |
|
132 Colour colour; |
|
133 Texture *texture; |
|
134 Float ambient, diffuse, specular, shininess; // Phong constants |
|
135 Float reflectivity; // how much reflective is the surface |
|
136 Float transmissivity, refract_index; // part of light which can be refracted; index of refraction |
|
137 bool smooth; // triangle smoothing |
|
138 |
|
139 Material(const Colour &acolour): colour(acolour), texture(NULL), smooth(false) |
|
140 { |
|
141 ambient = 0.2; |
|
142 diffuse = 0.8; |
|
143 specular = 0.2; |
|
144 shininess = 0.5; |
|
145 reflectivity = 0.2; |
|
146 transmissivity = 0.0; |
|
147 refract_index = 1.3; |
|
148 } |
|
149 |
|
150 void setPhong(const Float amb, const Float dif, const Float spec, const Float shin) |
|
151 { ambient = amb; diffuse = dif; specular = spec; shininess = shin; }; |
|
152 void setReflectivity(const Float refl) { reflectivity = refl; }; |
|
153 void setTransmissivity(const Float trans, const Float rindex) |
|
154 { transmissivity = trans; refract_index = rindex; }; |
|
155 void setSmooth(bool sm) { smooth = sm; }; |
|
156 }; |
114 }; |
157 |
115 |
158 #endif |
116 #endif |