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
|
|
|
|
//
|
2008-02-15 11:06:27 +00:00
|
|
|
// With major additions by Vivian Meazza, Feb 2008
|
|
|
|
//
|
2003-11-28 15:48:05 +00:00
|
|
|
// 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>
|
2008-01-04 22:31:18 +00:00
|
|
|
#include <simgear/scene/material/mat.hxx>
|
2007-06-07 16:30:26 +00:00
|
|
|
|
|
|
|
|
2003-11-28 15:48:05 +00:00
|
|
|
#include "AIManager.hxx"
|
|
|
|
#include "AIBase.hxx"
|
|
|
|
|
2008-07-27 16:25:13 +00:00
|
|
|
using std::vector;
|
|
|
|
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
|
|
|
|
2008-02-15 11:06:27 +00:00
|
|
|
FGAIBallistic(object_type ot = otBallistic);
|
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);
|
|
|
|
|
2008-02-15 11:06:27 +00:00
|
|
|
FGAIBallistic *ballistic;
|
|
|
|
|
|
|
|
void Run(double dt);
|
|
|
|
|
2003-11-28 15:48:05 +00:00
|
|
|
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 );
|
2008-02-15 11:06:27 +00:00
|
|
|
void setWeight( double w );
|
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);
|
2010-07-16 22:05:05 +00:00
|
|
|
void setExpiry(bool e);
|
2007-05-15 16:19:11 +00:00
|
|
|
void setImpact(bool i);
|
2007-05-15 19:45:41 +00:00
|
|
|
void setImpactReportNode(const string&);
|
2008-02-15 11:06:27 +00:00
|
|
|
void setContentsNode(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&);
|
2007-12-21 23:37:05 +00:00
|
|
|
void setExternalForce( bool f );
|
|
|
|
void setForcePath(const string&);
|
2008-01-04 22:31:18 +00:00
|
|
|
void setForceStabilisation( bool val );
|
2008-02-15 11:06:27 +00:00
|
|
|
void setGroundOffset(double g);
|
|
|
|
void setLoadOffset(double l);
|
|
|
|
void setSlaved(bool s);
|
|
|
|
void setSlavedLoad(bool s);
|
|
|
|
void setHitchPos();
|
|
|
|
void setPch (double e, double dt, double c);
|
|
|
|
void setHdg (double az, double dt, double c);
|
|
|
|
void setBnk(double r, double dt, double c);
|
|
|
|
void setHt(double h, double dt, double c);
|
|
|
|
void setHitchVelocity(double dt);
|
|
|
|
void setFormate(bool f);
|
|
|
|
|
|
|
|
double _getTime() const;
|
|
|
|
double getRelBrgHitchToUser() const;
|
|
|
|
double getElevHitchToUser() const;
|
|
|
|
double getLoadOffset() const;
|
|
|
|
double getContents();
|
|
|
|
|
|
|
|
SGVec3d getCartHitchPos() const;
|
2008-01-04 22:31:18 +00:00
|
|
|
|
2008-02-15 11:06:27 +00:00
|
|
|
bool getHtAGL();
|
|
|
|
bool getSlaved() const;
|
|
|
|
bool getSlavedLoad() 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
|
2008-01-04 22:31:18 +00:00
|
|
|
static const double slugs_to_lbs; //conversion factor
|
2006-02-11 13:16:56 +00:00
|
|
|
|
2007-12-21 23:37:05 +00:00
|
|
|
SGPropertyNode_ptr _force_node;
|
|
|
|
SGPropertyNode_ptr _force_azimuth_node;
|
|
|
|
SGPropertyNode_ptr _force_elevation_node;
|
|
|
|
|
2008-02-15 11:06:27 +00:00
|
|
|
SGGeod hitchpos;
|
2003-11-28 15:48:05 +00:00
|
|
|
|
2008-02-15 11:06:27 +00:00
|
|
|
double _height;
|
|
|
|
double _ht_agl_ft; // height above ground level
|
2007-05-15 17:22:49 +00:00
|
|
|
double _azimuth; // degrees true
|
|
|
|
double _elevation; // degrees
|
|
|
|
double _rotation; // degrees
|
2008-02-15 11:06:27 +00:00
|
|
|
|
|
|
|
bool _formate_to_ac;
|
|
|
|
|
|
|
|
void setTgtXOffset(double x);
|
|
|
|
void setTgtYOffset(double y);
|
|
|
|
void setTgtZOffset(double z);
|
|
|
|
void setTgtOffsets(double dt, double c);
|
|
|
|
|
|
|
|
double getTgtXOffset() const;
|
|
|
|
double getTgtYOffset() const;
|
|
|
|
double getTgtZOffset() const;
|
|
|
|
|
|
|
|
double _tgt_x_offset;
|
|
|
|
double _tgt_y_offset;
|
|
|
|
double _tgt_z_offset;
|
|
|
|
double _elapsed_time;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
virtual void reinit() { init(); }
|
|
|
|
|
2007-05-15 17:22:49 +00:00
|
|
|
bool _aero_stabilised; // if true, object will align with trajectory
|
|
|
|
double _drag_area; // equivalent drag area in ft2
|
|
|
|
double _life_timer; // seconds
|
2008-02-15 11:06:27 +00:00
|
|
|
double _gravity; // fps^2
|
|
|
|
double _buoyancy; // fps^2
|
2007-05-15 17:22:49 +00:00
|
|
|
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 _load_resistance; // ground load resistanc N/m^2
|
2008-01-04 22:31:18 +00:00
|
|
|
double _frictionFactor; // dimensionless modifier for Coefficient of Friction
|
2007-05-15 17:22:49 +00:00
|
|
|
bool _solid; // if true ground is solid for FDMs
|
2008-01-04 22:31:18 +00:00
|
|
|
double _elevation_m; // ground elevation in meters
|
|
|
|
bool _force_stabilised;// if true, object will align to external force
|
2008-02-15 11:06:27 +00:00
|
|
|
bool _slave_to_ac; // if true, object will be slaved to the parent ac pos and orientation
|
|
|
|
bool _slave_load_to_ac;// if true, object will be slaved to the parent ac pos
|
|
|
|
double _contents_lb; // contents of the object
|
|
|
|
double _weight_lb; // weight of the object (no contents if appropriate) (lbs)
|
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
|
2007-12-21 23:37:05 +00:00
|
|
|
bool _external_force; // if true then apply external force
|
2010-07-16 22:05:05 +00:00
|
|
|
bool _report_expiry;
|
2007-06-07 16:30:26 +00:00
|
|
|
|
|
|
|
SGPropertyNode_ptr _impact_report_node; // report node for impact and collision
|
2008-02-15 11:06:27 +00:00
|
|
|
SGPropertyNode_ptr _contents_node; // report node for impact and collision
|
2007-06-07 16:30:26 +00:00
|
|
|
|
|
|
|
double _fuse_range;
|
2008-02-15 11:06:27 +00:00
|
|
|
double _distance;
|
2007-06-07 16:30:26 +00:00
|
|
|
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;
|
2007-12-21 23:37:05 +00:00
|
|
|
string _force_path;
|
2004-09-22 08:47:05 +00:00
|
|
|
|
2008-01-04 22:31:18 +00:00
|
|
|
const SGMaterial* _material;
|
|
|
|
|
2007-06-07 16:30:26 +00:00
|
|
|
void handle_collision();
|
2010-07-16 22:05:05 +00:00
|
|
|
void handle_expiry();
|
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);
|
2008-02-15 11:06:27 +00:00
|
|
|
void slaveToAC(double dt);
|
|
|
|
void setContents(double c);
|
|
|
|
void formateToAC(double dt);
|
|
|
|
|
|
|
|
SGVec3d getCartUserPos() const;
|
2007-06-07 16:30:26 +00:00
|
|
|
|
2008-02-15 11:06:27 +00:00
|
|
|
double getDistanceLoadToHitch() const;
|
|
|
|
double getElevLoadToHitch() const;
|
|
|
|
double getBearingLoadToHitch() const;
|
2008-01-04 22:31:18 +00:00
|
|
|
double getRecip(double az);
|
2008-02-15 11:06:27 +00:00
|
|
|
double getMass() const;
|
|
|
|
|
|
|
|
double hs;
|
|
|
|
double _ground_offset;
|
|
|
|
double _load_offset;
|
|
|
|
double _force;
|
|
|
|
double _old_height;
|
|
|
|
|
|
|
|
SGVec3d _oldcarthitchPos;
|
|
|
|
|
|
|
|
SGGeod oldhitchpos;
|
2008-01-04 22:31:18 +00:00
|
|
|
|
2003-11-28 15:48:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _FG_AIBALLISTIC_HXX
|