00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #if !defined(AFX_HEIGHTMAP_H__F4CB4CAD_C592_4183_AFB2_016FC66C144A__INCLUDED_)
00022 #define AFX_HEIGHTMAP_H__F4CB4CAD_C592_4183_AFB2_016FC66C144A__INCLUDED_
00023
00024 #include <stdlib.h>
00025 #include <common/ProgressCounter.h>
00026 #include <common/FixedVector.h>
00027 #include <common/Vector.h>
00028
00029 class Line;
00030 class GraphicalHeightMap;
00031 class HeightMap
00032 {
00033 public:
00034 HeightMap();
00035 virtual ~HeightMap();
00036
00037 void create(int width, int height);
00038 void reset();
00039
00040
00041 int getMapWidth() { return width_; }
00042 int getMapHeight() { return height_; }
00043
00044
00045 inline fixed getHeight(int w, int h) {
00046 if (w >= 0 && h >= 0 && w<=width_ && h<=height_)
00047 return heightData_[(width_+1) * h + w].position[2];
00048 return fixed(0); }
00049 fixed getInterpHeight(fixed w, fixed h);
00050
00051
00052 FixedVector &getNormal(int w, int h);
00053 void getInterpNormal(fixed w, fixed h, FixedVector &normal);
00054
00055 bool getIntersect(Line &direction, Vector &intersect);
00056
00057
00058 void setHeight(int w, int h, fixed height);
00059
00060 GraphicalHeightMap *getGraphicalMap() { return graphicalMap_; }
00061 void setGraphicalMap(GraphicalHeightMap *map) { graphicalMap_ = map; }
00062
00063 protected:
00064 struct HeightData
00065 {
00066 FixedVector position;
00067 FixedVector normal;
00068 };
00069
00070 int width_, height_;
00071 HeightData *heightData_;
00072 GraphicalHeightMap *graphicalMap_;
00073
00074 bool getVector(FixedVector &vec, int x, int y);
00075 void getVectorPos(int pos, int &x, int &y, int dist=1);
00076 };
00077
00078 #endif // !defined(AFX_HEIGHTMAP_H__F4CB4CAD_C592_4183_AFB2_016FC66C144A__INCLUDED_)
00079