1 /***************************************************************************
2 * This file is part of Tecorrec. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
5 * Tecorrec is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
10 * Tecorrec is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with Tecorrec. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
25 * @brief Manages data for a globe.
28 #include "tcSrtmModel.h"
36 /** Manages data for a globe.
37 * Holds terrain elevation and imagery data.
58 ElevationSampleAlignment
62 * Constructors + destructor
65 /// Primary constructor.
66 tcGlobe(double meanRadius
);
75 /// Add some imagery data.
76 void addImagery(tcGeoImageData
* data
);
78 /// Get the imagery data.
79 const QList
<tcGeoImageData
*>& imagery() const;
81 /// Get the elevation model.
82 tcSrtmModel
* dem() const;
88 /// Render from the POV of an observer.
89 void render(tcObserver
* const observer
= 0, bool adaptive
= true, const tcGeo
* extent
= 0);
91 /// Set the elevation mode to render in.
92 void setElevationMode(int dem
, ElevationMode mode
);
94 /// Set the level of interpolation.
95 void setElevationInterpolation(float interpolation
);
97 /// Set the elevation data set name.
98 void setElevationDataSet(int dem
, const QString
& name
);
100 /// Set colour coding method.
101 void setColourCoding(ColourCoding colourCoding
);
103 /// Adjust the mapping between bands and colour channels.
104 void setColourMapping(int outputChannel
, int inputBand
, int inputGroup
);
110 /// Get the mean radius.
111 double meanRadius() const;
113 /// Get the altitude above sea level at a sample in a render state.
114 double altitudeAt(const tcSrtmModel::RenderState
& state
, int x
, int y
, tcGeo
* outCoord
, bool* isAccurate
= 0) const;
116 /// Get the altitude above sea level at a coordinate.
117 double altitudeAt(const tcGeo
& coord
, bool* isAccurate
= 0) const;
119 /// Get the radius at a coordinate.
120 double radiusAt(const tcGeo
& coord
) const;
122 /// Get the texture coordinate of the effective texture at a geographical coordinate.
123 maths::Vector
<2,double> textureCoordOfGeo(const tcGeo
& coord
) const;
125 /// Get the current normal at a coordinate.
126 maths::Vector
<3,float> normalAt(int norm
, const tcGeo
& coord
) const;
134 /// Draw a line of latitude.
135 void drawLineOfLatitude(double latitude
) const;
138 void renderCell(tcObserver
* const observer
, const tcGeo
& swCorner
, const tcGeo
& neCorner
, int samples
, bool normals
= false,
139 bool northEdge
= false, bool eastEdge
= false, bool southEdge
= false, bool westEdge
= false) const;
147 /// Mean radius in metres.
151 tcSrtmModel
* m_elevation
;
154 QList
<tcGeoImageData
*> m_imagery
;
160 /// Current elevation mode.
161 ElevationMode m_elevationMode
[2];
163 /// Current level of elevation interpolation.
164 float m_elevationInterpolation
;
166 /// Colour coding method.
167 ColourCoding m_colourCoding
;
169 /// Mapping of bands to colour channels.
170 int m_colourMapping
[6][2];