Added cur_radius (radius in meters from the center of the earth) to the
current terrain elevation structure.
This commit is contained in:
parent
ed973e8993
commit
e8d1596ec7
3 changed files with 28 additions and 15 deletions
|
@ -47,6 +47,10 @@ struct fgSCENERY {
|
||||||
// elevation of terrain at our current lat/lon (based on the
|
// elevation of terrain at our current lat/lon (based on the
|
||||||
// actual drawn polygons)
|
// actual drawn polygons)
|
||||||
double cur_elev;
|
double cur_elev;
|
||||||
|
|
||||||
|
// the distance (radius) from the center of the earth to the
|
||||||
|
// current scenery elevation point
|
||||||
|
double cur_radius;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct fgSCENERY scenery;
|
extern struct fgSCENERY scenery;
|
||||||
|
|
|
@ -696,7 +696,7 @@ void FGTileMgr::my_ssg_los( string s, ssgBranch *branch, sgdMat4 m,
|
||||||
// explicitely. lat & lon are in radians. view_pos in current world
|
// explicitely. lat & lon are in radians. view_pos in current world
|
||||||
// coordinate translated near (0,0,0) (in meters.) Returns result in
|
// coordinate translated near (0,0,0) (in meters.) Returns result in
|
||||||
// meters.
|
// meters.
|
||||||
double
|
bool
|
||||||
FGTileMgr::current_elev_ssg( const Point3D& abs_view_pos,
|
FGTileMgr::current_elev_ssg( const Point3D& abs_view_pos,
|
||||||
const Point3D& view_pos )
|
const Point3D& view_pos )
|
||||||
{
|
{
|
||||||
|
@ -716,32 +716,40 @@ FGTileMgr::current_elev_ssg( const Point3D& abs_view_pos,
|
||||||
<< view_pos[0] << " " << view_pos[1] << " " << view_pos[2] );
|
<< view_pos[0] << " " << view_pos[1] << " " << view_pos[2] );
|
||||||
my_ssg_los( "", scene, m, sgvp, sgavp );
|
my_ssg_los( "", scene, m, sgvp, sgavp );
|
||||||
|
|
||||||
|
Point3D rel_cart;
|
||||||
|
Point3D abs_cart;
|
||||||
|
Point3D geoc;
|
||||||
|
double lat_geod, alt, sea_level_r;
|
||||||
double result = -9999;
|
double result = -9999;
|
||||||
|
|
||||||
for ( int i = 0; i < hitcount; ++i ) {
|
for ( int i = 0; i < hitcount; ++i ) {
|
||||||
Point3D rel_cart( hit_pts[i][0], hit_pts[i][1], hit_pts[i][2] );
|
rel_cart = Point3D( hit_pts[i][0], hit_pts[i][1], hit_pts[i][2] );
|
||||||
Point3D abs_cart = rel_cart + scenery.center;
|
abs_cart = rel_cart + scenery.center;
|
||||||
Point3D pp = fgCartToPolar3d( abs_cart );
|
geoc = fgCartToPolar3d( abs_cart );
|
||||||
FG_LOG( FG_TERRAIN, FG_DEBUG, " polar form = " << pp );
|
// FG_LOG( FG_TERRAIN, FG_DEBUG, " polar form = " << geoc );
|
||||||
// convert to geodetic coordinates
|
// convert to geodetic coordinates
|
||||||
double lat_geod, alt, sea_level_r;
|
fgGeocToGeod(geoc.lat(), geoc.radius(), &lat_geod,
|
||||||
fgGeocToGeod(pp.lat(), pp.radius(), &lat_geod,
|
|
||||||
&alt, &sea_level_r);
|
&alt, &sea_level_r);
|
||||||
FG_LOG( FG_TERRAIN, FG_DEBUG, " alt (meters) = " << alt );
|
// FG_LOG( FG_TERRAIN, FG_DEBUG, " alt (meters) = " << alt );
|
||||||
|
// FG_LOG( FG_TERRAIN, FG_DEBUG, " geoc alt (meters) = " << geoc.radius() );
|
||||||
|
// FG_LOG( FG_TERRAIN, FG_DEBUG, " sea_level_r + alt = " << sea_level_r + alt );
|
||||||
|
|
||||||
// printf("alt = %.2f\n", alt);
|
// printf("alt = %.2f\n", alt);
|
||||||
// exit since we found an intersection
|
// exit since we found an intersection
|
||||||
if ( alt > result && alt < 10000 ) {
|
if ( alt > result && alt < 10000 ) {
|
||||||
// printf("returning alt\n");
|
// printf(" returning alt = %.2f\n", alt);
|
||||||
result = alt;
|
result = alt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( result > -9000 ) {
|
if ( result > -9000 ) {
|
||||||
return result;
|
scenery.cur_elev = result;
|
||||||
|
scenery.cur_radius = geoc.radius();
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
FG_LOG( FG_TERRAIN, FG_INFO, "no terrain intersection" );
|
FG_LOG( FG_TERRAIN, FG_INFO, "no terrain intersection" );
|
||||||
return 0.0;
|
scenery.cur_elev = 0.0;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -951,15 +959,16 @@ int FGTileMgr::update( void ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// find our current elevation (feed in the current bucket to save work)
|
// find our current elevation (feed in the current bucket to save work)
|
||||||
Point3D geod_pos = Point3D( f->get_Longitude(), f->get_Latitude(), 0.0);
|
// Point3D geod_pos = Point3D( f->get_Longitude(), f->get_Latitude(), 0.0);
|
||||||
// Point3D tmp_abs_view_pos = fgGeodToCart(geod_pos);
|
// Point3D tmp_abs_view_pos = fgGeodToCart(geod_pos);
|
||||||
|
|
||||||
// cout << "current elevation (old) == "
|
// cout << "current elevation (old) == "
|
||||||
// << current_elev( f->get_Longitude(), f->get_Latitude(),
|
// << current_elev( f->get_Longitude(), f->get_Latitude(),
|
||||||
// tmp_abs_view_pos )
|
// tmp_abs_view_pos )
|
||||||
// << endl;
|
// << endl;
|
||||||
scenery.cur_elev = current_elev_ssg( current_view.abs_view_pos,
|
|
||||||
current_view.view_pos );
|
// set scenery.cur_elev and scenery.cur_radius
|
||||||
|
current_elev_ssg( current_view.abs_view_pos, current_view.view_pos );
|
||||||
// cout << "current elevation (ssg) == " << scenery.cur_elev << endl;
|
// cout << "current elevation (ssg) == " << scenery.cur_elev << endl;
|
||||||
|
|
||||||
p_last = p1;
|
p_last = p1;
|
||||||
|
|
|
@ -112,7 +112,7 @@ public:
|
||||||
double current_elev( double lon, double lat, const Point3D& abs_view_pos );
|
double current_elev( double lon, double lat, const Point3D& abs_view_pos );
|
||||||
void my_ssg_los( string s, ssgBranch *branch, sgdMat4 m,
|
void my_ssg_los( string s, ssgBranch *branch, sgdMat4 m,
|
||||||
const sgdVec3 p, const sgdVec3 dir );
|
const sgdVec3 p, const sgdVec3 dir );
|
||||||
double current_elev_ssg( const Point3D& abs_view_pos,
|
bool current_elev_ssg( const Point3D& abs_view_pos,
|
||||||
const Point3D& view_pos );
|
const Point3D& view_pos );
|
||||||
double current_elev_new( const FGBucket& p );
|
double current_elev_new( const FGBucket& p );
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue