source: trunk/vizservers/nanovis/HeightMap.h @ 835

Last change on this file since 835 was 835, checked in by gah, 17 years ago

More clean up. Added dxReader.cpp

File size: 3.3 KB
Line 
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
11/**
12 *@class HeightMap
13 *@brief Create a surface from height map and line contour of the generated surface
14 */
15class HeightMap {
16    unsigned int _vertexBufferObjectID;
17    unsigned int _textureBufferObjectID;
18   
19    int _vertexCount;
20    CGparameter _tf;
21    R2Geometry* _contour;
22    TransferFunction* _colorMap;
23    NvShader* _shader;
24    int* _indexBuffer;
25    int _indexCount;
26    Vector3 _contourColor;
27   
28    bool _contourVisible;
29    bool _visible;
30   
31    Vector3 _scale;
32
33    double _vmin;               // minimum (unscaled) value in data
34    double _vmax;               // maximum (unscaled) value in data
35
36
37public :
38    /**
39     *@brief Constructor
40     */
41        HeightMap();
42    /**
43     *@brief Destructor
44     */
45        ~HeightMap();
46
47private :
48        void createIndexBuffer(int xCount, int zCount, int*& indexBuffer, int& indexCount, float* heights);
49        Vector3* createHeightVertices(float startX, float startY, float endX, float endY, int xCount, int yCount, float* height);
50        void reset();
51public :
52        void render();
53    /**
54     *@brief Create a height map with heigh values
55     *@param startX a x position of the first height value
56     *@param startY a y position of the first height value
57     *@param endX a x position of the last height value
58     *@param endY a y position of the last height value
59     *@param xCount the number of columns of height values
60     *@param yCount the number of rows of height values
61     *@param height a pointer value adrressing xCount * yCount values of heights
62     */
63        void setHeight(float startX, float startY, float endX, float endY, int xCount, int yCount, float* height);
64
65    /**
66     *@brief Create a height map with a set of points
67     *@param xCount the number of columns of height values
68     *@param yCount the number of rows of height values
69     */
70        void setHeight(int xCount, int yCount, Vector3* heights);
71
72    /**
73     *@brief Define a color map for color shading of heightmap
74     */
75        void setColorMap(TransferFunction* colorMap);
76
77    /**
78     *@brief Get the color map defined for shading of this heightmap
79     */
80    TransferFunction *getColorMap(void);
81
82    /**
83     *@brief Set the visibility of the height map
84     */
85        void setVisible(bool visible);
86
87    /**
88     *@brief Return the status of the visibility
89     */
90        bool isVisible() const;
91
92    /**
93     *@brief Set the visibility of the line contour
94     */
95        void setLineContourVisible(bool visible);
96
97    /**
98     *@brief Defind the color of the line contour
99     */
100    void setLineContourColor(float r, float g, float b);
101
102    double range_min(void);
103    double range_max(void);
104};
105
106inline void HeightMap::setVisible(bool visible)
107{
108        _visible = visible;
109}
110
111inline bool HeightMap::isVisible() const
112{
113        return _visible;
114}
115
116inline void HeightMap::setLineContourVisible(bool visible)
117{
118        _contourVisible = visible;
119}
120
121inline void HeightMap::setLineContourColor(float r, float g, float b)
122{
123    _contourColor.x = r;
124    _contourColor.y = g;
125    _contourColor.z = b;
126}
127
128inline TransferFunction *
129HeightMap::getColorMap()
130{
131    return _colorMap;
132}
133
134inline double
135HeightMap::range_min()
136{
137    return _vmin;
138}
139
140inline double
141HeightMap::range_max()
142{
143    return _vmax;
144}
145#endif
Note: See TracBrowser for help on using the repository browser.