]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIBase.cxx
Wingman code from Vivian Meazza
[flightgear.git] / src / AIModel / AIBase.cxx
index e375f606c917fb0f8defd9ff85b4d58406681806..35be09b9d183f67b01c2256cbefe08249e3b85a2 100644 (file)
@@ -138,6 +138,7 @@ void FGAIBase::update(double dt) {
 void FGAIBase::Transform() {
 
     if (!invisible) {
+        aip.setVisible(true);
         aip.setPosition(pos);
 
         if (no_roll)
@@ -146,6 +147,9 @@ void FGAIBase::Transform() {
             aip.setOrientation(roll, pitch, hdg);
 
         aip.update();
+    } else {
+        aip.setVisible(false);
+        aip.update();
     }
 
 }
@@ -245,6 +249,10 @@ void FGAIBase::bind() {
         SGRawValueMethods<FGAIBase,double>(*this,
         &FGAIBase::_getCartPosZ,
         0));
+    props->tie("callsign",
+        SGRawValueMethods<FGAIBase,const char*>(*this,
+        &FGAIBase::_getCallsign,
+        0));
 
     props->tie("orientation/pitch-deg",   SGRawValuePointer<double>(&pitch));
     props->tie("orientation/roll-deg",    SGRawValuePointer<double>(&roll));
@@ -290,6 +298,7 @@ void FGAIBase::unbind() {
     props->untie("position/global-x");
     props->untie("position/global-y");
     props->untie("position/global-z");
+    props->untie("callsign");
 
     props->untie("orientation/pitch-deg");
     props->untie("orientation/roll-deg");
@@ -430,15 +439,7 @@ SGVec3d FGAIBase::getCartPosAt(const SGVec3d& _off) const {
 }
 
 SGVec3d FGAIBase::getCartPos() const {
-    // Transform that one to the horizontal local coordinate system.
-    SGQuatd hlTrans = SGQuatd::fromLonLat(pos);
-
-    // and postrotate the orientation of the AIModel wrt the horizontal
-    // local frame
-    hlTrans *= SGQuatd::fromYawPitchRollDeg(hdg, pitch, roll);
-
     SGVec3d cartPos = SGVec3d::fromGeod(pos);
-
     return cartPos;
 }
 
@@ -465,6 +466,12 @@ void FGAIBase::_setLatitude ( double latitude )  {
     pos.setLatitudeDeg(latitude);
 }
 
+void FGAIBase::_setUserPos(){
+    userpos.setLatitudeDeg(manager->get_user_latitude());
+    userpos.setLongitudeDeg(manager->get_user_longitude());
+    userpos.setElevationM(manager->get_user_altitude() * SG_FEET_TO_METER);
+}
+
 void FGAIBase::_setSubID( int s ) {
     _subID = s;
 }
@@ -581,23 +588,38 @@ double FGAIBase::_getHeading() const {
     return hdg;
 }
 
-const char* FGAIBase::_getPath() {
+double  FGAIBase::_getXOffset() const {
+    return _x_offset;
+}
+
+double  FGAIBase::_getYOffset() const {
+    return _y_offset;
+}
+
+double  FGAIBase::_getZOffset() const {
+    return _z_offset;
+}
+
+const char* FGAIBase::_getPath() const {
+    return model_path.c_str();
+}
+
+const char* FGAIBase::_getSMPath() const {
     return _path.c_str();
 }
 
-const char* FGAIBase::_getName() {
+const char* FGAIBase::_getName() const {
     return _name.c_str();
 }
 
-const char* FGAIBase::_getCallsign() {
+const char* FGAIBase::_getCallsign() const {
     return _callsign.c_str();
 }
 
-const char* FGAIBase::_getSubmodel() {
+const char* FGAIBase::_getSubmodel() const {
     return _submodel.c_str();
 }
 
-
 void FGAIBase::CalculateMach() {
     // Calculate rho at altitude, using standard atmosphere
     // For the temperature T and the pressure p,
@@ -621,7 +643,7 @@ void FGAIBase::CalculateMach() {
     // where:
     // a = speed of sound [ft/s]
     // g = specific heat ratio, which is usually equal to 1.4
-    // R = specific gas constant, which equals 1716 ft-lb/slug/°R
+    // R = specific gas constant, which equals 1716 ft-lb/slug/R
     a = sqrt ( 1.4 * 1716 * (T + 459.7));
 
     // calculate Mach number