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 ***************************************************************************/
22 * @brief Manages data for a globe.
26 #include "tcSrtmCache.h"
27 #include "tcElevationData.h"
34 * Constructors + destructor
37 /// Primary constructor.
38 tcGlobe::tcGlobe(double meanRadius
)
39 : m_meanRadius(meanRadius
)
40 , m_srtmCache(new tcSrtmCache())
43 addDataSet(new tcElevationData(m_srtmCache
->loadData(6, 45)));
44 addDataSet(new tcElevationData(m_srtmCache
->loadData(7, 45)));
45 addDataSet(new tcElevationData(m_srtmCache
->loadData(6, 46)));
46 addDataSet(new tcElevationData(m_srtmCache
->loadData(7, 46)));
58 /// Add a dataset to the globe.
59 void tcGlobe::addDataSet(tcGeoData
* data
)
61 m_data
.push_back(data
);
68 /// Render from the POV of an observer.
69 void tcGlobe::render(tcObserver
* observer
)
71 glColor3f(0.0f
, 1.0f
, 0.0f
);
74 for (int lat
= 5; lat
< 180; lat
+= 5)
76 double z
= cos(M_PI
/180*lat
) * m_meanRadius
;
77 double xy
= sin(M_PI
/180*lat
) * m_meanRadius
;
78 glBegin(GL_LINE_LOOP
);
80 for (int lon
= 0; lon
< 360; ++lon
)
82 glVertex3d(xy
*sin(M_PI
/180*lon
), xy
*cos(M_PI
/180*lon
), z
);
89 for (int lon
= 0; lon
< 360; lon
+= 5)
91 double x
= sin(M_PI
/180*lon
) * m_meanRadius
;
92 double y
= cos(M_PI
/180*lon
) * m_meanRadius
;
93 glBegin(GL_LINE_STRIP
);
95 for (int lat
= 10; lat
<= 170; ++lat
)
97 double z
= cos(M_PI
/180*lat
) * m_meanRadius
;
98 double xy
= sin(M_PI
/180*lat
);
99 glVertex3d(xy
*x
, xy
*y
, z
);
105 foreach(tcGeoData
* data
, m_data
)
107 data
->renderSchematic(m_meanRadius
);