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

Last change on this file since 3464 was 3463, checked in by ldelgass, 7 years ago

Begin process of renaming R2 library

  • Property svn:eol-style set to native
File size: 3.3 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
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 heigh 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, Vector3 *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    AxisRange xAxis, yAxis, zAxis, wAxis;
110    static bool updatePending;
111    static double valueMin, valueMax;
112
113private:
114    void createIndexBuffer(int xCount, int zCount, float *heights);
115    Vector3 *createHeightVertices(float startX, float startY,
116                                  float endX, float endY,
117                                  int xCount, int yCount, float *height);
118    void reset();
119
120    unsigned int _vertexBufferObjectID;
121    unsigned int _texcoordBufferObjectID;
122    int _vertexCount;
123    nv::graphics::Geometry *_contour;
124    TransferFunction *_tfPtr;
125    float _opacity;
126    NvShader *_shader;
127    int *_indexBuffer;
128    int _indexCount;
129    Vector3 _contourColor;
130
131    bool _contourVisible;
132    bool _visible;
133
134    Vector3 _scale;
135    Vector3 _centerPoint;
136    int _xNum, _yNum;           // Number of elements x and y axes in grid.
137    float *_heights;            // Array of original (unscaled) heights
138                                // (y-values)
139};
140
141#endif
Note: See TracBrowser for help on using the repository browser.