//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifdef HAVE_CONFIG_H
invisible = true;
no_roll = true;
life = 900;
- index = 0;
delete_me = false;
}
globals->get_scenery()->unregister_placement_transform(aip.getTransform());
globals->get_scenery()->get_scene_graph()->removeKid(aip.getSceneGraph());
}
- SGPropertyNode *root = globals->get_props()->getNode("ai/models", true);
- root->removeChild(getTypeString(), index);
+ if (props) {
+ SGPropertyNode* parent = props->getParent();
+ if (parent)
+ parent->removeChild(props->getName(), props->getIndex(), false);
+ }
delete fp;
- fp = NULL;
+ fp = 0;
}
bool FGAIBase::init() {
- SGPropertyNode *root = globals->get_props()->getNode("ai/models", true);
-
- index = manager->getNum(_otype) - 1;
- props = root->getNode(getTypeString(), index, true);
-
if (!model_path.empty()) {
try {
model = load3DModel( globals->get_fg_root(), model_path, props,
return range_ft2;
}
-Point3D
-FGAIBase::getCartPosAt(const Point3D& off) const
+SGVec3d
+FGAIBase::getCartPosAt(const SGVec3d& _off) const
{
- // The offset converted to the usual body fixed coordinate system.
- sgdVec3 sgdOff;
- sgdSetVec3(sgdOff, -off.x(), off.z(), -off.y());
-
// Transform that one to the horizontal local coordinate system.
- sgdMat4 hlTrans;
- sgdMakeRotMat4(hlTrans, hdg, pitch, roll);
- sgdXformPnt3(sgdOff, hlTrans);
-
- // Now transform to the wgs84 earth centeres system.
- Point3D pos2(pos.lon()* SGD_DEGREES_TO_RADIANS,
- pos.lat() * SGD_DEGREES_TO_RADIANS,
- pos.elev());
- Point3D cartPos3D = sgGeodToCart(pos2);
- sgdMat4 ecTrans;
- sgdMakeCoordMat4(ecTrans, cartPos3D.x(), cartPos3D.y(), cartPos3D.z(),
- pos.lon(), 0, - 90 - pos.lat());
- sgdXformPnt3(sgdOff, ecTrans);
-
- return Point3D(sgdOff[0], sgdOff[1], sgdOff[2]);
-}
+ SGQuatd hlTrans = SGQuatd::fromLonLatDeg(pos.lon(), pos.lat());
+ // and postrotate the orientation of the AIModel wrt the horizontal
+ // local frame
+ hlTrans *= SGQuatd::fromYawPitchRollDeg(hdg, pitch, roll);
-Point3D
-FGAIBase::getGeocPosAt(const Point3D& off) const
-{
- return sgCartToGeod(getCartPosAt(off));
+ // The offset converted to the usual body fixed coordinate system
+ // rotated to the earth fiexed coordinates axis
+ SGVec3d off = hlTrans.backTransform(_off);
+
+ // Add the position offset of the AIModel to gain the earth centered position
+ SGVec3d cartPos = SGGeod::fromDegFt(pos.lon(), pos.lat(), pos.elev());
+
+ return cartPos + off;
}
/*