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

Last change on this file since 3497 was 3497, checked in by ldelgass, 6 years ago

Rename display() -> render() in nanovis

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