1
0
Fork 0
flightgear/src/Systems/submodel.hxx

95 lines
2.2 KiB
C++
Raw Normal View History

// 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>
2004-08-26 08:38:43 +00:00
#include <vector>
#include <string>
SG_USING_STD(vector);
SG_USING_STD(string);
class SubmodelSystem : public SGSubsystem
{
public:
2004-08-26 08:38:43 +00:00
typedef struct {
SGPropertyNode_ptr trigger;
SGPropertyNode_ptr prop;
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;
David Culp: Silly me. I was starting the timer at zero, so the first tracer didn't fly until 0.25 seconds after pulling the trigger. Now the timer starts at the same value as "delay", so the first round comes out immediately. Also, I've added an optional configuration attribute that allows you to change the ballistics of the submodel. This allows parachutes, or anything else that has ballistics different from a bullet. The attribute is called "eda", which is the equivalent drag area. Default value is 0.007, which gives the same ballistics as the current tracers. Increasing this value gives more drag. A value of 2.0 looks good for a parachute. math stuff ######################################################################## The deceleration of the ballictic object is now given by: [ (rho) (Cd) ] / [ (1/2) (m) ] * A * (V * V) where rho is sea-level air density, and Cd and m are fixed, bullet-like values. So the calculation is: 0.0116918 * A * (V * V) The value "A" is what I'm calling the "eda" (equivalent drag area). ######################################################################## A parachute model will have to be built so that the parachutist's feet are in the forward x-direction. Here is the submodel.xml config I use for "parachutes": <submodel> <name>flares</name> <model>Models/Geometry/flare.ac</model> <trigger>systems/submodels/submodel[0]/trigger</trigger> <speed>0.0</speed> <repeat>true</repeat> <delay>0.85</delay> <count>4</count> <x-offset>0.0</x-offset> <y-offset>0.0</y-offset> <z-offset>-4.0</z-offset> <yaw-offset>0.0</yaw-offset> <pitch-offset>0.0</pitch-offset> <eda>2.0</eda> </submodel>
2004-08-26 16:25:54 +00:00
double drag_area;
double life;
2004-08-26 08:38:43 +00:00
} submodel;
typedef struct {
double lat;
double lon;
double alt;
double azimuth;
double elevation;
double speed;
} IC_struct;
SubmodelSystem ();
~SubmodelSystem ();
2004-08-26 08:38:43 +00:00
void load ();
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);
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;
double x_offset, y_offset, z_offset;
double pitch_offset, yaw_offset;
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_speed_node;
FGAIManager* ai;
2004-08-26 08:38:43 +00:00
IC_struct IC;
};
#endif // __SYSTEMS_SUBMODEL_HXX