]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/submodel.hxx
Maik: add ROTORELTARGET and ROTORENGINEMAXRELTORQUE input axes
[flightgear.git] / src / AIModel / submodel.hxx
1 // submodel.hxx - models a releasable submodel.
2 // Written by Dave Culp, started Aug 2004
3 //
4 // This file is in the Public Domain and comes with no warranty.
5
6
7 #ifndef __SYSTEMS_SUBMODEL_HXX
8 #define __SYSTEMS_SUBMODEL_HXX 1
9
10 #ifndef __cplusplus
11 # error This library requires C++
12 #endif
13
14 #include <simgear/props/props.hxx>
15 #include <simgear/structure/subsystem_mgr.hxx>
16 #include <AIModel/AIBase.hxx>
17 #include <vector>
18 #include <string>
19 SG_USING_STD(vector);
20 SG_USING_STD(string);
21
22 class FGAIBase;
23
24 class FGSubmodelMgr : public SGSubsystem
25 {
26
27 public:
28
29     typedef struct
30     {
31         SGPropertyNode_ptr trigger_node;
32         SGPropertyNode_ptr prop;
33         SGPropertyNode_ptr contents_node;
34         SGPropertyNode_ptr submodel_node;
35         SGPropertyNode_ptr speed_node;
36
37         string             name;
38         string             model;
39         double             speed;
40         bool               slaved;
41         bool               repeat;
42         double             delay;
43         double             timer;
44         int                count;
45         double             x_offset;
46         double             y_offset;
47         double             z_offset;
48         double             yaw_offset;
49         double             pitch_offset;
50         double             drag_area;
51         double             life;
52         double             buoyancy;
53         bool               wind;
54         bool               first_time;
55         double             cd;
56         double             weight;
57         double             contents;
58         bool               aero_stabilised;
59         int                id;
60         bool               no_roll;
61         bool               serviceable;
62         bool               impact;
63         string             impact_reports;
64     }
65     submodel;
66
67     typedef struct
68     {
69         double     lat;
70         double     lon;
71         double     alt;
72         double     roll;
73         double     azimuth;
74         double     elevation;
75         double     speed;
76         double     wind_from_east;
77         double     wind_from_north;
78         double     speed_down_fps;
79         double     speed_east_fps;
80         double     speed_north_fps;
81         double     total_speed_down;
82         double     total_speed_east;
83         double     total_speed_north;
84         double     mass;
85         int        id;
86         bool       no_roll;
87         bool       impact;
88     }
89     IC_struct;
90
91     FGSubmodelMgr();
92     ~FGSubmodelMgr();
93
94     void load();
95     void init();
96     void postinit();
97     void bind();
98     void unbind();
99     void update(double dt);
100     bool release(submodel* sm, double dt);
101     void transform(submodel* sm);
102     void updatelat(double lat);
103
104 private:
105
106     typedef vector <submodel*> submodel_vector_type;
107     typedef submodel_vector_type::const_iterator submodel_vector_iterator;
108
109     submodel_vector_type       submodels;
110     submodel_vector_iterator   submodel_iterator;
111
112     float trans[3][3];
113     float in[3];
114     float out[3];
115
116     double Rx, Ry, Rz;
117     double Sx, Sy, Sz;
118     double Tx, Ty, Tz;
119
120     float cosRx, sinRx;
121     float cosRy, sinRy;
122     float cosRz, sinRz;
123
124     int index;
125
126     double ft_per_deg_longitude;
127     double ft_per_deg_latitude;
128
129     double x_offset, y_offset, z_offset;
130     double pitch_offset, yaw_offset;
131
132     static const double lbs_to_slugs; //conversion factor
133
134     double contrail_altitude;
135
136     SGPropertyNode_ptr _serviceable_node;
137     SGPropertyNode_ptr _user_lat_node;
138     SGPropertyNode_ptr _user_lon_node;
139     SGPropertyNode_ptr _user_heading_node;
140     SGPropertyNode_ptr _user_alt_node;
141     SGPropertyNode_ptr _user_pitch_node;
142     SGPropertyNode_ptr _user_roll_node;
143     SGPropertyNode_ptr _user_yaw_node;
144     SGPropertyNode_ptr _user_alpha_node;
145     SGPropertyNode_ptr _user_speed_node;
146     SGPropertyNode_ptr _user_wind_from_east_node;
147     SGPropertyNode_ptr _user_wind_from_north_node;
148     SGPropertyNode_ptr _user_speed_down_fps_node;
149     SGPropertyNode_ptr _user_speed_east_fps_node;
150     SGPropertyNode_ptr _user_speed_north_fps_node;
151     SGPropertyNode_ptr _contrail_altitude_node;
152     SGPropertyNode_ptr _contrail_trigger;
153
154     FGAIManager* ai;
155     IC_struct  IC;
156
157     // A list of pointers to AI objects
158     typedef list <SGSharedPtr<FGAIBase> > sm_list_type;
159     typedef sm_list_type::iterator sm_list_iterator;
160     typedef sm_list_type::const_iterator sm_list_const_iterator;
161
162     sm_list_type sm_list;
163
164     void loadAI();
165     void loadSubmodels();
166     void setData(int id, string& path, bool serviceable);
167     double getRange(double lat, double lon, double lat2, double lon2) const;
168
169 };
170
171 #endif // __SYSTEMS_SUBMODEL_HXX