]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/AIEntity.cxx
Emergency fix for AI model loading - non existance of the piper model as in the lates...
[flightgear.git] / src / ATC / AIEntity.cxx
index 126d0377852c7b948783117b1e4ed0d61dc2f286..9dccebea01911ec734d2d84c3c6fa884eb23634f 100644 (file)
@@ -21,7 +21,7 @@
 /*****************************************************************
 *
 * WARNING - Curt has some ideas about AI traffic so anything in here
-* may get rewritten or scrapped.  Contact Curt curt@flightgear.org 
+* may get rewritten or scrapped.  Contact Curt http://www.flightgear.org/~curt 
 * before spending any time or effort on this code!!!
 *
 ******************************************************************/
@@ -32,7 +32,7 @@
 
 #include <Main/globals.hxx>
 #include <Scenery/scenery.hxx>
-//#include <simgear/constants.h>
+#include <simgear/constants.h>
 #include <simgear/math/point3d.hxx>
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/misc/sg_path.hxx>
 
 #include "AIEntity.hxx"
 
+FGAIEntity::FGAIEntity() {
+}
+
 FGAIEntity::~FGAIEntity() {
+       //cout << "FGAIEntity dtor called..." << endl;
+       _model->deRef();        // Ought to check valid?
+       //cout << "Removing model from scene graph..." << endl;
+       globals->get_scenery()->get_scene_graph()->removeKid(_aip.getSceneGraph());
+       //cout << "Done!" << endl;
+}
+
+void FGAIEntity::SetModel(ssgBranch* model) {
+       _model = model;
+       _model->ref();
+       _aip.init(_model);
+       _aip.setVisible(false);
+       globals->get_scenery()->get_scene_graph()->addKid(_aip.getSceneGraph());
 }
 
 void FGAIEntity::Update(double dt) {
 }
 
+string FGAIEntity::GetCallsign() {
+       return("");
+}
+
 void FGAIEntity::RegisterTransmission(int code) {
 }
 
 // Run the internal calculations
 //void FGAIEntity::Update() {
 void FGAIEntity::Transform() {
-    aip.setPosition(pos.lon(), pos.lat(), pos.elev() * SG_METER_TO_FEET);
-    aip.setOrientation(roll, pitch, hdg);
-    aip.update();    
+    _aip.setPosition(_pos.lon(), _pos.lat(), _pos.elev() * SG_METER_TO_FEET);
+    _aip.setOrientation(_roll, _pitch, _hdg);
+    _aip.update( globals->get_scenery()->get_center() );    
 }