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

Last change on this file since 829 was 820, checked in by vrinside, 16 years ago

NaN values in a data set is taken into account.

File size: 2.8 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
33public :
34    /**
35     *@brief Constructor
36     */
37        HeightMap();
38    /**
39     *@brief Destructor
40     */
41        ~HeightMap();
42
43private :
44        void createIndexBuffer(int xCount, int zCount, int*& indexBuffer, int& indexCount, float* heights);
45        Vector3* createHeightVertices(float startX, float startY, float endX, float endY, int xCount, int yCount, float* height);
46        void reset();
47public :
48        void render();
49    /**
50     *@brief Create a height map with heigh values
51     *@param startX a x position of the first height value
52     *@param startY a y position of the first height value
53     *@param endX a x position of the last height value
54     *@param endY a y position of the last height value
55     *@param xCount the number of columns of height values
56     *@param yCount the number of rows of height values
57     *@param height a pointer value adrressing xCount * yCount values of heights
58     */
59        void setHeight(float startX, float startY, float endX, float endY, int xCount, int yCount, float* height);
60
61    /**
62     *@brief Create a height map with a set of points
63     *@param xCount the number of columns of height values
64     *@param yCount the number of rows of height values
65     */
66        void setHeight(int xCount, int yCount, Vector3* heights);
67
68    /**
69     *@brief Define a color map for color shading of heighmap
70     */
71        void setColorMap(TransferFunction* colorMap);
72
73    /**
74     *@brief Set the visibility of the height map
75     */
76        void setVisible(bool visible);
77
78    /**
79     *@brief Return the status of the visibility
80     */
81        bool isVisible() const;
82
83    /**
84     *@brief Set the visibility of the line contour
85     */
86        void setLineContourVisible(bool visible);
87
88    /**
89     *@brief Defind the color of the line contour
90     */
91    void setLineContourColor(float r, float g, float b);
92};
93
94inline void HeightMap::setVisible(bool visible)
95{
96        _visible = visible;
97}
98
99inline bool HeightMap::isVisible() const
100{
101        return _visible;
102}
103
104inline void HeightMap::setLineContourVisible(bool visible)
105{
106        _contourVisible = visible;
107}
108
109inline void HeightMap::setLineContourColor(float r, float g, float b)
110{
111    _contourColor.x = r;
112    _contourColor.y = g;
113    _contourColor.z = b;
114}
115#endif
Note: See TracBrowser for help on using the repository browser.