2004-09-27 14:24:20 +00:00
|
|
|
// FGAIBallistic.hxx - AIBase derived class creates an AI ballistic object
|
2003-11-28 15:48:05 +00:00
|
|
|
//
|
|
|
|
// Written by David Culp, started November 2003.
|
|
|
|
// - davidculp2@comcast.net
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
2006-02-21 01:16:04 +00:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-11-28 15:48:05 +00:00
|
|
|
|
|
|
|
#ifndef _FG_AIBALLISTIC_HXX
|
|
|
|
#define _FG_AIBALLISTIC_HXX
|
|
|
|
|
2007-06-07 16:30:26 +00:00
|
|
|
#include <math.h>
|
|
|
|
#include <vector>
|
|
|
|
#include <simgear/structure/SGSharedPtr.hxx>
|
|
|
|
|
|
|
|
|
2003-11-28 15:48:05 +00:00
|
|
|
#include "AIManager.hxx"
|
|
|
|
#include "AIBase.hxx"
|
|
|
|
|
2007-06-07 16:30:26 +00:00
|
|
|
SG_USING_STD(vector);
|
|
|
|
SG_USING_STD(list);
|
2003-11-28 15:48:05 +00:00
|
|
|
|
|
|
|
class FGAIBallistic : public FGAIBase {
|
2004-09-22 08:47:05 +00:00
|
|
|
|
2003-11-28 15:48:05 +00:00
|
|
|
public:
|
2004-09-22 08:47:05 +00:00
|
|
|
|
2006-02-11 13:16:56 +00:00
|
|
|
FGAIBallistic();
|
2003-11-28 15:48:05 +00:00
|
|
|
~FGAIBallistic();
|
2004-09-22 08:47:05 +00:00
|
|
|
|
2006-02-11 13:16:56 +00:00
|
|
|
void readFromScenario(SGPropertyNode* scFileNode);
|
|
|
|
|
2007-01-13 16:04:28 +00:00
|
|
|
bool init(bool search_in_AI_path=false);
|
2003-12-21 20:12:55 +00:00
|
|
|
virtual void bind();
|
|
|
|
virtual void unbind();
|
2007-03-30 22:51:52 +00:00
|
|
|
|
2003-11-28 15:48:05 +00:00
|
|
|
void update(double dt);
|
|
|
|
|
|
|
|
void setAzimuth( double az );
|
|
|
|
void setElevation( double el );
|
2004-09-22 08:47:05 +00:00
|
|
|
void setRoll( double rl );
|
2004-10-28 08:29:15 +00:00
|
|
|
void setStabilisation( bool val );
|
2004-08-26 16:25:54 +00:00
|
|
|
void setDragArea( double a );
|
2004-08-30 09:11:59 +00:00
|
|
|
void setLife( double seconds );
|
2004-09-05 09:45:34 +00:00
|
|
|
void setBuoyancy( double fpss );
|
2004-09-08 14:02:25 +00:00
|
|
|
void setWind_from_east( double fps );
|
|
|
|
void setWind_from_north( double fps );
|
|
|
|
void setWind( bool val );
|
2004-09-22 08:47:05 +00:00
|
|
|
void setCd( double c );
|
2004-09-27 14:24:20 +00:00
|
|
|
void setMass( double m );
|
2007-03-30 22:51:52 +00:00
|
|
|
void setNoRoll( bool nr );
|
|
|
|
void setRandom( bool r );
|
|
|
|
void setName(const string&);
|
2007-06-07 16:30:26 +00:00
|
|
|
void setCollision(bool c);
|
2007-05-15 16:19:11 +00:00
|
|
|
void setImpact(bool i);
|
2007-05-15 19:45:41 +00:00
|
|
|
void setImpactReportNode(const string&);
|
2007-06-07 16:30:26 +00:00
|
|
|
void setFuseRange(double f);
|
|
|
|
void setSMPath(const string&);
|
|
|
|
void setSubID(int i);
|
|
|
|
void setSubmodel(const string&);
|
|
|
|
|
2004-09-08 14:02:25 +00:00
|
|
|
|
|
|
|
double _getTime() const;
|
2004-09-22 08:47:05 +00:00
|
|
|
|
2006-02-11 13:16:56 +00:00
|
|
|
virtual const char* getTypeString(void) const { return "ballistic"; }
|
2007-05-15 16:19:11 +00:00
|
|
|
static const double slugs_to_kgs; //conversion factor
|
2006-02-11 13:16:56 +00:00
|
|
|
|
2003-11-28 15:48:05 +00:00
|
|
|
private:
|
|
|
|
|
2007-05-15 17:22:49 +00:00
|
|
|
double _azimuth; // degrees true
|
|
|
|
double _elevation; // degrees
|
|
|
|
double _rotation; // degrees
|
|
|
|
bool _aero_stabilised; // if true, object will align with trajectory
|
|
|
|
double _drag_area; // equivalent drag area in ft2
|
|
|
|
double _life_timer; // seconds
|
|
|
|
double _gravity; // fps2
|
|
|
|
double _buoyancy; // fps2
|
|
|
|
double _wind_from_east; // fps
|
|
|
|
double _wind_from_north; // fps
|
|
|
|
bool _wind; // if true, local wind will be applied to object
|
|
|
|
double _Cd; // drag coefficient
|
|
|
|
double _mass; // slugs
|
|
|
|
bool _random; // modifier for Cd
|
|
|
|
double _ht_agl_ft; // height above ground level
|
|
|
|
double _load_resistance; // ground load resistanc N/m^2
|
|
|
|
bool _solid; // if true ground is solid for FDMs
|
2007-06-07 16:30:26 +00:00
|
|
|
|
|
|
|
bool _report_collision; // if true a collision point with AI Objects is calculated
|
|
|
|
bool _report_impact; // if true an impact point on the terrain is calculated
|
|
|
|
|
|
|
|
SGPropertyNode_ptr _impact_report_node; // report node for impact and collision
|
|
|
|
|
|
|
|
double _fuse_range;
|
|
|
|
|
|
|
|
double _dt_count;
|
|
|
|
double _next_run;
|
2007-05-15 19:45:41 +00:00
|
|
|
|
2007-05-15 17:22:49 +00:00
|
|
|
string _name;
|
2007-06-07 16:30:26 +00:00
|
|
|
string _path;
|
|
|
|
string _submodel;
|
2004-09-22 08:47:05 +00:00
|
|
|
|
2003-11-28 15:48:05 +00:00
|
|
|
void Run(double dt);
|
2007-06-07 16:30:26 +00:00
|
|
|
void handle_collision();
|
2007-05-15 16:19:11 +00:00
|
|
|
void handle_impact();
|
|
|
|
|
2007-06-07 16:30:26 +00:00
|
|
|
void report_impact(double elevation, const FGAIBase *target = 0);
|
|
|
|
|
2003-11-28 15:48:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _FG_AIBALLISTIC_HXX
|