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

Last change on this file since 2958 was 2956, checked in by ldelgass, 12 years ago

First batch of converting shaders to use new parameter support in NvShader?.

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