source: nanovis/tags/1.1.1/HeightMap.h @ 4890

Last change on this file since 4890 was 4612, checked in by ldelgass, 10 years ago

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