2009-04-20 14:20:05 +00:00
|
|
|
// FGAIThermal - FGAIBase-derived class creates an AI thermal
|
2004-03-03 20:26:06 +00:00
|
|
|
//
|
2009-04-20 14:20:05 +00:00
|
|
|
// Original by Written by David Culp
|
2004-03-03 20:26:06 +00:00
|
|
|
//
|
2009-04-20 14:20:05 +00:00
|
|
|
// An attempt to refine the thermal shape and behaviour by WooT 2009
|
|
|
|
//
|
|
|
|
// Copyright (C) 2009 Patrice Poly ( WooT )
|
2004-03-03 20:26:06 +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.
|
2004-03-03 20:26:06 +00:00
|
|
|
|
|
|
|
#ifndef _FG_AIThermal_HXX
|
|
|
|
#define _FG_AIThermal_HXX
|
|
|
|
|
|
|
|
#include "AIManager.hxx"
|
|
|
|
#include "AIBase.hxx"
|
|
|
|
|
|
|
|
#include <string>
|
2008-07-27 16:25:13 +00:00
|
|
|
using std::string;
|
2004-03-03 20:26:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
class FGAIThermal : public FGAIBase {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2006-02-11 13:16:56 +00:00
|
|
|
FGAIThermal();
|
2004-03-03 20:26:06 +00:00
|
|
|
~FGAIThermal();
|
|
|
|
|
2006-02-11 13:16:56 +00:00
|
|
|
void readFromScenario(SGPropertyNode* scFileNode);
|
|
|
|
|
2007-01-13 16:04:28 +00:00
|
|
|
virtual bool init(bool search_in_AI_path=false);
|
2004-03-03 20:26:06 +00:00
|
|
|
virtual void bind();
|
|
|
|
virtual void unbind();
|
2006-02-11 13:16:56 +00:00
|
|
|
virtual void update(double dt);
|
2004-03-03 20:26:06 +00:00
|
|
|
|
2009-04-20 14:20:05 +00:00
|
|
|
inline void setMaxStrength( double s ) { max_strength = s; };
|
2004-03-03 20:26:06 +00:00
|
|
|
inline void setDiameter( double d ) { diameter = d; };
|
2004-11-07 14:46:21 +00:00
|
|
|
inline void setHeight( double h ) { height = h; };
|
2009-04-20 14:20:05 +00:00
|
|
|
inline void setMaxUpdraft( double lift ) { v_up_max = lift; };
|
|
|
|
inline void setMinUpdraft( double sink ) { v_up_min = sink; };
|
|
|
|
inline void setR_up_frac( double r ) { r_up_frac = r; };
|
|
|
|
|
|
|
|
inline double getStrength() const { return strength; };
|
David Culp:
I added some things to the AI stuff to improve the AIThermal processing.
Before, all the thermals were processed in order, and the last one overwrote
the prior one. Now, only the data from the nearest thermal is kept. This
way a tile can be populated with many thermals, and (as long as they have the
same diameter) the one nearest the airplane correctly takes effect. This
will make us ready for the next step, "auto-thermaling", where FlightGear's
tile manager can cover a tile with thermals, and set the thermal strength
based on land-use type.
I moved the enumerated object_type to the base class. When an AI object is
created it now sets the _otype variable in the base class. This lets the AI
manager find out what kind of AI object it is dealing with, using the base
pointer. I also added a function isa() to the base class, so the manager can
process objects differently based on their type.
The AI manager now sends AIThermal processing to a different function, where
only the data from the nearest thermal is kept. After the manager processes
all the AI objects, then the results from the nearest thermal are applied to
wind-from-down.
2004-03-07 12:08:46 +00:00
|
|
|
inline double getDiameter() const { return diameter; };
|
2004-11-07 14:46:21 +00:00
|
|
|
inline double getHeight() const { return height; };
|
2009-04-20 14:20:05 +00:00
|
|
|
inline double getV_up_max() const { return v_up_max; };
|
|
|
|
inline double getV_up_min() const { return v_up_min; };
|
|
|
|
inline double getR_up_frac() const { return r_up_frac; };
|
2004-03-03 20:26:06 +00:00
|
|
|
|
2006-02-11 13:16:56 +00:00
|
|
|
virtual const char* getTypeString(void) const { return "thermal"; }
|
2009-04-20 14:20:05 +00:00
|
|
|
void getGroundElev(double dt);
|
|
|
|
|
|
|
|
|
2004-03-03 20:26:06 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
void Run(double dt);
|
2009-04-20 14:20:05 +00:00
|
|
|
double get_strength_fac(double alt_frac);
|
|
|
|
double max_strength;
|
2004-03-03 20:26:06 +00:00
|
|
|
double strength;
|
|
|
|
double diameter;
|
2004-11-07 14:46:21 +00:00
|
|
|
double height;
|
David Culp:
I added some things to the AI stuff to improve the AIThermal processing.
Before, all the thermals were processed in order, and the last one overwrote
the prior one. Now, only the data from the nearest thermal is kept. This
way a tile can be populated with many thermals, and (as long as they have the
same diameter) the one nearest the airplane correctly takes effect. This
will make us ready for the next step, "auto-thermaling", where FlightGear's
tile manager can cover a tile with thermals, and set the thermal strength
based on land-use type.
I moved the enumerated object_type to the base class. When an AI object is
created it now sets the _otype variable in the base class. This lets the AI
manager find out what kind of AI object it is dealing with, using the base
pointer. I also added a function isa() to the base class, so the manager can
process objects differently based on their type.
The AI manager now sends AIThermal processing to a different function, where
only the data from the nearest thermal is kept. After the manager processes
all the AI objects, then the results from the nearest thermal are applied to
wind-from-down.
2004-03-07 12:08:46 +00:00
|
|
|
double factor;
|
2009-04-20 14:20:05 +00:00
|
|
|
double alt_rel;
|
|
|
|
double alt;
|
|
|
|
double v_up_max;
|
|
|
|
double v_up_min;
|
|
|
|
double r_up_frac;
|
|
|
|
double cycle_timer;
|
|
|
|
double dt_count;
|
|
|
|
double time;
|
|
|
|
double xx;
|
|
|
|
double ground_elev_ft; // ground level in ft
|
|
|
|
double altitude_agl_ft; // altitude above ground in feet
|
|
|
|
bool do_agl_calc;
|
|
|
|
bool is_forming;
|
|
|
|
bool is_formed;
|
|
|
|
bool is_dying;
|
|
|
|
bool is_dead;
|
|
|
|
SGPropertyNode_ptr _surface_wind_from_deg_node;
|
|
|
|
SGPropertyNode_ptr _surface_wind_speed_node;
|
|
|
|
SGPropertyNode_ptr _aloft_wind_from_deg_node;
|
|
|
|
SGPropertyNode_ptr _aloft_wind_speed_node;
|
|
|
|
|
2004-03-03 20:26:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _FG_AIThermal_HXX
|