Use SGGeod as reference point in TGTexParams
This commit is contained in:
parent
d629fa8215
commit
8698ab4e69
16 changed files with 40 additions and 107 deletions
|
@ -175,7 +175,7 @@ static TGPolygon rwy_section_tex_coords( const TGPolygon& in_poly, const TGTexPa
|
|||
TGPolygon result;
|
||||
result.erase();
|
||||
|
||||
Point3D ref = tp.get_ref();
|
||||
SGGeod ref = tp.get_ref();
|
||||
double width = tp.get_width();
|
||||
double length = tp.get_length();
|
||||
double heading = tp.get_heading();
|
||||
|
@ -204,7 +204,7 @@ static TGPolygon rwy_section_tex_coords( const TGPolygon& in_poly, const TGTexPa
|
|||
// and ending az1, az2 and distance (s). Lat, lon, and
|
||||
// azimuth are in degrees. distance in meters
|
||||
double az1, az2, dist;
|
||||
geo_inverse_wgs_84( 0, ref.y(), ref.x(), p.y(), p.x(),
|
||||
geo_inverse_wgs_84( 0, ref.getLatitudeDeg(), ref.getLongitudeDeg(), p.y(), p.x(),
|
||||
&az1, &az2, &dist );
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "basic course = " << az2);
|
||||
|
||||
|
@ -267,7 +267,7 @@ static TGPolygon shoulder_tex_coords( const TGPolygon& in_poly, const TGTexParam
|
|||
TGPolygon result;
|
||||
result.erase();
|
||||
|
||||
Point3D ref = tp.get_ref();
|
||||
SGGeod ref = tp.get_ref();
|
||||
double width = tp.get_width();
|
||||
double length = tp.get_length();
|
||||
double heading = tp.get_heading();
|
||||
|
@ -302,7 +302,7 @@ static TGPolygon shoulder_tex_coords( const TGPolygon& in_poly, const TGTexParam
|
|||
// and ending az1, az2 and distance (s). Lat, lon, and
|
||||
// azimuth are in degrees. distance in meters
|
||||
double az1, az2, dist;
|
||||
geo_inverse_wgs_84( 0, ref.y(), ref.x(), p.y(), p.x(),
|
||||
geo_inverse_wgs_84( 0, ref.getLatitudeDeg(), ref.getLongitudeDeg(), p.y(), p.x(),
|
||||
&az1, &az2, &dist );
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "basic course from ref = " << az2);
|
||||
|
||||
|
@ -358,7 +358,7 @@ static TGPolygon linear_feature_tex_coords( const TGPolygon& in_poly, const TGTe
|
|||
TGPolygon result;
|
||||
result.erase();
|
||||
|
||||
Point3D ref = tp.get_ref();
|
||||
SGGeod ref = tp.get_ref();
|
||||
double width = tp.get_width();
|
||||
double length = tp.get_length();
|
||||
double heading = tp.get_heading();
|
||||
|
@ -393,7 +393,7 @@ static TGPolygon linear_feature_tex_coords( const TGPolygon& in_poly, const TGTe
|
|||
// and ending az1, az2 and distance (s). Lat, lon, and
|
||||
// azimuth are in degrees. distance in meters
|
||||
double az1, az2, dist;
|
||||
geo_inverse_wgs_84( 0, ref.y(), ref.x(), p.y(), p.x(),
|
||||
geo_inverse_wgs_84( 0, ref.getLatitudeDeg(), ref.getLongitudeDeg(), p.y(), p.x(),
|
||||
&az1, &az2, &dist );
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "basic course from ref = " << az2);
|
||||
|
||||
|
|
|
@ -492,7 +492,7 @@ int ClosedPoly::BuildBtg( superpoly_list* rwy_polys, texparams_list* texparams,
|
|||
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "tp construct");
|
||||
|
||||
tp = TGTexParams( pre_tess.get_pt(0,0), 5.0, 5.0, texture_heading );
|
||||
tp = TGTexParams( pre_tess.get_pt(0,0).toSGGeod(), 5.0, 5.0, texture_heading );
|
||||
texparams->push_back( tp );
|
||||
|
||||
if ( apt_base )
|
||||
|
|
|
@ -146,7 +146,7 @@ void Helipad::BuildBtg( superpoly_list *rwy_polys,
|
|||
WriteGeom( helipad, material + "heli", rwy_polys, accum, slivers);
|
||||
|
||||
TGTexParams tp;
|
||||
tp = TGTexParams( helipad.get_pt(0,0), maxsize, maxsize, heli.heading );
|
||||
tp = TGTexParams( helipad.get_pt(0,0).toSGGeod(), maxsize, maxsize, heli.heading );
|
||||
tp.set_minu( 1 );
|
||||
tp.set_maxu( 0 );
|
||||
tp.set_minv( 1 );
|
||||
|
@ -187,7 +187,7 @@ void Helipad::BuildBtg( superpoly_list *rwy_polys,
|
|||
area_geom.add_contour(area_poly.get_contour(i), false);
|
||||
WriteGeom( area_geom, material + "tiedown", rwy_polys, accum, slivers);
|
||||
|
||||
tp = TGTexParams( area_poly.get_pt(i,0), maxsize, areahight, heading );
|
||||
tp = TGTexParams( area_poly.get_pt(i,0).toSGGeod(), maxsize, areahight, heading );
|
||||
tp.set_minu( 1 );
|
||||
tp.set_maxu( 0 );
|
||||
tp.set_minv( 1 );
|
||||
|
@ -239,7 +239,7 @@ void Helipad::BuildBtg( superpoly_list *rwy_polys,
|
|||
sp.set_flag( "heli-shoulder" );
|
||||
shoulder_polys.push_back( sp );
|
||||
|
||||
tp = TGTexParams( area_poly.get_pt(0,1), areahight, shoulder_width, heading );
|
||||
tp = TGTexParams( area_poly.get_pt(0,1).toSGGeod(), areahight, shoulder_width, heading );
|
||||
tp.set_minu( 1 );
|
||||
tp.set_maxu( 0 );
|
||||
tp.set_minv( 1 );
|
||||
|
|
|
@ -741,7 +741,7 @@ int LinearFeature::Finish( bool closed, unsigned int idx )
|
|||
sp.set_flag("lf");
|
||||
marking_polys.push_back(sp);
|
||||
|
||||
tp = TGTexParams( prev_inner, width, 1.0f, heading );
|
||||
tp = TGTexParams( prev_inner.toSGGeod(), width, 1.0f, heading );
|
||||
tp.set_minv(last_end_v);
|
||||
marking_tps.push_back(tp);
|
||||
|
||||
|
|
|
@ -132,11 +132,11 @@ void Runway::gen_shoulder_section( Point3D p0, Point3D p1, Point3D t0, Point3D t
|
|||
sp.set_flag( "shoulder" );
|
||||
|
||||
if (side == 0) {
|
||||
tp = TGTexParams( poly.get_pt(0,2), width, dist, heading );
|
||||
tp = TGTexParams( poly.get_pt(0,2).toSGGeod(), width, dist, heading );
|
||||
tp.set_minu(0);
|
||||
tp.set_maxu(1);
|
||||
} else {
|
||||
tp = TGTexParams( poly.get_pt(0,1), width, dist, heading );
|
||||
tp = TGTexParams( poly.get_pt(0,1).toSGGeod(), width, dist, heading );
|
||||
tp.set_minu(1);
|
||||
tp.set_maxu(0);
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ void Runway::gen_runway_section( const TGPolygon& runway,
|
|||
double sect_wid = width * ( endw_pct - startw_pct );
|
||||
|
||||
TGTexParams tp;
|
||||
tp = TGTexParams( p0,
|
||||
tp = TGTexParams( p0.toSGGeod(),
|
||||
sect_wid,
|
||||
sect_len,
|
||||
heading );
|
||||
|
|
|
@ -174,7 +174,7 @@ int Taxiway::BuildBtg( superpoly_list* rwy_polys, texparams_list* texparams, sup
|
|||
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "tp construct");
|
||||
|
||||
tp = TGTexParams( taxi.get_pt(0,0), width, 250*SG_FEET_TO_METER, heading );
|
||||
tp = TGTexParams( taxi.get_pt(0,0).toSGGeod(), width, 250*SG_FEET_TO_METER, heading );
|
||||
texparams->push_back( tp );
|
||||
|
||||
if ( apt_base )
|
||||
|
|
|
@ -140,7 +140,7 @@ bool TGConstruct::load_poly(const string& path) {
|
|||
in >> minv;
|
||||
in >> maxv;
|
||||
|
||||
tp.set_ref( Point3D(x, y, 0.0f) );
|
||||
tp.set_ref( SGGeod::fromDeg(x,y) );
|
||||
tp.set_width( width );
|
||||
tp.set_length( length );
|
||||
tp.set_heading( heading );
|
||||
|
|
|
@ -77,7 +77,7 @@ TGPolygon TGConstruct::linear_tex_coords( const TGPolygon& tri, const TGTexParam
|
|||
|
||||
result.erase();
|
||||
|
||||
Point3D ref = tp.get_ref();
|
||||
SGGeod ref = tp.get_ref();
|
||||
double width = tp.get_width();
|
||||
double length = tp.get_length();
|
||||
double heading = tp.get_heading();
|
||||
|
@ -112,7 +112,7 @@ TGPolygon TGConstruct::linear_tex_coords( const TGPolygon& tri, const TGTexParam
|
|||
// and ending az1, az2 and distance (s). Lat, lon, and
|
||||
// azimuth are in degrees. distance in meters
|
||||
double az1, az2, dist;
|
||||
geo_inverse_wgs_84( 0, ref.y(), ref.x(), p.y(), p.x(),
|
||||
geo_inverse_wgs_84( 0, ref.getLatitudeDeg(), ref.getLongitudeDeg(), p.y(), p.x(),
|
||||
&az1, &az2, &dist );
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "basic course from ref = " << az2);
|
||||
|
||||
|
|
|
@ -42,26 +42,6 @@ void TGLandclass::clear(void)
|
|||
}
|
||||
}
|
||||
|
||||
// input from stream
|
||||
std::istream& operator >> ( std::istream& in, TGLandclass& lc)
|
||||
{
|
||||
int i, j, count;
|
||||
|
||||
// Load all landclass shapes
|
||||
for (i=0; i<TG_MAX_AREA_TYPES; i++) {
|
||||
in >> count;
|
||||
|
||||
for (j=0; j<count; j++) {
|
||||
TGShape shape;
|
||||
|
||||
in >> shape;
|
||||
lc.shapes[i].push_back( shape );
|
||||
}
|
||||
}
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
void TGLandclass::LoadFromGzFile(gzFile& fp)
|
||||
{
|
||||
int i, j, count;
|
||||
|
|
|
@ -152,8 +152,7 @@ public:
|
|||
void SaveToGzFile( gzFile& fp );
|
||||
void LoadFromGzFile( gzFile& fp );
|
||||
|
||||
// Friends for serialization
|
||||
friend std::istream& operator>> ( std::istream&, TGLandclass& );
|
||||
// Friend for output to stream
|
||||
friend std::ostream& operator<< ( std::ostream&, const TGLandclass& );
|
||||
|
||||
private:
|
||||
|
|
|
@ -70,39 +70,6 @@ void TGShape::IntersectPolys( void )
|
|||
}
|
||||
}
|
||||
|
||||
// Serialization
|
||||
// input from stream
|
||||
std::istream& operator >> ( std::istream& in, TGShape& p)
|
||||
{
|
||||
int i, count;
|
||||
|
||||
// First, load the clipmask
|
||||
in >> p.clip_mask;
|
||||
|
||||
// Then load superpolys
|
||||
in >> count;
|
||||
for (i=0; i<count; i++) {
|
||||
TGSuperPoly sp;
|
||||
in >> sp;
|
||||
p.sps.push_back( sp );
|
||||
}
|
||||
|
||||
// Then load texparams
|
||||
in >> count;
|
||||
for (i=0; i<count; i++) {
|
||||
TGTexParams tp;
|
||||
in >> tp;
|
||||
p.tps.push_back( tp );
|
||||
}
|
||||
|
||||
// Load the id, area type and textured flag
|
||||
in >> p.id;
|
||||
in >> p.area;
|
||||
in >> p.textured;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
void TGShape::LoadFromGzFile(gzFile& fp)
|
||||
{
|
||||
int i, count;
|
||||
|
|
|
@ -59,8 +59,7 @@ public:
|
|||
void SaveToGzFile( gzFile& fp );
|
||||
void LoadFromGzFile( gzFile& fp );
|
||||
|
||||
// Friends for serialization
|
||||
friend std::istream& operator>> ( std::istream&, TGShape& );
|
||||
// Friend for output to stream
|
||||
friend std::ostream& operator<< ( std::ostream&, const TGShape& );
|
||||
};
|
||||
|
||||
|
|
|
@ -767,7 +767,7 @@ makePolygonsTP (const Line &line, double width, poly_list& polys, texparams_list
|
|||
|
||||
polys.push_back(poly);
|
||||
|
||||
tp = TGTexParams( prev_inner, width, 20.0f, heading );
|
||||
tp = TGTexParams( prev_inner.Point3D::toSGGeod(), width, 20.0f, heading );
|
||||
tp.set_minv(last_end_v);
|
||||
tps.push_back(tp);
|
||||
|
||||
|
|
|
@ -371,7 +371,8 @@ static void clip_and_write_polys_with_tps( string root, long int p_index,
|
|||
tp = clipped_tps[s];
|
||||
|
||||
fprintf( rfp, "%.15f %.15f %.15f %.15f %.15f %.15f %.15f %.15f %.15f\n",
|
||||
tp.get_ref().x(), tp.get_ref().y(), tp.get_width(), tp.get_length(),
|
||||
tp.get_ref().getLongitudeDeg(), tp.get_ref().getLatitudeDeg(),
|
||||
tp.get_width(), tp.get_length(),
|
||||
tp.get_heading(),
|
||||
tp.get_minu(), tp.get_maxu(), tp.get_minu(), tp.get_maxu());
|
||||
|
||||
|
@ -474,7 +475,8 @@ static void clip_and_write_poly_tp( string root, long int p_index,
|
|||
fprintf( rfp, "%s\n", poly_type.c_str() );
|
||||
|
||||
fprintf( rfp, "%.15f %.15f %.15f %.15f %.15f %.15f %.15f %.15f %.15f\n",
|
||||
tp.get_ref().x(), tp.get_ref().y(), tp.get_width(), tp.get_length(),
|
||||
tp.get_ref().getLongitudeDeg(), tp.get_ref().getLatitudeDeg(),
|
||||
tp.get_width(), tp.get_length(),
|
||||
tp.get_heading(),
|
||||
tp.get_minu(), tp.get_maxu(), tp.get_minu(), tp.get_maxu());
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#include <simgear/io/lowlevel.hxx>
|
||||
|
||||
#include "texparams.hxx"
|
||||
|
||||
// Send a TexParam to standard output.
|
||||
|
@ -19,7 +21,7 @@ std::ostream& operator << (std::ostream &output, const TGTexParams &tp)
|
|||
|
||||
void TGTexParams::SaveToGzFile(gzFile& fp)
|
||||
{
|
||||
sgWritePoint3D( fp, ref );
|
||||
sgWriteSGGeod( fp, ref );
|
||||
sgWriteDouble( fp, width );
|
||||
sgWriteDouble( fp, length );
|
||||
sgWriteDouble( fp, heading );
|
||||
|
@ -30,26 +32,9 @@ void TGTexParams::SaveToGzFile(gzFile& fp)
|
|||
sgWriteDouble( fp, maxv );
|
||||
}
|
||||
|
||||
// Read a polygon from input buffer.
|
||||
std::istream& operator >> (std::istream &input, TGTexParams &tp)
|
||||
{
|
||||
// Load the data
|
||||
input >> tp.ref;
|
||||
input >> tp.width;
|
||||
input >> tp.length;
|
||||
input >> tp.heading;
|
||||
|
||||
input >> tp.minu;
|
||||
input >> tp.maxu;
|
||||
input >> tp.minv;
|
||||
input >> tp.maxv;
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
void TGTexParams::LoadFromGzFile(gzFile& fp)
|
||||
{
|
||||
sgReadPoint3D( fp, ref );
|
||||
sgReadSGGeod( fp, ref );
|
||||
sgReadDouble( fp, &width );
|
||||
sgReadDouble( fp, &length );
|
||||
sgReadDouble( fp, &heading );
|
||||
|
|
|
@ -30,19 +30,21 @@
|
|||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/math/sg_types.hxx>
|
||||
#include <simgear/math/SGMath.hxx>
|
||||
|
||||
#include <Geometry/point3d.hxx>
|
||||
#include <zlib.h> /* for gzFile */
|
||||
|
||||
#include <vector>
|
||||
|
||||
class TGTexParams {
|
||||
|
||||
private:
|
||||
|
||||
Point3D ref;
|
||||
SGGeod ref;
|
||||
double width;
|
||||
double length;
|
||||
double heading;
|
||||
|
@ -58,7 +60,7 @@ public:
|
|||
inline TGTexParams( void )
|
||||
{
|
||||
}
|
||||
inline TGTexParams( const Point3D &r, const double w, const double l, const double h )
|
||||
inline TGTexParams( const SGGeod &r, const double w, const double l, const double h )
|
||||
{
|
||||
ref = r;
|
||||
width = w;
|
||||
|
@ -72,11 +74,11 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
inline Point3D get_ref() const
|
||||
inline SGGeod get_ref() const
|
||||
{
|
||||
return ref;
|
||||
}
|
||||
inline void set_ref( const Point3D &r )
|
||||
inline void set_ref( const SGGeod &r )
|
||||
{
|
||||
ref = r;
|
||||
}
|
||||
|
@ -146,9 +148,8 @@ public:
|
|||
|
||||
void SaveToGzFile( gzFile& fp );
|
||||
void LoadFromGzFile( gzFile& fp );
|
||||
|
||||
// Friends for serialization
|
||||
friend std::istream& operator>> ( std::istream&, TGTexParams& );
|
||||
|
||||
// Friend for output
|
||||
friend std::ostream& operator<< ( std::ostream&, const TGTexParams& );
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue