1 // model.cxx - manage a 3D aircraft model.
2 // Written by David Megginson, started 2002.
4 // This file is in the Public Domain, and comes with no warranty.
10 #include <string.h> // for strcmp()
15 #include <simgear/compiler.h>
16 #include <simgear/debug/logstream.hxx>
17 #include <simgear/misc/exception.hxx>
18 #include <simgear/misc/sg_path.hxx>
20 #include <Main/globals.hxx>
21 #include <Main/fg_props.hxx>
22 #include <Main/viewmgr.hxx>
23 #include "acmodel.hxx"
27 ////////////////////////////////////////////////////////////////////////
28 // Implementation of FGAircraftModel
29 ////////////////////////////////////////////////////////////////////////
31 FGAircraftModel::FGAircraftModel ()
39 FGAircraftModel::~FGAircraftModel ()
46 FGAircraftModel::init ()
48 _aircraft = new FG3DModel;
49 _aircraft->init(fgGetString("/sim/model/path", "Models/Geometry/glider.ac"));
50 _scene->addKid(_aircraft->getSceneGraph());
54 FGAircraftModel::bind ()
60 FGAircraftModel::unbind ()
66 FGAircraftModel::update (int dt)
68 int view_number = globals->get_viewmgr()->get_current();
70 if (view_number == 0 && !fgGetBool("/sim/view/internal")) {
71 _aircraft->setVisible(false);
73 _aircraft->setVisible(true);
76 _aircraft->setPosition(fgGetDouble("/position/longitude-deg"),
77 fgGetDouble("/position/latitude-deg"),
78 fgGetDouble("/position/altitude-ft"));
79 _aircraft->setOrientation(fgGetDouble("/orientation/roll-deg"),
80 fgGetDouble("/orientation/pitch-deg"),
81 fgGetDouble("/orientation/heading-deg"));
82 _aircraft->update(dt);
87 FGAircraftModel::draw ()
89 // OK, now adjust the clip planes and draw
90 // FIXME: view number shouldn't be
92 int view_number = globals->get_viewmgr()->get_current();
93 if (_aircraft->getVisible()) {
94 if (view_number == 0) {
96 glClear(GL_DEPTH_BUFFER_BIT);
97 ssgSetNearFar(_nearplane, _farplane);
99 ssgCullAndDraw(_scene);