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

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

remove global.h header. Move global Cg context handle into NvShader? as a
static member. Move LoadCgSourceProgram? to NvShader?.cpp, but make shader
classes use the methods NvShader::loadVertex/FragmentProgram instead.
There are still some users of LoadCgSourceProgram? left that need the context
handle.

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