1 // FGAIBallistic.hxx - AIBase derived class creates an AI ballistic object
3 // Written by David Culp, started November 2003.
4 // - davidculp2@comcast.net
6 // With major additions by Vivian Meazza, Feb 2008
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifndef _FG_AIBALLISTIC_HXX
23 #define _FG_AIBALLISTIC_HXX
27 #include <simgear/structure/SGSharedPtr.hxx>
28 #include <simgear/scene/material/mat.hxx>
31 #include "AIManager.hxx"
37 class FGAIBallistic : public FGAIBase {
41 FGAIBallistic(object_type ot = otBallistic);
44 void readFromScenario(SGPropertyNode* scFileNode);
46 bool init(bool search_in_AI_path=false);
48 virtual void unbind();
50 void update(double dt);
52 FGAIBallistic *ballistic;
56 void setAzimuth( double az );
57 void setElevation( double el );
58 void setRoll( double rl );
59 void setStabilisation( bool val );
60 void setDragArea( double a );
61 void setLife( double seconds );
62 void setBuoyancy( double fpss );
63 void setWind_from_east( double fps );
64 void setWind_from_north( double fps );
65 void setWind( bool val );
66 void setCd( double c );
67 void setMass( double m );
68 void setWeight( double w );
69 void setNoRoll( bool nr );
70 void setRandom( bool r );
71 void setName(const string&);
72 void setCollision(bool c);
73 void setExpiry(bool e);
74 void setImpact(bool i);
75 void setImpactReportNode(const string&);
76 void setContentsNode(const string&);
77 void setFuseRange(double f);
78 void setSMPath(const string&);
80 void setSubmodel(const string&);
81 void setExternalForce( bool f );
82 void setForcePath(const string&);
83 void setForceStabilisation( bool val );
84 void setGroundOffset(double g);
85 void setLoadOffset(double l);
86 void setSlaved(bool s);
87 void setSlavedLoad(bool s);
89 void setPch (double e, double dt, double c);
90 void setHdg (double az, double dt, double c);
91 void setBnk(double r, double dt, double c);
92 void setHt(double h, double dt, double c);
93 void setHitchVelocity(double dt);
94 void setFormate(bool f);
96 double _getTime() const;
97 double getRelBrgHitchToUser() const;
98 double getElevHitchToUser() const;
99 double getLoadOffset() const;
100 double getContents();
102 SGVec3d getCartHitchPos() const;
105 bool getSlaved() const;
106 bool getSlavedLoad() const;
108 virtual const char* getTypeString(void) const { return "ballistic"; }
109 static const double slugs_to_kgs; //conversion factor
110 static const double slugs_to_lbs; //conversion factor
112 SGPropertyNode_ptr _force_node;
113 SGPropertyNode_ptr _force_azimuth_node;
114 SGPropertyNode_ptr _force_elevation_node;
119 double _ht_agl_ft; // height above ground level
120 double _azimuth; // degrees true
121 double _elevation; // degrees
122 double _rotation; // degrees
126 void setTgtXOffset(double x);
127 void setTgtYOffset(double y);
128 void setTgtZOffset(double z);
129 void setTgtOffsets(double dt, double c);
131 double getTgtXOffset() const;
132 double getTgtYOffset() const;
133 double getTgtZOffset() const;
135 double _tgt_x_offset;
136 double _tgt_y_offset;
137 double _tgt_z_offset;
138 double _elapsed_time;
142 virtual void reinit() { init(); }
144 bool _aero_stabilised; // if true, object will align with trajectory
145 double _drag_area; // equivalent drag area in ft2
146 double _life_timer; // seconds
147 double _gravity; // fps^2
148 double _buoyancy; // fps^2
149 double _wind_from_east; // fps
150 double _wind_from_north; // fps
151 bool _wind; // if true, local wind will be applied to object
152 double _Cd; // drag coefficient
153 double _mass; // slugs
154 bool _random; // modifier for Cd
155 double _load_resistance; // ground load resistanc N/m^2
156 double _frictionFactor; // dimensionless modifier for Coefficient of Friction
157 bool _solid; // if true ground is solid for FDMs
158 double _elevation_m; // ground elevation in meters
159 bool _force_stabilised;// if true, object will align to external force
160 bool _slave_to_ac; // if true, object will be slaved to the parent ac pos and orientation
161 bool _slave_load_to_ac;// if true, object will be slaved to the parent ac pos
162 double _contents_lb; // contents of the object
163 double _weight_lb; // weight of the object (no contents if appropriate) (lbs)
165 bool _report_collision; // if true a collision point with AI Objects is calculated
166 bool _report_impact; // if true an impact point on the terrain is calculated
167 bool _external_force; // if true then apply external force
170 SGPropertyNode_ptr _impact_report_node; // report node for impact and collision
171 SGPropertyNode_ptr _contents_node; // report node for impact and collision
183 const SGMaterial* _material;
185 void handle_collision();
186 void handle_expiry();
187 void handle_impact();
188 void report_impact(double elevation, const FGAIBase *target = 0);
189 void slaveToAC(double dt);
190 void setContents(double c);
191 void formateToAC(double dt);
193 SGVec3d getCartUserPos() const;
195 double getDistanceLoadToHitch() const;
196 double getElevLoadToHitch() const;
197 double getBearingLoadToHitch() const;
198 double getRecip(double az);
199 double getMass() const;
202 double _ground_offset;
207 SGVec3d _oldcarthitchPos;
213 #endif // _FG_AIBALLISTIC_HXX