X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fmisc%2Ftexcoord.cxx;h=2705980d1c96db73cc04ed30c65878f49aface37;hb=2e71b64de1d937e2b7c34dd4a2365be455d0b82a;hp=e9a5ff8043747ef2d702917e95eb4edfdf451df3;hpb=a09806bb984b32607614df92dd430494d7af05de;p=simgear.git diff --git a/simgear/misc/texcoord.cxx b/simgear/misc/texcoord.cxx index e9a5ff80..2705980d 100644 --- a/simgear/misc/texcoord.cxx +++ b/simgear/misc/texcoord.cxx @@ -2,7 +2,7 @@ // // Written by Curtis Olson, started March 1999. // -// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org +// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public @@ -14,10 +14,9 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the -// Free Software Foundation, Inc., 59 Temple Place - Suite 330, -// Boston, MA 02111-1307, USA. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id$ @@ -140,8 +139,19 @@ enter this in the official comments in case I forget again. :-) */ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +// #include + #include "texcoord.hxx" +// using std::cout; +// using std::endl; + #define FG_STANDARD_TEXTURE_DIMENSION 1000.0 // meters #define MAX_TEX_COORD 8.0 @@ -149,9 +159,10 @@ enter this in the official comments in case I forget again. :-) // return the basic unshifted/unmoded texture coordinate for a lat/lon -inline Point3D basic_tex_coord( const Point3D& p, - double degree_width, double degree_height, - double scale ) +static inline Point3D basic_tex_coord( const Point3D& p, + double degree_width, + double degree_height, + double scale ) { return Point3D( p.x() * ( degree_width * scale / FG_STANDARD_TEXTURE_DIMENSION ), @@ -163,7 +174,13 @@ inline Point3D basic_tex_coord( const Point3D& p, // traverse the specified fan/strip/list of vertices and attempt to // calculate "none stretching" texture coordinates -point_list calc_tex_coords( const SGBucket& b, const point_list& geod_nodes, +point_list sgCalcTexCoords( const SGBucket& b, const point_list& geod_nodes, + const int_list& fan, double scale ) +{ + return sgCalcTexCoords(b.get_center_lat(), geod_nodes, fan, scale); +} + +point_list sgCalcTexCoords( double centerLat, const point_list& geod_nodes, const int_list& fan, double scale ) { // cout << "calculating texture coordinates for a specific fan of size = " @@ -171,17 +188,17 @@ point_list calc_tex_coords( const SGBucket& b, const point_list& geod_nodes, // calculate perimeter based on center of this degree (not center // of bucket) - double clat = (int)b.get_center_lat(); + double clat = (int)centerLat; if ( clat > 0 ) { clat = (int)clat + 0.5; } else { clat = (int)clat - 0.5; } - double clat_rad = clat * DEG_TO_RAD; + double clat_rad = clat * SGD_DEGREES_TO_RADIANS; double cos_lat = cos( clat_rad ); - double local_radius = cos_lat * EQUATORIAL_RADIUS_M; - double local_perimeter = 2.0 * local_radius * FG_PI; + double local_radius = cos_lat * SG_EQUATORIAL_RADIUS_M; + double local_perimeter = local_radius * SGD_2PI; double degree_width = local_perimeter / 360.0; // cout << "clat = " << clat << endl; @@ -191,7 +208,7 @@ point_list calc_tex_coords( const SGBucket& b, const point_list& geod_nodes, // cout << "local_perimeter = " << local_perimeter << endl; // cout << "degree_width = " << degree_width << endl; - double perimeter = 2.0 * EQUATORIAL_RADIUS_M * FG_PI; + double perimeter = SG_EQUATORIAL_RADIUS_M * SGD_2PI; double degree_height = perimeter / 360.0; // cout << "degree_height = " << degree_height << endl; @@ -323,10 +340,10 @@ point_list calc_tex_coords( const SGBucket& b, const point_list& geod_nodes, // cout << "adjusted_t " << adjusted_t << endl; } #endif - if ( adjusted_t.x() < FG_EPSILON ) { + if ( adjusted_t.x() < SG_EPSILON ) { adjusted_t.setx( 0.0 ); } - if ( adjusted_t.y() < FG_EPSILON ) { + if ( adjusted_t.y() < SG_EPSILON ) { adjusted_t.sety( 0.0 ); } adjusted_t.setz( 0.0 );