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>
|
2004-09-07 09:53:23 +00:00
|
|
|
#include <AIModel/AIBase.hxx>
|
2004-08-26 08:38:43 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
SG_USING_STD(vector);
|
|
|
|
SG_USING_STD(string);
|
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
|
|
|
|
|
|
|
|
2004-10-22 09:58:24 +00:00
|
|
|
class FGSubmodelMgr : public SGSubsystem
|
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:
|
|
|
|
|
2004-09-07 19:10:10 +00:00
|
|
|
|
2004-08-26 08:38:43 +00:00
|
|
|
typedef struct {
|
2004-09-07 19:10:10 +00:00
|
|
|
SGPropertyNode* trigger;
|
|
|
|
SGPropertyNode* prop;
|
2004-09-27 14:24:20 +00:00
|
|
|
SGPropertyNode* contents_node;
|
2004-09-22 08:47:05 +00:00
|
|
|
|
2004-08-26 08:38:43 +00:00
|
|
|
string name;
|
|
|
|
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;
|
2004-08-26 16:25:54 +00:00
|
|
|
double drag_area;
|
2004-08-30 09:11:59 +00:00
|
|
|
double life;
|
2004-09-01 21:05:04 +00:00
|
|
|
double buoyancy;
|
2004-09-05 09:45:34 +00:00
|
|
|
bool wind;
|
2004-09-09 08:40:08 +00:00
|
|
|
bool first_time;
|
2004-09-22 08:47:05 +00:00
|
|
|
double cd;
|
|
|
|
double weight;
|
2004-09-27 14:24:20 +00:00
|
|
|
double contents;
|
2004-08-26 08:38:43 +00:00
|
|
|
} submodel;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
double lat;
|
|
|
|
double lon;
|
|
|
|
double alt;
|
2004-09-07 19:10:10 +00:00
|
|
|
double roll;
|
2004-08-26 08:38:43 +00:00
|
|
|
double azimuth;
|
|
|
|
double elevation;
|
|
|
|
double speed;
|
2004-09-05 09:45:34 +00:00
|
|
|
double wind_from_east;
|
|
|
|
double wind_from_north;
|
2004-09-14 08:27:55 +00:00
|
|
|
double speed_down_fps;
|
|
|
|
double speed_east_fps;
|
|
|
|
double speed_north_fps;
|
|
|
|
double total_speed_down;
|
|
|
|
double total_speed_east;
|
|
|
|
double total_speed_north;
|
2004-09-22 08:47:05 +00:00
|
|
|
double mass;
|
2004-08-26 08:38:43 +00:00
|
|
|
} IC_struct;
|
|
|
|
|
2004-10-22 09:58:24 +00:00
|
|
|
FGSubmodelMgr ();
|
|
|
|
~FGSubmodelMgr ();
|
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
|
|
|
|
2004-08-26 08:38:43 +00:00
|
|
|
void load ();
|
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
|
|
|
void init ();
|
|
|
|
void bind ();
|
|
|
|
void unbind ();
|
|
|
|
void update (double dt);
|
2004-08-26 08:38:43 +00:00
|
|
|
bool release (submodel* sm, double dt);
|
|
|
|
void transform (submodel* sm);
|
2004-09-07 19:10:10 +00:00
|
|
|
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:
|
|
|
|
|
2004-08-26 08:38:43 +00:00
|
|
|
typedef vector <submodel*> submodel_vector_type;
|
|
|
|
typedef submodel_vector_type::iterator submodel_vector_iterator;
|
|
|
|
|
|
|
|
submodel_vector_type submodels;
|
|
|
|
submodel_vector_iterator submodel_iterator;
|
|
|
|
|
2004-09-07 19:10:10 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2004-09-22 08:47:05 +00:00
|
|
|
static const double lbs_to_slugs; //conversion factor
|
|
|
|
|
2004-09-07 19:10:10 +00:00
|
|
|
SGPropertyNode* _serviceable_node;
|
|
|
|
SGPropertyNode* _user_lat_node;
|
|
|
|
SGPropertyNode* _user_lon_node;
|
|
|
|
SGPropertyNode* _user_heading_node;
|
|
|
|
SGPropertyNode* _user_alt_node;
|
|
|
|
SGPropertyNode* _user_pitch_node;
|
|
|
|
SGPropertyNode* _user_roll_node;
|
|
|
|
SGPropertyNode* _user_yaw_node;
|
2004-09-09 08:40:08 +00:00
|
|
|
SGPropertyNode* _user_alpha_node;
|
2004-09-07 19:10:10 +00:00
|
|
|
SGPropertyNode* _user_speed_node;
|
|
|
|
SGPropertyNode* _user_wind_from_east_node;
|
|
|
|
SGPropertyNode* _user_wind_from_north_node;
|
2004-09-22 08:47:05 +00:00
|
|
|
SGPropertyNode* _user_speed_down_fps_node;
|
|
|
|
SGPropertyNode* _user_speed_east_fps_node;
|
|
|
|
SGPropertyNode* _user_speed_north_fps_node;
|
|
|
|
|
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
|
|
|
FGAIManager* ai;
|
2004-08-26 08:38:43 +00:00
|
|
|
IC_struct IC;
|
2004-09-09 08:40:08 +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
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __SYSTEMS_SUBMODEL_HXX
|
2004-09-17 16:32:58 +00:00
|
|
|
|
2004-09-22 08:47:05 +00:00
|
|
|
|
2004-09-27 14:24:20 +00:00
|
|
|
|