source: trunk/packages/vizservers/nanovis/HeightMap.h @ 1984

Last change on this file since 1984 was 1984, checked in by gah, 13 years ago

Clean up debugging/printing traces

File size: 3.6 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#include <RenderContext.h>
11#include "AxisRange.h"
12
13namespace graphics {
14    class RenderContext;
15}
16
17class Grid;
18
19/**
20 *@class HeightMap
21 *@brief Create a surface from height map and line contour of the generated surface
22 */
23
24class HeightMap {
25    unsigned int _vertexBufferObjectID;
26    unsigned int _textureBufferObjectID;
27    int _vertexCount;
28    CGparameter _tfParam;
29    CGparameter _opacityParam;
30    R2Geometry* _contour;
31    R2Geometry* _topContour;
32    TransferFunction* _tfPtr;
33    float _opacity;
34    NvShader* _shader;
35    int *_indexBuffer;
36    int _indexCount;
37    Vector3 _contourColor;
38   
39    bool _contourVisible;
40    bool _topContourVisible;
41    bool _visible;
42   
43    Vector3 _scale;
44    Vector3 _centerPoint;
45    int _xNum, _yNum;           // Number of elements x and y axes in grid.
46    float *_heights;            // Array of original (unscaled) heights
47                                // (y-values)
48public :
49    AxisRange xAxis, yAxis, zAxis, wAxis;
50    static bool update_pending;
51    static double valueMin, valueMax;
52
53    /**
54     *@brief Constructor
55     */
56    HeightMap();
57    /**
58     *@brief Destructor
59     */
60    ~HeightMap();
61
62private :
63    void createIndexBuffer(int xCount, int zCount, float* heights);
64        Vector3* createHeightVertices(float startX, float startY, float endX, float endY, int xCount, int yCount, float* height);
65        void reset();
66public :
67    void render(graphics::RenderContext* renderContext);
68    void render_topview(graphics::RenderContext* renderContext, int render_width, int render_height);
69    /**
70     *@brief Create a height map with heigh values
71     *@param startX a x position of the first height value
72     *@param startY a y position of the first height value
73     *@param endX a x position of the last height value
74     *@param endY a y position of the last height value
75     *@param xCount the number of columns of height values
76     *@param yCount the number of rows of height values
77     *@param height a pointer value adrressing xCount * yCount values of heights
78     */
79    void setHeight(float startX, float startY, float endX, float endY,
80                   int xCount, int yCount, float* height);
81
82    /**
83     *@brief Create a height map with a set of points
84     *@param xCount the number of columns of height values
85     *@param yCount the number of rows of height values
86     */
87    void setHeight(int xCount, int yCount, Vector3* heights);
88
89    void MapToGrid(Grid *gridPtr);
90    /**
91     *@brief Define a color map for color shading of heightmap
92     */
93    void transferFunction(TransferFunction* tfPtr) {
94        _tfPtr = tfPtr;
95    }
96    /**
97     *@brief Get the color map defined for shading of this heightmap
98     */
99    TransferFunction *transferFunction(void) {
100        return _tfPtr;
101    }
102    /**
103     *@brief Set the visibility of the height map
104     */
105    void setVisible(bool visible) {
106        _visible = visible;
107    }
108
109    /**
110     *@brief Return the status of the visibility
111     */
112    bool isVisible() const {
113        return _visible;
114    }
115    /**
116     *@brief Set the visibility of the line contour
117     */
118    void setLineContourVisible(bool visible) {
119        _contourVisible = visible;
120    }
121
122    void setTopLineContourVisible(bool visible) {
123            _topContourVisible = visible;
124    }
125
126    void opacity(float opacity) {
127        _opacity = opacity;
128    }
129    float opacity(void) {
130        return _opacity;
131    }
132    /**
133     *@brief Defind the color of the line contour
134     */
135    void setLineContourColor(float *rgb) {
136        _contourColor.x = rgb[0];
137        _contourColor.y = rgb[1];
138        _contourColor.z = rgb[2];
139    }
140};
141
142#endif
Note: See TracBrowser for help on using the repository browser.