1
0
Fork 0
flightgear/src/Systems/submodel.hxx
ehofman 161912ea4c 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

57 lines
1.3 KiB
C++

// 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>
#include <AIModel/AIManager.hxx>
class SubmodelSystem : public SGSubsystem
{
public:
SubmodelSystem ();
~SubmodelSystem ();
void init ();
void bind ();
void unbind ();
void update (double dt);
bool release (double dt);
private:
double x_offset, y_offset, z_offset;
double pitch_offset, yaw_offset;
SGPropertyNode_ptr _serviceable_node;
SGPropertyNode_ptr _trigger_node;
SGPropertyNode_ptr _amount_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_speed_node;
double elapsed_time;
FGAIManager* ai;
double initial_velocity;
bool firing;
};
#endif // __SYSTEMS_SUBMODEL_HXX