source: nanovis/branches/1.2/HeightMap.h @ 5491

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

Merge r3611:3618 from trunk

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