2002-04-25 16:23:16 +00:00
|
|
|
// UFO.hxx -- interface to the "UFO" flight model
|
|
|
|
//
|
|
|
|
// Written by Curtis Olson, started October 1999.
|
|
|
|
// Slightly modified from MagicCarpet.hxx by Jonathan Polley, April 2002
|
|
|
|
//
|
2004-11-19 22:10:41 +00:00
|
|
|
// Copyright (C) 1999-2002 Curtis L. Olson - http://www.flightgear.org/~curt
|
2002-04-25 16:23:16 +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.
|
2002-04-25 16:23:16 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _UFO_HXX
|
|
|
|
#define _UFO_HXX
|
|
|
|
|
|
|
|
#include "flight.hxx"
|
|
|
|
|
|
|
|
|
|
|
|
class FGUFO: public FGInterface {
|
2007-07-28 08:08:22 +00:00
|
|
|
private:
|
|
|
|
|
2007-07-27 21:57:55 +00:00
|
|
|
class lowpass {
|
2007-07-28 08:08:22 +00:00
|
|
|
private:
|
|
|
|
static double _dt;
|
2007-07-27 21:57:55 +00:00
|
|
|
double _coeff;
|
|
|
|
double _last;
|
|
|
|
bool _initialized;
|
|
|
|
public:
|
|
|
|
lowpass(double coeff) : _coeff(coeff), _initialized(false) {}
|
2007-07-28 08:08:22 +00:00
|
|
|
static inline void set_delta(double dt) { _dt = dt; }
|
|
|
|
double filter(double value) {
|
2007-07-27 21:57:55 +00:00
|
|
|
if (!_initialized) {
|
|
|
|
_initialized = true;
|
|
|
|
return _last = value;
|
|
|
|
}
|
2007-07-28 08:08:22 +00:00
|
|
|
double c = _dt / (_coeff + _dt);
|
2007-07-27 21:57:55 +00:00
|
|
|
return _last = value * c + _last * (1.0 - c);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
lowpass *Throttle;
|
|
|
|
lowpass *Aileron;
|
|
|
|
lowpass *Elevator;
|
|
|
|
lowpass *Rudder;
|
|
|
|
lowpass *Aileron_Trim;
|
|
|
|
lowpass *Elevator_Trim;
|
|
|
|
lowpass *Rudder_Trim;
|
2006-03-11 12:19:43 +00:00
|
|
|
SGPropertyNode_ptr Speed_Max;
|
2006-03-11 09:23:51 +00:00
|
|
|
|
2002-04-25 16:23:16 +00:00
|
|
|
public:
|
|
|
|
FGUFO( double dt );
|
|
|
|
~FGUFO();
|
|
|
|
|
2007-07-29 17:36:30 +00:00
|
|
|
// reset flight params to a specific position
|
2002-04-25 16:23:16 +00:00
|
|
|
void init();
|
|
|
|
|
|
|
|
// update position based on inputs, positions, velocities, etc.
|
2002-05-11 16:28:50 +00:00
|
|
|
void update( double dt );
|
2002-04-25 16:23:16 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _UFO_HXX
|