]> git.mxchange.org Git - flightgear.git/commitdiff
new global function for aircraft position
authorTorsten Dreyer <Torsten@t3r.de>
Sat, 20 Aug 2011 06:54:47 +0000 (08:54 +0200)
committerTorsten Dreyer <Torsten@t3r.de>
Sat, 20 Aug 2011 06:54:47 +0000 (08:54 +0200)
add a new function to get the aircraft's position instead
of reading /position/* properties

src/Main/globals.cxx
src/Main/globals.hxx

index 99f1709da14b2298e394c6490bde15b5f462bab2..40afef14c9e1c082c169411feabeafd8201897a4 100644 (file)
@@ -37,6 +37,7 @@
 #include <simgear/misc/ResourceManager.hxx>
 #include <simgear/props/propertyObject.hxx>
 #include <simgear/props/props_io.hxx>
+#include <simgear/scene/model/placement.hxx>
 
 #include <Aircraft/controls.hxx>
 #include <Airports/runways.hxx>
@@ -362,6 +363,18 @@ FGGlobals::get_event_mgr () const
     return event_mgr;
 }
 
+const SGGeod &
+FGGlobals::get_aircraft_position() const
+{
+    if( acmodel != NULL ) {
+        SGModelPlacement * mp = acmodel->get3DModel();
+        if( mp != NULL )
+            return mp->getPosition();
+    }
+    throw sg_exception("Can't get aircraft position", "FGGlobals::get_aircraft_position()" );
+}
+
+
 
 // Save the current state as the initial state.
 void
index e241b6297a0630b911ecd03c092aad1380976f6f..d2027d333d8c91db4bfc7baa3c1d15a07d2a57da 100644 (file)
@@ -265,6 +265,8 @@ public:
         acmodel = model;
     }
 
+    const SGGeod & get_aircraft_position() const;
+
     inline FGModelMgr *get_model_mgr () { return model_mgr; }
 
     inline void set_model_mgr (FGModelMgr * mgr)