]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/submodel.hxx
Interim windows build fix
[flightgear.git] / src / AIModel / submodel.hxx
index 7b28b176b0832c7118e8d50b9c35cd78cb34c48d..02de6d6e13dd69951653dc4de72933490f313408 100644 (file)
 
 #include <simgear/props/props.hxx>
 #include <simgear/structure/subsystem_mgr.hxx>
-#include <AIModel/AIBase.hxx>
+#include <simgear/math/SGMath.hxx>
+
+#include <Autopilot/inputvalue.hxx>
+
 #include <vector>
 #include <string>
-SG_USING_STD(vector);
-SG_USING_STD(string);
 
 class FGAIBase;
+class FGAIManager;
 
-class FGSubmodelMgr : public SGSubsystem
+class FGSubmodelMgr : public SGSubsystem, public SGPropertyChangeListener
 {
 
 public:
 
-    typedef struct
-    {
+    typedef struct {
         SGPropertyNode_ptr trigger_node;
         SGPropertyNode_ptr prop;
         SGPropertyNode_ptr contents_node;
         SGPropertyNode_ptr submodel_node;
         SGPropertyNode_ptr speed_node;
 
-        string             name;
-        string             model;
+        std::string        name;
+        std::string        model;
         double             speed;
         bool               slaved;
         bool               repeat;
         double             delay;
         double             timer;
         int                count;
-        double             x_offset;
-        double             y_offset;
-        double             z_offset;
-        double             yaw_offset;
-        double             pitch_offset;
+        bool               offsets_in_meter;
+        FGXMLAutopilot::InputValue_ptr x_offset;
+        FGXMLAutopilot::InputValue_ptr y_offset;
+        FGXMLAutopilot::InputValue_ptr z_offset;
+        FGXMLAutopilot::InputValue_ptr yaw_offset;
+        FGXMLAutopilot::InputValue_ptr pitch_offset;
         double             drag_area;
         double             life;
         double             buoyancy;
+        FGXMLAutopilot::InputValue_ptr azimuth_error;
+        FGXMLAutopilot::InputValue_ptr elevation_error;
+        FGXMLAutopilot::InputValue_ptr cd_randomness;
+        FGXMLAutopilot::InputValue_ptr life_randomness;
         bool               wind;
         bool               first_time;
         double             cd;
         double             weight;
+        double             mass;
         double             contents;
         bool               aero_stabilised;
         int                id;
         bool               no_roll;
         bool               serviceable;
+        bool               random;
+        bool               collision;
+        bool               expiry;
         bool               impact;
-        string             impact_reports;
-    }
-    submodel;
-
-    typedef struct
-    {
+        std::string        impact_report;
+        double             fuse_range;
+        std::string        submodel;
+        int                sub_id;
+        bool               force_stabilised;
+        bool               ext_force;
+        std::string        force_path;
+    }   submodel;
+
+    typedef struct {
         double     lat;
         double     lon;
         double     alt;
@@ -78,15 +92,11 @@ public:
         double     speed_down_fps;
         double     speed_east_fps;
         double     speed_north_fps;
-        double     total_speed_down;
-        double     total_speed_east;
-        double     total_speed_north;
         double     mass;
         int        id;
         bool       no_roll;
-        bool       impact;
-    }
-    IC_struct;
+        int        parent_id;
+    }   IC_struct;
 
     FGSubmodelMgr();
     ~FGSubmodelMgr();
@@ -97,29 +107,16 @@ public:
     void bind();
     void unbind();
     void update(double dt);
-    bool release(submodel* sm, double dt);
-    void transform(submodel* sm);
     void updatelat(double lat);
 
 private:
 
-    typedef vector <submodel*> submodel_vector_type;
-    typedef submodel_vector_type::const_iterator submodel_vector_iterator;
+    typedef std::vector <submodel*> submodel_vector_type;
+    typedef submodel_vector_type::iterator submodel_vector_iterator;
 
     submodel_vector_type       submodels;
-    submodel_vector_iterator   submodel_iterator;
-
-    float trans[3][3];
-    float in[3];
-    float out[3];
-
-    double Rx, Ry, Rz;
-    double Sx, Sy, Sz;
-    double Tx, Ty, Tz;
-
-    float cosRx, sinRx;
-    float cosRy, sinRy;
-    float cosRz, sinRz;
+    submodel_vector_type       subsubmodels;
+    submodel_vector_iterator   submodel_iterator, subsubmodel_iterator;
 
     int index;
 
@@ -129,10 +126,28 @@ private:
     double x_offset, y_offset, z_offset;
     double pitch_offset, yaw_offset;
 
-    static const double lbs_to_slugs; //conversion factor
+    double _parent_lat;
+    double _parent_lon;
+    double _parent_elev;
+    double _parent_hdg;
+    double _parent_pitch;
+    double _parent_roll;
+    double _parent_speed;
+
+    double _x_offset;
+    double _y_offset;
+    double _z_offset;
+
+    // Conversion factor
+    static const double lbs_to_slugs;
 
     double contrail_altitude;
 
+    bool _impact;
+    bool _hit;
+    bool _expiry;
+    bool _found_sub;
+
     SGPropertyNode_ptr _serviceable_node;
     SGPropertyNode_ptr _user_lat_node;
     SGPropertyNode_ptr _user_lon_node;
@@ -150,21 +165,32 @@ private:
     SGPropertyNode_ptr _user_speed_north_fps_node;
     SGPropertyNode_ptr _contrail_altitude_node;
     SGPropertyNode_ptr _contrail_trigger;
+    SGPropertyNode_ptr _count_node;
+    SGPropertyNode_ptr _trigger_node;
+    SGPropertyNode_ptr props;
+    SGPropertyNode_ptr _model_added_node;
+    SGPropertyNode_ptr _path_node;
+    SGPropertyNode_ptr _selected_ac;
 
-    FGAIManager* ai;
     IC_struct  IC;
 
-    // A list of pointers to AI objects
-    typedef list <SGSharedPtr<FGAIBase> > sm_list_type;
-    typedef sm_list_type::iterator sm_list_iterator;
-    typedef sm_list_type::const_iterator sm_list_const_iterator;
-
-    sm_list_type sm_list;
+    // Helper to retrieve the AI manager, if it currently exists
+    FGAIManager* aiManager();
 
     void loadAI();
     void loadSubmodels();
-    void setData(int id, string& path, bool serviceable);
-    double getRange(double lat, double lon, double lat2, double lon2) const;
+    void setData(int id, const std::string& path, bool serviceable, const std::string& property_path, submodel_vector_type& models);
+    void valueChanged (SGPropertyNode *);
+    void transform(submodel *);
+    void setParentNode(int parent_id);
+    bool release(submodel *, double dt);
+
+    int _count;
+
+    SGGeod userpos;
+    SGGeod offsetpos;
+    SGVec3d getCartOffsetPos() const;
+    void setOffsetPos();
 
 };