From: david Date: Fri, 5 Apr 2002 18:48:04 +0000 (+0000) Subject: Patch from Jim Wilson to realign model slightly in new model code: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9d6011aa691e2c33c5430b8b8a8d5434e574f637;p=flightgear.git Patch from Jim Wilson to realign model slightly in new model code: This should fix it. The problem wasn't the rotations but a difference in the translations. Note that this fix also puts the wheels back on top of the pavement when in external view. --- diff --git a/src/Model/model.cxx b/src/Model/model.cxx index 33f16cedd..f5d5426f5 100644 --- a/src/Model/model.cxx +++ b/src/Model/model.cxx @@ -128,19 +128,31 @@ world_coordinate( sgCoord *obj_pos, double lat_deg, double lon_deg, double elev_ft, double roll_deg, double pitch_deg, double hdg_deg) { + // setup translation + double sea_level_radius_m; + double lat_geoc_rad; + + // Convert from geodetic to geocentric + // coordinates. + sgGeodToGeoc(lat_deg * SGD_DEGREES_TO_RADIANS, + elev_ft * SG_FEET_TO_METER, + &sea_level_radius_m, + &lat_geoc_rad); + Point3D center = scenery.get_center(); - // setup transforms - Point3D geod( lon_deg * SGD_DEGREES_TO_RADIANS, - lat_deg * SGD_DEGREES_TO_RADIANS, - elev_ft * SG_FEET_TO_METER); + Point3D geod = Point3D(lon_deg * SG_DEGREES_TO_RADIANS, + lat_geoc_rad, + sea_level_radius_m); + geod.setz(geod.radius() + elev_ft * SG_FEET_TO_METER); - Point3D world_pos = sgGeodToCart( geod ); + Point3D world_pos = sgPolarToCart3d( geod ); Point3D offset = world_pos - center; sgMat4 POS; sgMakeTransMat4( POS, offset.x(), offset.y(), offset.z() ); + // setup transforms sgVec3 obj_bk, obj_rt, obj_up; sgSetVec3( obj_bk, 1.0, 0.0, 0.0); // X axis sgSetVec3( obj_rt, 0.0, 1.0, 0.0); // Y axis