1 // submodel.hxx - models a releasable submodel.
2 // Written by Dave Culp, started Aug 2004
4 // This file is in the Public Domain and comes with no warranty.
7 #ifndef __SYSTEMS_SUBMODEL_HXX
8 #define __SYSTEMS_SUBMODEL_HXX 1
11 # error This library requires C++
14 #include <simgear/props/props.hxx>
15 #include <simgear/structure/subsystem_mgr.hxx>
16 #include <simgear/math/SGMath.hxx>
18 #include <Autopilot/inputvalue.hxx>
26 class FGSubmodelMgr : public SGSubsystem, public SGPropertyChangeListener
32 SGPropertyNode_ptr trigger_node;
33 SGPropertyNode_ptr prop;
34 SGPropertyNode_ptr contents_node;
35 SGPropertyNode_ptr submodel_node;
36 SGPropertyNode_ptr speed_node;
49 FGXMLAutopilot::InputValue_ptr yaw_offset;
50 FGXMLAutopilot::InputValue_ptr pitch_offset;
54 FGXMLAutopilot::InputValue_ptr azimuth_error;
55 FGXMLAutopilot::InputValue_ptr elevation_error;
56 FGXMLAutopilot::InputValue_ptr cd_randomness;
57 FGXMLAutopilot::InputValue_ptr life_randomness;
72 std::string impact_report;
76 bool force_stabilised;
78 std::string force_path;
89 double wind_from_east;
90 double wind_from_north;
91 double speed_down_fps;
92 double speed_east_fps;
93 double speed_north_fps;
94 double total_speed_down;
95 double total_speed_east;
96 double total_speed_north;
111 void update(double dt);
112 void updatelat(double lat);
116 typedef std::vector <submodel*> submodel_vector_type;
117 typedef submodel_vector_type::iterator submodel_vector_iterator;
119 submodel_vector_type submodels;
120 submodel_vector_type subsubmodels;
121 submodel_vector_iterator submodel_iterator, subsubmodel_iterator;
125 double ft_per_deg_longitude;
126 double ft_per_deg_latitude;
128 double x_offset, y_offset, z_offset;
129 double pitch_offset, yaw_offset;
135 double _parent_pitch;
137 double _parent_speed;
144 static const double lbs_to_slugs;
146 double contrail_altitude;
153 SGPropertyNode_ptr _serviceable_node;
154 SGPropertyNode_ptr _user_lat_node;
155 SGPropertyNode_ptr _user_lon_node;
156 SGPropertyNode_ptr _user_heading_node;
157 SGPropertyNode_ptr _user_alt_node;
158 SGPropertyNode_ptr _user_pitch_node;
159 SGPropertyNode_ptr _user_roll_node;
160 SGPropertyNode_ptr _user_yaw_node;
161 SGPropertyNode_ptr _user_alpha_node;
162 SGPropertyNode_ptr _user_speed_node;
163 SGPropertyNode_ptr _user_wind_from_east_node;
164 SGPropertyNode_ptr _user_wind_from_north_node;
165 SGPropertyNode_ptr _user_speed_down_fps_node;
166 SGPropertyNode_ptr _user_speed_east_fps_node;
167 SGPropertyNode_ptr _user_speed_north_fps_node;
168 SGPropertyNode_ptr _contrail_altitude_node;
169 SGPropertyNode_ptr _contrail_trigger;
170 SGPropertyNode_ptr _count_node;
171 SGPropertyNode_ptr _trigger_node;
172 SGPropertyNode_ptr props;
173 SGPropertyNode_ptr _model_added_node;
174 SGPropertyNode_ptr _path_node;
175 SGPropertyNode_ptr _selected_ac;
179 // Helper to retrieve the AI manager, if it currently exists
180 FGAIManager* aiManager();
183 void loadSubmodels();
184 void setData(int id, const std::string& path, bool serviceable, const std::string& property_path, submodel_vector_type& models);
185 void valueChanged (SGPropertyNode *);
186 void transform(submodel *);
187 void setParentNode(int parent_id);
188 bool release(submodel *, double dt);
194 SGVec3d getCartOffsetPos() const;
199 #endif // __SYSTEMS_SUBMODEL_HXX