X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2Fflight.hxx;h=f5533625c090772cc5012ff3b55c1247acf617b9;hb=3ec74d79c23347add2afa088b05ad29af975f65f;hp=8dc1aaebb3dc48c8c2198e494519b988e196990a;hpb=b1674cb5063992cfa2bbf61bbaa827fbf89229d9;p=flightgear.git diff --git a/src/FDM/flight.hxx b/src/FDM/flight.hxx index 8dc1aaebb..f5533625c 100644 --- a/src/FDM/flight.hxx +++ b/src/FDM/flight.hxx @@ -2,7 +2,7 @@ // // Written by Curtis Olson, started May 1997. // -// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com +// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as @@ -16,7 +16,7 @@ // // 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., 675 Mass Ave, Cambridge, MA 02139, USA. +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id$ @@ -81,31 +81,25 @@ */ -#include - #include #include #include #include +#include #include -// #include - -#include
-#include -#include -#include
+#include +#include SG_USING_STD(list); SG_USING_STD(vector); SG_USING_STD(string); - typedef double FG_VECTOR_3[3]; // This is based heavily on LaRCsim/ls_generic.h -class FGInterface : public FGSubsystem { +class FGInterface : public SGSubsystem { private: @@ -227,8 +221,8 @@ private: // SGTimeStamp valid_stamp; // time this record is valid // SGTimeStamp next_stamp; // time this record is valid - // Model tied to FDM - FGAircraftModel * _acmodel; + // the ground cache object itself. + FGGroundCache ground_cache; protected: @@ -244,6 +238,7 @@ public: void _busdump(void); void _updateGeodeticPosition( double lat, double lon, double alt ); void _updateGeocentricPosition( double lat_geoc, double lon, double alt ); + void _update_ground_elev_at_pos( void ); void _updateWeather( void ); inline void _set_Inertias( double m, double xx, double yy, @@ -374,11 +369,10 @@ public: inline void _set_Density( double d ) { density = d; } inline void _set_Mach_number( double m ) { mach_number = m; } inline void _set_Static_pressure( double sp ) { static_pressure = sp; } - inline void _set_Static_temperature( double t ) { static_temperature = t; } + inline void _set_Static_temperature( double t ) { static_temperature = t; } + inline void _set_Total_temperature( double tat ) { total_temperature = tat; } //JW inline void _set_Sea_level_radius( double r ) { sea_level_radius = r; } - inline void _set_Earth_position_angle(double a) { - earth_position_angle = a; - } + inline void _set_Earth_position_angle(double a) { earth_position_angle = a; } inline void _set_Runway_altitude( double alt ) { runway_altitude = alt; } inline void _set_Climb_Rate(double rate) { climb_rate = rate; } inline void _set_sin_lat_geocentric(double parm) { @@ -511,11 +505,15 @@ public: virtual void set_Psi (double psi) { set_Euler_Angles(get_Phi(), get_Theta(), psi); } - virtual void set_Phi_deg (double phi) { set_Phi(phi * SGD_DEGREES_TO_RADIANS); } + virtual void set_Phi_deg (double phi) { + set_Phi(phi * SGD_DEGREES_TO_RADIANS); + } virtual void set_Theta_deg (double theta) { set_Theta(theta * SGD_DEGREES_TO_RADIANS); } - virtual void set_Psi_deg (double psi) { set_Psi(psi * SGD_DEGREES_TO_RADIANS); } + virtual void set_Psi_deg (double psi) { + set_Psi(psi * SGD_DEGREES_TO_RADIANS); + } // Flight Path virtual void set_Climb_Rate( double roc); @@ -834,6 +832,9 @@ public: inline double get_Phi_dot() const { return euler_rates_v[0]; } inline double get_Theta_dot() const { return euler_rates_v[1]; } inline double get_Psi_dot() const { return euler_rates_v[2]; } + inline double get_Phi_dot_degps() const { return euler_rates_v[0] * SGD_RADIANS_TO_DEGREES; } + inline double get_Theta_dot_degps() const { return euler_rates_v[1] * SGD_RADIANS_TO_DEGREES; } + inline double get_Psi_dot_degps() const { return euler_rates_v[2] * SGD_RADIANS_TO_DEGREES; } // inline double * get_Geocentric_rates_v() { return geocentric_rates_v; } inline double get_Latitude_dot() const { return geocentric_rates_v[0]; } @@ -976,6 +977,7 @@ public: } inline double get_Runway_altitude() const { return runway_altitude; } + inline double get_Runway_altitude_m() const { return SG_FEET_TO_METER * runway_altitude; } // inline double get_Runway_latitude() const { return runway_latitude; } // inline void set_Runway_latitude( double lat ) { runway_latitude = lat; } // inline double get_Runway_longitude() const { return runway_longitude; } @@ -1077,25 +1079,94 @@ public: inline float get_faux( int n ) const { return faux[n]; } inline int get_iaux( int n ) const { return iaux[n]; } - // Model tied to FDM - FGAircraftModel * getACModel() const { return _acmodel; } - // Note that currently this is the "same" value runway altitude... inline double get_ground_elev_ft() const { return runway_altitude; } -}; - -typedef list < FGInterface > fdm_state_list; -typedef fdm_state_list::iterator fdm_state_list_iterator; -typedef fdm_state_list::const_iterator const_fdm_state_list_iterator; + ////////////////////////////////////////////////////////////////////////// + // Ground handling routines + ////////////////////////////////////////////////////////////////////////// + enum GroundType { + Unknown = 0, //?? + Solid, // Whatever we will roll on with infinite load factor. + Water, // For the beaver ... + Catapult, // Carrier cats. + Wire // Carrier wires. + }; -extern FGInterface * cur_fdm_state; + // Prepare the ground cache for the wgs84 position pt_*. + // That is take all vertices in the ball with radius rad around the + // position given by the pt_* and store them in a local scene graph. + bool prepare_ground_cache_m(double ref_time, const double pt[3], + double rad); + bool prepare_ground_cache_ft(double ref_time, const double pt[3], + double rad); + + + // Returns true if the cache is valid. + // Also the reference time, point and radius values where the cache + // is valid for are returned. + bool is_valid_m(double *ref_time, double pt[3], double *rad); + bool is_valid_ft(double *ref_time, double pt[3], double *rad); + + // Return the nearest catapult to the given point + // pt in wgs84 coordinates. + double get_cat_m(double t, const double pt[3], + double end[2][3], double vel[2][3]); + double get_cat_ft(double t, const double pt[3], + double end[2][3], double vel[2][3]); + + // Return the altitude above ground below the wgs84 point pt + // Search for the nearest triangle to pt. + // Return ground properties like the ground type, the maximum load + // this kind kind of ground can carry, the friction factor between + // 0 and 1 which can be used to model lower friction with wet runways + // and finally the altitude above ground. + bool get_agl_m(double t, const double pt[3], + double contact[3], double normal[3], double vel[3], + int *type, double *loadCapacity, + double *frictionFactor, double *agl); + bool get_agl_m(double t, const double pt[3], + double contact[3], double normal[3], double vel[3], + int *type, const SGMaterial **material,double *agl); + bool get_agl_ft(double t, const double pt[3], + double contact[3], double normal[3], double vel[3], + int *type, double *loadCapacity, + double *frictionFactor, double *agl); + + // Return the altitude above ground below the wgs84 point pt + // Search for the nearest triangle to pt. + // Return ground properties like the ground type, a pointer to the + // material and finally the altitude above ground. + bool get_agl_m(double t, const double pt[3], double max_altoff, + double contact[3], double normal[3], double vel[3], + int *type, const SGMaterial** material, double *agl); + bool get_agl_ft(double t, const double pt[3], double max_altoff, + double contact[3], double normal[3], double vel[3], + int *type, const SGMaterial** material, double *agl); + double get_groundlevel_m(double lat, double lon, double alt); + + + // Return 1 if the hook intersects with a wire. + // That test is done by checking if the quad spanned by the points pt* + // intersects with the line representing the wire. + // If the wire is caught, the cache will trace this wires endpoints until + // the FDM calls release_wire(). + bool caught_wire_m(double t, const double pt[4][3]); + bool caught_wire_ft(double t, const double pt[4][3]); + + // Return the location and speed of the wire endpoints. + bool get_wire_ends_m(double t, double end[2][3], double vel[2][3]); + bool get_wire_ends_ft(double t, double end[2][3], double vel[2][3]); -// General interface to the flight model routines + // Tell the cache code that it does no longer need to care for + // the wire end position. + void release_wire(void); +}; +extern FGInterface * cur_fdm_state; // Toggle data logging on/off void fgToggleFDMdataLogging(void);