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

Last change on this file since 2831 was 2831, checked in by ldelgass, 9 years ago

Refactor texture classes, misc. cleanups, cut down on header pollution -- still
need to fix header deps in Makefile.in

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