PageRenderTime 32ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/flightgear-2.6.0/src/AIModel/AIManager.hxx

#
C++ Header | 144 lines | 91 code | 30 blank | 23 comment | 0 complexity | dc94e8f34b1d19815e7a820c6750c5dd MD5 | raw file
Possible License(s): GPL-2.0
  1. // AIManager.hxx - David Culp - based on:
  2. // AIMgr.hxx - definition of FGAIMgr
  3. // - a global management class for FlightGear generated AI traffic
  4. //
  5. // Written by David Luff, started March 2002.
  6. //
  7. // Copyright (C) 2002 David C Luff - david.luff@nottingham.ac.uk
  8. //
  9. // This program is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU General Public License as
  11. // published by the Free Software Foundation; either version 2 of the
  12. // License, or (at your option) any later version.
  13. //
  14. // This program is distributed in the hope that it will be useful, but
  15. // WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. // General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public License
  20. // along with this program; if not, write to the Free Software
  21. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  22. #ifndef _FG_AIMANAGER_HXX
  23. #define _FG_AIMANAGER_HXX
  24. #include <list>
  25. #include <simgear/structure/subsystem_mgr.hxx>
  26. #include <simgear/structure/SGSharedPtr.hxx>
  27. #include <simgear/props/props_io.hxx>
  28. #include <Main/fg_props.hxx>
  29. #include <AIModel/AIBase.hxx>
  30. #include <AIModel/AIFlightPlan.hxx>
  31. #include <Traffic/SchedFlight.hxx>
  32. #include <Traffic/Schedule.hxx>
  33. using std::list;
  34. class FGAIThermal;
  35. class FGAIManager : public SGSubsystem
  36. {
  37. public:
  38. // A list of pointers to AI objects
  39. typedef list <SGSharedPtr<FGAIBase> > ai_list_type;
  40. typedef ai_list_type::iterator ai_list_iterator;
  41. typedef ai_list_type::const_iterator ai_list_const_iterator;
  42. ai_list_type ai_list;
  43. inline const ai_list_type& get_ai_list() const {
  44. SG_LOG(SG_AI, SG_DEBUG, "AI Manager: AI model return list size " << ai_list.size());
  45. return ai_list;
  46. }
  47. FGAIManager();
  48. ~FGAIManager();
  49. void init();
  50. void postinit();
  51. void reinit();
  52. void bind();
  53. void unbind();
  54. void update(double dt);
  55. void updateLOD(SGPropertyNode* node);
  56. void attach(FGAIBase *model);
  57. void destroyObject( int ID );
  58. const FGAIBase *calcCollision(double alt, double lat, double lon, double fuse_range);
  59. inline double get_user_latitude() const { return user_latitude; }
  60. inline double get_user_longitude() const { return user_longitude; }
  61. inline double get_user_altitude() const { return user_altitude; }
  62. inline double get_user_heading() const { return user_heading; }
  63. inline double get_user_pitch() const { return user_pitch; }
  64. inline double get_user_yaw() const { return user_yaw; }
  65. inline double get_user_speed() const {return user_speed; }
  66. inline double get_wind_from_east() const {return wind_from_east; }
  67. inline double get_wind_from_north() const {return wind_from_north; }
  68. inline double get_user_roll() const { return user_roll; }
  69. inline double get_user_agl() const { return user_altitude_agl; }
  70. int getNumAiObjects(void) const;
  71. void processScenario( const string &filename );
  72. static SGPropertyNode_ptr loadScenarioFile(const std::string& filename);
  73. static bool getStartPosition(const string& id, const string& pid,
  74. SGGeod& geodPos, double& hdng, SGVec3d& uvw);
  75. private:
  76. bool enabled;
  77. int mNumAiTypeModels[FGAIBase::MAX_OBJECTS];
  78. int mNumAiModels;
  79. double calcRange(double lat, double lon, double lat2, double lon2)const;
  80. SGPropertyNode_ptr root;
  81. SGPropertyNode_ptr thermal_lift_node;
  82. SGPropertyNode_ptr user_latitude_node;
  83. SGPropertyNode_ptr user_longitude_node;
  84. SGPropertyNode_ptr user_altitude_node;
  85. SGPropertyNode_ptr user_altitude_agl_node;
  86. SGPropertyNode_ptr user_heading_node;
  87. SGPropertyNode_ptr user_pitch_node;
  88. SGPropertyNode_ptr user_yaw_node;
  89. SGPropertyNode_ptr user_roll_node;
  90. SGPropertyNode_ptr user_speed_node;
  91. SGPropertyNode_ptr wind_from_east_node;
  92. SGPropertyNode_ptr wind_from_north_node;
  93. double user_latitude;
  94. double user_longitude;
  95. double user_altitude;
  96. double user_altitude_agl;
  97. double user_heading;
  98. double user_pitch;
  99. double user_yaw;
  100. double user_roll;
  101. double user_speed;
  102. double user_agl;
  103. double wind_from_east;
  104. double wind_from_north;
  105. double _dt;
  106. void fetchUserState( void );
  107. // used by thermals
  108. double range_nearest;
  109. double strength;
  110. void processThermal( FGAIThermal* thermal );
  111. SGPropertyChangeCallback<FGAIManager> cb_ai_bare;
  112. SGPropertyChangeCallback<FGAIManager> cb_ai_detailed;
  113. };
  114. #endif // _FG_AIMANAGER_HXX