]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/submodel.hxx
Vivian MEAZZA:
[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     }
63     submodel;
64
65     typedef struct
66     {
67         double     lat;
68         double     lon;
69         double     alt;
70         double     roll;
71         double     azimuth;
72         double     elevation;
73         double     speed;
74         double     wind_from_east;
75         double     wind_from_north;
76         double     speed_down_fps;
77         double     speed_east_fps;
78         double     speed_north_fps;
79         double     total_speed_down;
80         double     total_speed_east;
81         double     total_speed_north;
82         double     mass;
83         int        id;
84         bool       no_roll;
85     }
86     IC_struct;
87
88     FGSubmodelMgr();
89     ~FGSubmodelMgr();
90
91     void load();
92     void init();
93     void bind();
94     void unbind();
95     void update(double dt);
96     bool release(submodel* sm, double dt);
97     void transform(submodel* sm);
98     void updatelat(double lat);
99
100 private:
101
102     typedef vector <submodel*> submodel_vector_type;
103     typedef submodel_vector_type::const_iterator submodel_vector_iterator;
104
105     submodel_vector_type       submodels;
106     submodel_vector_iterator   submodel_iterator;
107
108     float trans[3][3];
109     float in[3];
110     float out[3];
111
112     double Rx, Ry, Rz;
113     double Sx, Sy, Sz;
114     double Tx, Ty, Tz;
115
116     float cosRx, sinRx;
117     float cosRy, sinRy;
118     float cosRz, sinRz;
119
120     int index;
121
122     double ft_per_deg_longitude;
123     double ft_per_deg_latitude;
124
125     double x_offset, y_offset, z_offset;
126     double pitch_offset, yaw_offset;
127
128     static const double lbs_to_slugs; //conversion factor
129
130     double contrail_altitude;
131
132     SGPropertyNode_ptr _serviceable_node;
133     SGPropertyNode_ptr _user_lat_node;
134     SGPropertyNode_ptr _user_lon_node;
135     SGPropertyNode_ptr _user_heading_node;
136     SGPropertyNode_ptr _user_alt_node;
137     SGPropertyNode_ptr _user_pitch_node;
138     SGPropertyNode_ptr _user_roll_node;
139     SGPropertyNode_ptr _user_yaw_node;
140     SGPropertyNode_ptr _user_alpha_node;
141     SGPropertyNode_ptr _user_speed_node;
142     SGPropertyNode_ptr _user_wind_from_east_node;
143     SGPropertyNode_ptr _user_wind_from_north_node;
144     SGPropertyNode_ptr _user_speed_down_fps_node;
145     SGPropertyNode_ptr _user_speed_east_fps_node;
146     SGPropertyNode_ptr _user_speed_north_fps_node;
147     SGPropertyNode_ptr _contrail_altitude_node;
148     SGPropertyNode_ptr _contrail_trigger;
149
150     FGAIManager* ai;
151     IC_struct  IC;
152
153     // A list of pointers to AI objects
154     typedef list <SGSharedPtr<FGAIBase> > sm_list_type;
155     typedef sm_list_type::iterator sm_list_iterator;
156     typedef sm_list_type::const_iterator sm_list_const_iterator;
157
158     sm_list_type sm_list;
159
160     void loadAI();
161     void loadSubmodels();
162     double getRange(double lat, double lon, double lat2, double lon2) const;
163
164 };
165
166 #endif // __SYSTEMS_SUBMODEL_HXX