equal
deleted
inserted
replaced
27 #ifndef MATERIAL_H |
27 #ifndef MATERIAL_H |
28 #define MATERIAL_H |
28 #define MATERIAL_H |
29 |
29 |
30 #include "common.h" |
30 #include "common.h" |
31 #include "vector.h" |
31 #include "vector.h" |
|
32 #include "pixmap.h" |
32 |
33 |
33 /** |
34 /** |
34 * perlin noise |
35 * perlin noise |
35 */ |
36 */ |
36 Float perlin(Float x, Float y, Float z); |
37 Float perlin(Float x, Float y, Float z); |
223 public: |
224 public: |
224 Texture2D(TextureMap *amap): map(amap) {}; |
225 Texture2D(TextureMap *amap): map(amap) {}; |
225 }; |
226 }; |
226 |
227 |
227 /** |
228 /** |
228 * pixmap for image texture |
|
229 */ |
|
230 class Pixmap |
|
231 { |
|
232 Colour *data; |
|
233 int w,h; |
|
234 public: |
|
235 Pixmap(): data(NULL), w(0), h(0) {}; |
|
236 Pixmap(Float *adata, int aw, int ah): |
|
237 data((Colour*)(adata)), w(aw), h(ah) {}; |
|
238 void setData(Float *adata, int aw, int ah) |
|
239 { data = (Colour*)adata; w = aw; h = ah; }; |
|
240 Colour get(int x, int y) { return data[y*w + x]; }; |
|
241 int getWidth() { return w; }; |
|
242 int getHeight() { return h; }; |
|
243 }; |
|
244 |
|
245 /** |
|
246 * 2D image texture |
229 * 2D image texture |
247 */ |
230 */ |
248 class ImageTexture: public Texture2D |
231 class ImageTexture: public Texture2D |
249 { |
232 { |
250 Pixmap *pixmap; |
233 Pixmap *pixmap; |