1 | #ifndef _HEIGHT_MAP_H_ |
---|
2 | #define _HEIGHT_MAP_H_ |
---|
3 | |
---|
4 | #include <Cg/cgGL.h> |
---|
5 | #include <Cg/cg.h> |
---|
6 | #include <R2/graphics/R2Geometry.h> |
---|
7 | #include "TransferFunction.h" |
---|
8 | #include "NvShader.h" |
---|
9 | #include "Vector3.h" |
---|
10 | #include <RenderContext.h> |
---|
11 | #include "AxisRange.h" |
---|
12 | |
---|
13 | namespace graphics { |
---|
14 | class RenderContext; |
---|
15 | } |
---|
16 | |
---|
17 | /** |
---|
18 | *@class HeightMap |
---|
19 | *@brief Create a surface from height map and line contour of the generated surface |
---|
20 | */ |
---|
21 | class HeightMap { |
---|
22 | unsigned int _vertexBufferObjectID; |
---|
23 | unsigned int _textureBufferObjectID; |
---|
24 | |
---|
25 | int _vertexCount; |
---|
26 | CGparameter _tf; |
---|
27 | R2Geometry* _contour; |
---|
28 | R2Geometry* _topContour; |
---|
29 | TransferFunction* _colorMap; |
---|
30 | NvShader* _shader; |
---|
31 | int* _indexBuffer; |
---|
32 | int _indexCount; |
---|
33 | Vector3 _contourColor; |
---|
34 | |
---|
35 | bool _contourVisible; |
---|
36 | bool _topContourVisible; |
---|
37 | bool _visible; |
---|
38 | |
---|
39 | Vector3 _scale; |
---|
40 | Vector3 _centerPoint; |
---|
41 | |
---|
42 | public : |
---|
43 | AxisRange xAxis, yAxis, zAxis, wAxis; |
---|
44 | static bool update_pending; |
---|
45 | static double valueMin, valueMax; |
---|
46 | |
---|
47 | /** |
---|
48 | *@brief Constructor |
---|
49 | */ |
---|
50 | HeightMap(); |
---|
51 | /** |
---|
52 | *@brief Destructor |
---|
53 | */ |
---|
54 | ~HeightMap(); |
---|
55 | |
---|
56 | private : |
---|
57 | void createIndexBuffer(int xCount, int zCount, int*& indexBuffer, int& indexCount, float* heights); |
---|
58 | Vector3* createHeightVertices(float startX, float startY, float endX, float endY, int xCount, int yCount, float* height); |
---|
59 | void reset(); |
---|
60 | public : |
---|
61 | void render(graphics::RenderContext* renderContext); |
---|
62 | /** |
---|
63 | *@brief Create a height map with heigh values |
---|
64 | *@param startX a x position of the first height value |
---|
65 | *@param startY a y position of the first height value |
---|
66 | *@param endX a x position of the last height value |
---|
67 | *@param endY a y position of the last height value |
---|
68 | *@param xCount the number of columns of height values |
---|
69 | *@param yCount the number of rows of height values |
---|
70 | *@param height a pointer value adrressing xCount * yCount values of heights |
---|
71 | */ |
---|
72 | void setHeight(float startX, float startY, float endX, float endY, int xCount, int yCount, float* height); |
---|
73 | |
---|
74 | /** |
---|
75 | *@brief Create a height map with a set of points |
---|
76 | *@param xCount the number of columns of height values |
---|
77 | *@param yCount the number of rows of height values |
---|
78 | */ |
---|
79 | void setHeight(int xCount, int yCount, Vector3* heights); |
---|
80 | |
---|
81 | /** |
---|
82 | *@brief Define a color map for color shading of heightmap |
---|
83 | */ |
---|
84 | void setColorMap(TransferFunction* colorMap); |
---|
85 | |
---|
86 | /** |
---|
87 | *@brief Get the color map defined for shading of this heightmap |
---|
88 | */ |
---|
89 | TransferFunction *getColorMap(void) { |
---|
90 | return _colorMap; |
---|
91 | } |
---|
92 | /** |
---|
93 | *@brief Set the visibility of the height map |
---|
94 | */ |
---|
95 | void setVisible(bool visible) { |
---|
96 | _visible = visible; |
---|
97 | } |
---|
98 | |
---|
99 | /** |
---|
100 | *@brief Return the status of the visibility |
---|
101 | */ |
---|
102 | bool isVisible() const { |
---|
103 | return _visible; |
---|
104 | } |
---|
105 | /** |
---|
106 | *@brief Set the visibility of the line contour |
---|
107 | */ |
---|
108 | void setLineContourVisible(bool visible) { |
---|
109 | _contourVisible = visible; |
---|
110 | } |
---|
111 | |
---|
112 | void setTopLineContourVisible(bool visible) { |
---|
113 | _topContourVisible = visible; |
---|
114 | } |
---|
115 | |
---|
116 | /** |
---|
117 | *@brief Defind the color of the line contour |
---|
118 | */ |
---|
119 | void setLineContourColor(float *rgb) { |
---|
120 | _contourColor.x = rgb[0]; |
---|
121 | _contourColor.y = rgb[1]; |
---|
122 | _contourColor.z = rgb[2]; |
---|
123 | } |
---|
124 | }; |
---|
125 | |
---|
126 | #endif |
---|