David Culp:
Right now the code is not very configurable, and there is only one submodel per airplane possible. It is implemented as an SGSubSystem, just like the electrics, vacuum, etc. systems. To make it work you need to make a release binding like this (for my joystick trigger):
<button n="0">
<desc>Trigger</desc>
<binding>
<command>property-assign</command>
<property>/systems/submodel/trigger</property>
<value type="bool">true</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/systems/submodel/trigger</property>
<value type="bool">false</value>
</binding>
</mod-up>
</button>
Then, each airplane that uses the system should have something like this added to its *-set.xml file (note that this does *not* go within the <sim></sim> tags):
<systems>
<submodel>
<serviceable type="bool">true</serviceable>
<amount type="int">70</amount>
</submodel>
</systems>
Future improvements will include:
1) more configurability, so the user can create multiple submodels, and can assign them different locations, and pitch and yaw adjustments, and nitial velocity.
2) sound?
3) a more accurate calculation of the submodels location at any pitch/roll/yaw.
4) a way to pre-load the model, so the AI code doesn't have to parse the model every time it creates an instance.
I think that's all of it.
2004-08-22 16:22:18 +00:00
|
|
|
// submodel.hxx - models a releasable submodel.
|
|
|
|
// Written by Dave Culp, started Aug 2004
|
|
|
|
//
|
|
|
|
// This file is in the Public Domain and comes with no warranty.
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __SYSTEMS_SUBMODEL_HXX
|
|
|
|
#define __SYSTEMS_SUBMODEL_HXX 1
|
|
|
|
|
|
|
|
#ifndef __cplusplus
|
|
|
|
# error This library requires C++
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <simgear/props/props.hxx>
|
|
|
|
#include <simgear/structure/subsystem_mgr.hxx>
|
2010-10-28 15:10:37 +01:00
|
|
|
#include <simgear/math/SGMath.hxx>
|
|
|
|
|
2004-08-26 08:38:43 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2007-06-07 16:30:26 +00:00
|
|
|
|
2007-03-30 22:51:52 +00:00
|
|
|
class FGAIBase;
|
2010-10-28 15:10:37 +01:00
|
|
|
class FGAIManager;
|
David Culp:
Right now the code is not very configurable, and there is only one submodel per airplane possible. It is implemented as an SGSubSystem, just like the electrics, vacuum, etc. systems. To make it work you need to make a release binding like this (for my joystick trigger):
<button n="0">
<desc>Trigger</desc>
<binding>
<command>property-assign</command>
<property>/systems/submodel/trigger</property>
<value type="bool">true</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/systems/submodel/trigger</property>
<value type="bool">false</value>
</binding>
</mod-up>
</button>
Then, each airplane that uses the system should have something like this added to its *-set.xml file (note that this does *not* go within the <sim></sim> tags):
<systems>
<submodel>
<serviceable type="bool">true</serviceable>
<amount type="int">70</amount>
</submodel>
</systems>
Future improvements will include:
1) more configurability, so the user can create multiple submodels, and can assign them different locations, and pitch and yaw adjustments, and nitial velocity.
2) sound?
3) a more accurate calculation of the submodels location at any pitch/roll/yaw.
4) a way to pre-load the model, so the AI code doesn't have to parse the model every time it creates an instance.
I think that's all of it.
2004-08-22 16:22:18 +00:00
|
|
|
|
2010-08-14 13:39:30 +01:00
|
|
|
class FGSubmodelMgr : public SGSubsystem, public SGPropertyChangeListener
|
David Culp:
Right now the code is not very configurable, and there is only one submodel per airplane possible. It is implemented as an SGSubSystem, just like the electrics, vacuum, etc. systems. To make it work you need to make a release binding like this (for my joystick trigger):
<button n="0">
<desc>Trigger</desc>
<binding>
<command>property-assign</command>
<property>/systems/submodel/trigger</property>
<value type="bool">true</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/systems/submodel/trigger</property>
<value type="bool">false</value>
</binding>
</mod-up>
</button>
Then, each airplane that uses the system should have something like this added to its *-set.xml file (note that this does *not* go within the <sim></sim> tags):
<systems>
<submodel>
<serviceable type="bool">true</serviceable>
<amount type="int">70</amount>
</submodel>
</systems>
Future improvements will include:
1) more configurability, so the user can create multiple submodels, and can assign them different locations, and pitch and yaw adjustments, and nitial velocity.
2) sound?
3) a more accurate calculation of the submodels location at any pitch/roll/yaw.
4) a way to pre-load the model, so the AI code doesn't have to parse the model every time it creates an instance.
I think that's all of it.
2004-08-22 16:22:18 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2007-06-07 22:48:37 +00:00
|
|
|
typedef struct {
|
2007-03-30 22:51:52 +00:00
|
|
|
SGPropertyNode_ptr trigger_node;
|
|
|
|
SGPropertyNode_ptr prop;
|
|
|
|
SGPropertyNode_ptr contents_node;
|
|
|
|
SGPropertyNode_ptr submodel_node;
|
|
|
|
SGPropertyNode_ptr speed_node;
|
|
|
|
|
2010-10-28 15:10:37 +01:00
|
|
|
std::string name;
|
|
|
|
std::string model;
|
2007-03-30 22:51:52 +00:00
|
|
|
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;
|
|
|
|
double drag_area;
|
|
|
|
double life;
|
|
|
|
double buoyancy;
|
2010-08-14 13:39:30 +01:00
|
|
|
double randomness;
|
2007-03-30 22:51:52 +00:00
|
|
|
bool wind;
|
|
|
|
bool first_time;
|
|
|
|
double cd;
|
|
|
|
double weight;
|
2010-08-29 00:00:09 +01:00
|
|
|
double mass;
|
2007-03-30 22:51:52 +00:00
|
|
|
double contents;
|
|
|
|
bool aero_stabilised;
|
|
|
|
int id;
|
|
|
|
bool no_roll;
|
|
|
|
bool serviceable;
|
2010-08-14 13:39:30 +01:00
|
|
|
bool random;
|
2007-06-07 16:30:26 +00:00
|
|
|
bool collision;
|
2010-08-14 13:39:30 +01:00
|
|
|
bool expiry;
|
2007-05-15 16:19:11 +00:00
|
|
|
bool impact;
|
2010-10-28 15:10:37 +01:00
|
|
|
std::string impact_report;
|
2007-06-07 16:30:26 +00:00
|
|
|
double fuse_range;
|
2010-10-28 15:10:37 +01:00
|
|
|
std::string submodel;
|
2007-06-07 16:30:26 +00:00
|
|
|
int sub_id;
|
2009-01-18 21:56:55 +00:00
|
|
|
bool force_stabilised;
|
2007-12-21 23:37:05 +00:00
|
|
|
bool ext_force;
|
2010-10-28 15:10:37 +01:00
|
|
|
std::string force_path;
|
2007-06-07 22:48:37 +00:00
|
|
|
} submodel;
|
2007-03-30 22:51:52 +00:00
|
|
|
|
2007-06-07 22:48:37 +00:00
|
|
|
typedef struct {
|
2007-03-30 22:51:52 +00:00
|
|
|
double lat;
|
|
|
|
double lon;
|
|
|
|
double alt;
|
|
|
|
double roll;
|
|
|
|
double azimuth;
|
|
|
|
double elevation;
|
|
|
|
double speed;
|
|
|
|
double wind_from_east;
|
|
|
|
double wind_from_north;
|
|
|
|
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;
|
2010-08-29 00:00:09 +01:00
|
|
|
int parent_id;
|
2007-06-07 22:48:37 +00:00
|
|
|
} IC_struct;
|
2007-03-30 22:51:52 +00:00
|
|
|
|
|
|
|
FGSubmodelMgr();
|
|
|
|
~FGSubmodelMgr();
|
|
|
|
|
|
|
|
void load();
|
|
|
|
void init();
|
2007-04-27 11:02:39 +00:00
|
|
|
void postinit();
|
2007-03-30 22:51:52 +00:00
|
|
|
void bind();
|
|
|
|
void unbind();
|
|
|
|
void update(double dt);
|
|
|
|
void updatelat(double lat);
|
David Culp:
Right now the code is not very configurable, and there is only one submodel per airplane possible. It is implemented as an SGSubSystem, just like the electrics, vacuum, etc. systems. To make it work you need to make a release binding like this (for my joystick trigger):
<button n="0">
<desc>Trigger</desc>
<binding>
<command>property-assign</command>
<property>/systems/submodel/trigger</property>
<value type="bool">true</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/systems/submodel/trigger</property>
<value type="bool">false</value>
</binding>
</mod-up>
</button>
Then, each airplane that uses the system should have something like this added to its *-set.xml file (note that this does *not* go within the <sim></sim> tags):
<systems>
<submodel>
<serviceable type="bool">true</serviceable>
<amount type="int">70</amount>
</submodel>
</systems>
Future improvements will include:
1) more configurability, so the user can create multiple submodels, and can assign them different locations, and pitch and yaw adjustments, and nitial velocity.
2) sound?
3) a more accurate calculation of the submodels location at any pitch/roll/yaw.
4) a way to pre-load the model, so the AI code doesn't have to parse the model every time it creates an instance.
I think that's all of it.
2004-08-22 16:22:18 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2010-10-28 15:10:37 +01:00
|
|
|
typedef std::vector <submodel*> submodel_vector_type;
|
2007-06-07 22:48:37 +00:00
|
|
|
typedef submodel_vector_type::iterator submodel_vector_iterator;
|
2004-08-26 08:38:43 +00:00
|
|
|
|
|
|
|
submodel_vector_type submodels;
|
2007-06-07 16:30:26 +00:00
|
|
|
submodel_vector_type subsubmodels;
|
|
|
|
submodel_vector_iterator submodel_iterator, subsubmodel_iterator;
|
2004-08-26 08:38:43 +00:00
|
|
|
|
2004-09-07 19:10:10 +00:00
|
|
|
float trans[3][3];
|
|
|
|
float in[3];
|
|
|
|
float out[3];
|
|
|
|
|
2008-02-15 11:06:27 +00:00
|
|
|
//double Rx, Ry, Rz;
|
|
|
|
//double Sx, Sy, Sz;
|
|
|
|
//double Tx, Ty, Tz;
|
2004-09-07 19:10:10 +00:00
|
|
|
|
|
|
|
float cosRx, sinRx;
|
|
|
|
float cosRy, sinRy;
|
|
|
|
float cosRz, sinRz;
|
|
|
|
|
2007-03-30 22:51:52 +00:00
|
|
|
int index;
|
|
|
|
|
2004-09-07 19:10:10 +00:00
|
|
|
double ft_per_deg_longitude;
|
|
|
|
double ft_per_deg_latitude;
|
2004-08-26 08:38:43 +00:00
|
|
|
|
David Culp:
Right now the code is not very configurable, and there is only one submodel per airplane possible. It is implemented as an SGSubSystem, just like the electrics, vacuum, etc. systems. To make it work you need to make a release binding like this (for my joystick trigger):
<button n="0">
<desc>Trigger</desc>
<binding>
<command>property-assign</command>
<property>/systems/submodel/trigger</property>
<value type="bool">true</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/systems/submodel/trigger</property>
<value type="bool">false</value>
</binding>
</mod-up>
</button>
Then, each airplane that uses the system should have something like this added to its *-set.xml file (note that this does *not* go within the <sim></sim> tags):
<systems>
<submodel>
<serviceable type="bool">true</serviceable>
<amount type="int">70</amount>
</submodel>
</systems>
Future improvements will include:
1) more configurability, so the user can create multiple submodels, and can assign them different locations, and pitch and yaw adjustments, and nitial velocity.
2) sound?
3) a more accurate calculation of the submodels location at any pitch/roll/yaw.
4) a way to pre-load the model, so the AI code doesn't have to parse the model every time it creates an instance.
I think that's all of it.
2004-08-22 16:22:18 +00:00
|
|
|
double x_offset, y_offset, z_offset;
|
|
|
|
double pitch_offset, yaw_offset;
|
|
|
|
|
2007-06-07 16:30:26 +00:00
|
|
|
double _parent_lat;
|
|
|
|
double _parent_lon;
|
|
|
|
double _parent_elev;
|
|
|
|
double _parent_hdg;
|
|
|
|
double _parent_pitch;
|
|
|
|
double _parent_roll;
|
|
|
|
double _parent_speed;
|
2010-08-29 00:00:09 +01:00
|
|
|
double _parent_ID;
|
|
|
|
|
2010-08-14 13:39:30 +01:00
|
|
|
double _x_offset;
|
2010-07-28 22:20:50 +01:00
|
|
|
double _y_offset;
|
|
|
|
double _z_offset;
|
|
|
|
|
2007-06-07 16:30:26 +00:00
|
|
|
|
2004-09-22 08:47:05 +00:00
|
|
|
static const double lbs_to_slugs; //conversion factor
|
|
|
|
|
2004-11-07 14:46:21 +00:00
|
|
|
double contrail_altitude;
|
|
|
|
|
2007-06-07 16:30:26 +00:00
|
|
|
bool _impact;
|
|
|
|
bool _hit;
|
2010-08-14 13:39:30 +01:00
|
|
|
bool _expiry;
|
|
|
|
bool _found_sub;
|
2007-06-07 16:30:26 +00:00
|
|
|
|
2006-06-11 10:21:10 +00:00
|
|
|
SGPropertyNode_ptr _serviceable_node;
|
|
|
|
SGPropertyNode_ptr _user_lat_node;
|
|
|
|
SGPropertyNode_ptr _user_lon_node;
|
|
|
|
SGPropertyNode_ptr _user_heading_node;
|
|
|
|
SGPropertyNode_ptr _user_alt_node;
|
|
|
|
SGPropertyNode_ptr _user_pitch_node;
|
|
|
|
SGPropertyNode_ptr _user_roll_node;
|
|
|
|
SGPropertyNode_ptr _user_yaw_node;
|
|
|
|
SGPropertyNode_ptr _user_alpha_node;
|
|
|
|
SGPropertyNode_ptr _user_speed_node;
|
|
|
|
SGPropertyNode_ptr _user_wind_from_east_node;
|
|
|
|
SGPropertyNode_ptr _user_wind_from_north_node;
|
|
|
|
SGPropertyNode_ptr _user_speed_down_fps_node;
|
|
|
|
SGPropertyNode_ptr _user_speed_east_fps_node;
|
|
|
|
SGPropertyNode_ptr _user_speed_north_fps_node;
|
|
|
|
SGPropertyNode_ptr _contrail_altitude_node;
|
|
|
|
SGPropertyNode_ptr _contrail_trigger;
|
2007-06-07 16:30:26 +00:00
|
|
|
SGPropertyNode_ptr _count_node;
|
|
|
|
SGPropertyNode_ptr _trigger_node;
|
|
|
|
SGPropertyNode_ptr props;
|
2010-08-14 13:39:30 +01:00
|
|
|
SGPropertyNode_ptr _model_added_node;
|
|
|
|
SGPropertyNode_ptr _path_node;
|
2010-08-29 00:00:09 +01:00
|
|
|
SGPropertyNode_ptr _selected_ac;
|
2010-08-14 13:39:30 +01:00
|
|
|
|
2004-08-26 08:38:43 +00:00
|
|
|
IC_struct IC;
|
2010-10-28 15:10:37 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper to retrieve the AI manager, if it currently exists
|
|
|
|
*/
|
|
|
|
FGAIManager* aiManager();
|
|
|
|
|
2007-03-30 22:51:52 +00:00
|
|
|
void loadAI();
|
|
|
|
void loadSubmodels();
|
2010-10-28 15:10:37 +01:00
|
|
|
void setData(int id, std::string& path, bool serviceable);
|
|
|
|
void setSubData(int id, std::string& path, bool serviceable);
|
2007-06-07 16:30:26 +00:00
|
|
|
void valueChanged (SGPropertyNode *);
|
2007-06-07 22:48:37 +00:00
|
|
|
void transform(submodel *);
|
2010-08-29 00:00:09 +01:00
|
|
|
void setParentNode(int parent_id);
|
2007-06-07 16:30:26 +00:00
|
|
|
|
2007-06-07 22:48:37 +00:00
|
|
|
bool release(submodel *, double dt);
|
2007-06-07 16:30:26 +00:00
|
|
|
|
2004-09-22 08:47:05 +00:00
|
|
|
|
2007-06-07 16:30:26 +00:00
|
|
|
int _count;
|
2010-08-14 13:39:30 +01:00
|
|
|
|
|
|
|
SGGeod userpos;
|
|
|
|
SGGeod offsetpos;
|
|
|
|
SGVec3d getCartOffsetPos() const;
|
|
|
|
void setOffsetPos();
|
2007-06-07 16:30:26 +00:00
|
|
|
|
2007-03-30 22:51:52 +00:00
|
|
|
};
|
2004-09-27 14:24:20 +00:00
|
|
|
|
2007-03-30 22:51:52 +00:00
|
|
|
#endif // __SYSTEMS_SUBMODEL_HXX
|