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

Last change on this file since 1522 was 1493, checked in by gah, 15 years ago

Changed vector id to name

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