#include "AIBase.hxx"
+FGAIBase *FGAIBase::_self = NULL;
+
+FGAIBase::FGAIBase() {
+ _self = this;
+}
+
FGAIBase::~FGAIBase() {
+ _self = NULL;
}
void FGAIBase::update(double dt) {
props->tie("velocities/vertical-speed-fps", SGRawValuePointer<double>(&vs));
props->tie("position/altitude-ft", SGRawValuePointer<double>(&altitude));
- props->tie("position/latitude-deg", SGRawValuePointer<double>(&lat));
- props->tie("position/longitude-deg", SGRawValuePointer<double>(&lon));
+ props->tie("position/latitude-deg",
+ SGRawValueFunctions<double>(FGAIBase::_getLatitude,
+ FGAIBase::_setLatitude));
+ props->tie("position/longitude-deg",
+ SGRawValueFunctions<double>(FGAIBase::_getLongitude,
+ FGAIBase::_setLongitude));
props->tie("orientation/pitch-deg", SGRawValuePointer<double>(&pitch));
props->tie("orientation/roll-deg", SGRawValuePointer<double>(&roll));
props->untie("orientation/roll-deg");
props->untie("orientation/heading-deg");
}
+
+
+void FGAIBase::_setLongitude( double longitude ) {
+ _self->pos.setlon(longitude);
+}
+
+void FGAIBase::_setLatitude ( double latitude ) {
+ _self->pos.setlat(latitude);
+}
+
+double FGAIBase::_getLongitude() { return _self->pos.lon(); }
+
+double FGAIBase::_getLatitude () { return _self->pos.lat(); }
class FGAIBase {
+private:
+
+ static FGAIBase *_self;
+
public:
+ FGAIBase();
virtual ~FGAIBase();
virtual void update(double dt);
inline Point3D GetPos() { return(pos); }
void setPath( const char* model );
void setSpeed( double speed_KTAS );
void setAltitude( double altitude_ft );
- void setLongitude( double longitude );
- void setLatitude( double latitude );
void setHeading( double heading );
+ void setLatitude( double latitude );
+ void setLongitude( double longitude );
void setDie( bool die );
bool getDie();
SGPropertyNode *props;
Point3D pos; // WGS84 lat & lon in degrees, elev above sea-level in meters
- double lat, lon; // As above, this is needed for the property bindings
double hdg; // True heading in degrees
double roll; // degrees, left is negative
double pitch; // degrees, nose-down is negative
void Transform();
+private:
+ static void _setLongitude( double longitude );
+ static void _setLatitude ( double latitude );
+ static double _getLongitude();
+ static double _getLatitude ();
};
pos.setelev(altitude * SG_FEET_TO_METER);
}
-
-inline void FGAIBase::setLongitude( double longitude ) {
- lon = longitude;
- pos.setlon(longitude);
+inline void FGAIBase::setHeading( double heading ) {
+ hdg = tgt_heading = heading;
}
-inline void FGAIBase::setLatitude( double latitude ) {
- lat = latitude;
- pos.setlat(latitude);
+inline void FGAIBase::setLongitude( double longitude ) {
+ pos.setlon( longitude );
}
-inline void FGAIBase::setHeading( double heading ) {
- hdg = tgt_heading = heading;
+inline void FGAIBase::setLatitude ( double latitude ) {
+ pos.setlat( latitude );
}
inline void FGAIBase::setDie( bool die ) { delete_me = die; }