00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _DISPMAP_H_
00011 #define _DISPMAP_H_
00012
00013 #include <string>
00014 #include <celmath/vecmath.h>
00015
00016
00017 typedef float (*DisplacementMapFunc)(float, float, void*);
00018
00019 class DisplacementMap
00020 {
00021 public:
00022 DisplacementMap(int w, int h);
00023 ~DisplacementMap();
00024 int getWidth() const { return width; };
00025 int getHeight() const { return height; };
00026 inline float getDisplacement(int x, int y) const;
00027 inline void setDisplacement(int x, int y, float d);
00028 void generate(DisplacementMapFunc func, void* info = NULL);
00029 void clear();
00030
00031 private:
00032 int width;
00033 int height;
00034 float* disp;
00035 };
00036
00037
00038
00039
00040 float DisplacementMap::getDisplacement(int x, int y) const
00041 {
00042 return disp[y * width + x];
00043 }
00044
00045 void DisplacementMap::setDisplacement(int x, int y, float d)
00046 {
00047 disp[y * width + x] = d;
00048 }
00049
00050 #endif // _DISPMAP_H_