1 // FGAIBase - abstract base class for AI objects
2 // Written by David Culp, started Nov 2003, based on
3 // David Luff's FGAIEntity class.
4 // - davidculp2@comcast.net
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License as
8 // published by the Free Software Foundation; either version 2 of the
9 // License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <Main/globals.hxx>
28 #include <Scenery/scenery.hxx>
29 #include <simgear/math/point3d.hxx>
30 #include <simgear/misc/sg_path.hxx>
31 #include <simgear/scene/model/location.hxx>
32 #include <simgear/scene/model/model.hxx>
33 #include <simgear/debug/logstream.hxx>
38 FGAIBase::~FGAIBase() {
41 void FGAIBase::update(double dt) {
45 void FGAIBase::Transform() {
46 aip.setPosition(pos.lon(), pos.lat(), pos.elev() * SG_METER_TO_FEET);
47 aip.setOrientation(roll, pitch, hdg);
48 aip.update( globals->get_scenery()->get_center() );
52 bool FGAIBase::init() {
53 ssgBranch *model = sgLoad3DModel( globals->get_fg_root(),
56 globals->get_sim_time_sec() );
60 globals->get_scenery()->get_scene_graph()->addKid(aip.getSceneGraph());
62 SG_LOG(SG_INPUT, SG_WARN, "AIBase: Could not load aircraft model.");
65 tgt_roll = tgt_pitch = tgt_yaw = tgt_vs = vs = roll = pitch = 0.0;
70 void FGAIBase::setPath( const char* model ) {
71 model_path.append(model);
74 void FGAIBase::setSpeed( double speed_KTAS ) {
75 speed = tgt_speed = speed_KTAS;
78 void FGAIBase::setAltitude( double altitude_ft ) {
79 altitude = tgt_altitude = altitude_ft;
80 pos.setelev(altitude * 0.3048);
83 void FGAIBase::setLongitude( double longitude ) {
84 pos.setlon(longitude);
87 void FGAIBase::setLatitude( double latitude ) {
91 void FGAIBase::setHeading( double heading ) {
92 hdg = tgt_heading = heading;
95 void FGAIBase::setDie( bool die ) {