00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00031 #include "../Include/Globals.h"
00032 #include "../Include/Terrain.h"
00033 #include "../Include/Utility.h"
00034 #include "../Include/Ui.h"
00035
00036
00037
00038
00039
00040 CTerrainTile::CTerrainTile (void)
00041 {
00042 memset (&sw, 0, sizeof(SPosition));
00043 memset (&nw, 0, sizeof(SPosition));
00044 memset (&ne, 0, sizeof(SPosition));
00045 memset (&se, 0, sizeof(SPosition));
00046 memset (&c, 0, sizeof(SPosition));
00047 strcpy (swBound, "");
00048 strcpy (nwBound, "");
00049 strcpy (neBound, "");
00050 strcpy (seBound, "");
00051 texid = 0;
00052 created = false;
00053 }
00054
00055 CTerrainTile::~CTerrainTile (void)
00056 {
00057 if (texid != 0) {
00058 glDeleteTextures (1, &texid);
00059 }
00060 }
00061
00062
00063
00064
00065
00066
00067
00068
00069 void CTerrainTile::CalculateCenter (void)
00070 {
00071
00072 c.lat = sw.lat + (ne.lat - sw.lat) / 2;
00073 c.lon = sw.lon + (ne.lon - sw.lon) / 2;
00074 c.alt = 0;
00075 }
00076
00077
00078
00079
00080 void CTerrainTile::SetBounds (SPosition sw, SPosition nw, SPosition ne, SPosition se)
00081 {
00082 this->sw = sw;
00083 this->nw = nw;
00084 this->ne = ne;
00085 this->se = se;
00086
00087 CalculateCenter ();
00088 FormatBounds ();
00089 }
00090
00091
00092
00093
00094 void CTerrainTile::SetCorners (double sw_lat, double sw_lon,
00095 double ne_lat, double ne_lon)
00096 {
00097 sw.lon = sw_lon;
00098 sw.lat = sw_lat;
00099
00100 ne.lon = ne_lon;
00101 ne.lat = ne_lat;
00102
00103 nw.lon = sw.lon;
00104 nw.lat = ne.lat;
00105
00106 se.lon = ne.lon;
00107 se.lat = sw.lat;
00108
00109 CalculateCenter ();
00110 FormatBounds ();
00111 }
00112
00113
00114
00115
00116
00117
00118
00119 void CTerrainTile::FormatBounds (void)
00120 {
00121 FormatPosition (sw, swBound);
00122 FormatPosition (nw, nwBound);
00123 FormatPosition (ne, neBound);
00124 FormatPosition (se, seBound);
00125 }
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 void CTerrainTile::Create (void)
00182 {
00183 created = true;
00184 }
00185
00186 void CTerrainTile::Destroy (void)
00187 {
00188 created = false;
00189 }
00190
00191 bool CTerrainTile::IsCreated (void)
00192 {
00193 return created;
00194 }
00195
00196
00197
00198
00199 void CTerrainTile::print (FILE *fd, char *indent, int how_much)
00200 {
00201 ssgTransform::print (fd, indent, how_much);
00202
00203
00204 FormatBounds();
00205 fprintf (fd, "%s CTerrainTile:\n", indent);
00206 fprintf (fd, "%s SW Extent = %s\n", indent, swBound);
00207 fprintf (fd, "%s NW Extent = %s\n", indent, nwBound);
00208 fprintf (fd, "%s NE Extent = %s\n", indent, neBound);
00209 fprintf (fd, "%s SE Extent = %s\n", indent, seBound);
00210 }
00211