1
0
Fork 0

Merge branch 'next' of D:\Git_New\flightgear into next

This commit is contained in:
Vivian Meazza 2010-08-01 14:48:18 +01:00
commit 740195dc63
28 changed files with 1499 additions and 231 deletions

File diff suppressed because it is too large Load diff

View file

@ -52,7 +52,8 @@
#if !ENABLE_ATCDCL #if !ENABLE_ATCDCL
class SGPath; class SGPath;
class ATCData;
// Possible types of ATC type that the radios may be tuned to. // Possible types of ATC type that the radios may be tuned to.
// INVALID implies not tuned in to anything. // INVALID implies not tuned in to anything.
@ -67,6 +68,18 @@ enum atc_type {
INVALID /* must be last element; see ATC_NUM_TYPES */ INVALID /* must be last element; see ATC_NUM_TYPES */
}; };
struct ATCData {
ATCData() : type(INVALID), cart(0, 0, 0), freq(0), range(0) {}
atc_type type;
SGGeod geod;
SGVec3d cart;
unsigned short int freq;
unsigned short int range;
std::string ident;
std::string name;
};
// A list of ATC stations // A list of ATC stations
typedef std::list < ATCData > comm_list_type; typedef std::list < ATCData > comm_list_type;

View file

@ -194,8 +194,7 @@ void FGXMLAutopilotGroup::init()
continue; continue;
} }
SGPath config( globals->get_fg_root() ); SGPath config = globals->resolve_aircraft_path(pathNode->getStringValue());
config.append( pathNode->getStringValue() );
SG_LOG( SG_ALL, SG_INFO, "Reading autopilot configuration from " << config.str() ); SG_LOG( SG_ALL, SG_INFO, "Reading autopilot configuration from " << config.str() );

View file

@ -122,11 +122,7 @@ FGTextureManager::createTexture (const string &relativePath, bool staticTexture)
{ {
osg::Texture2D* texture = _textureMap[relativePath].get(); osg::Texture2D* texture = _textureMap[relativePath].get();
if (texture == 0) { if (texture == 0) {
SG_LOG( SG_COCKPIT, SG_DEBUG, SGPath tpath = globals->resolve_aircraft_path(relativePath);
"Texture " << relativePath << " does not yet exist" );
SGPath tpath(globals->get_fg_root());
tpath.append(relativePath);
texture = SGLoadTexture2D(staticTexture, tpath); texture = SGLoadTexture2D(staticTexture, tpath);
_textureMap[relativePath] = texture; _textureMap[relativePath] = texture;

View file

@ -839,10 +839,9 @@ fgReadPanel (istream &input)
FGPanel * FGPanel *
fgReadPanel (const string &relative_path) fgReadPanel (const string &relative_path)
{ {
SGPath path(globals->get_fg_root()); SGPath path = globals->resolve_aircraft_path(relative_path);
path.append(relative_path);
SGPropertyNode root; SGPropertyNode root;
try { try {
readProperties(path.str(), &root); readProperties(path.str(), &root);
} catch (const sg_exception &e) { } catch (const sg_exception &e) {

View file

@ -60,9 +60,7 @@ extern void fgDumpSnapShotWrapper();
extern void fgHiResDumpWrapper(); extern void fgHiResDumpWrapper();
extern void fgHiResDump(); extern void fgHiResDump();
#endif #endif
#if defined( _WIN32 ) && !defined(__MINGW32__)
extern void printScreen();
#endif
extern void helpCb(); extern void helpCb();
typedef struct { typedef struct {

View file

@ -53,11 +53,8 @@
#ifdef _WIN32 #ifdef _WIN32
# include <shellapi.h> # include <shellapi.h>
# if !defined(__MINGW32__)
# include <simgear/screen/win32-printer.h>
# include <simgear/screen/GlBitmaps.h>
# endif
#endif #endif
#include "gui.h" #include "gui.h"
using std::string; using std::string;
@ -75,9 +72,6 @@ const __fg_gui_fn_t __fg_gui_fn[] = {
{"dumpHiResSnapShot", fgHiResDumpWrapper}, {"dumpHiResSnapShot", fgHiResDumpWrapper},
#endif #endif
{"dumpSnapShot", fgDumpSnapShotWrapper}, {"dumpSnapShot", fgDumpSnapShotWrapper},
#if defined( _WIN32 ) && !defined(__MINGW32__)
{"printScreen", printScreen},
#endif
// Help // Help
{"helpCb", helpCb}, {"helpCb", helpCb},
@ -403,61 +397,6 @@ void fgHiResDump()
} }
#endif // #if defined( TR_HIRES_SNAP) #endif // #if defined( TR_HIRES_SNAP)
#if defined( _WIN32 ) && !defined(__MINGW32__)
void rotateView( double roll, double pitch, double yaw )
{
// rotate view
}
GlBitmap *b1 = NULL;
GLubyte *hiResScreenCapture( int multiplier )
{
float oldfov = fgGetDouble("/sim/current-view/field-of-view");
float fov = oldfov / multiplier;
FGViewer *v = globals->get_current_view();
fgSetDouble("/sim/current-view/field-of-view", fov);
// globals->get_renderer()->init();
int cur_width = fgGetInt("/sim/startup/xsize");
int cur_height = fgGetInt("/sim/startup/ysize");
delete( b1 );
// New empty (mostly) bitmap
b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
int x,y;
for ( y = 0; y < multiplier; y++ ) {
for ( x = 0; x < multiplier; x++ ) {
globals->get_renderer()->resize( cur_width, cur_height );
// pan to tile
rotateView( 0, (y*fov)-((multiplier-1)*fov/2), (x*fov)-((multiplier-1)*fov/2) );
globals->get_renderer()->update( false );
// restore view
GlBitmap b2;
b1->copyBitmap( &b2, cur_width*x, cur_height*y );
}
}
fgSetDouble("/sim/current-view/field-of-view", oldfov);
return b1->getBitmap();
}
#endif
#if defined( _WIN32 ) && !defined(__MINGW32__)
// win32 print screen function
void printScreen () {
int mouse = fgGetMouseCursor();
fgSetMouseCursor(MOUSE_CURSOR_NONE);
CGlPrinter p( CGlPrinter::PRINT_BITMAP );
int cur_width = fgGetInt("/sim/startup/xsize");
int cur_height = fgGetInt("/sim/startup/ysize");
p.Begin( "FlightGear", cur_width*3, cur_height*3 );
p.End( hiResScreenCapture(3) );
fgSetMouseCursor(mouse);
}
#endif // #ifdef _WIN32
void fgDumpSnapShotWrapper () { void fgDumpSnapShotWrapper () {
fgDumpSnapShot(); fgDumpSnapShot();
} }

View file

@ -36,16 +36,6 @@ do_hires_snapshot_dialog (const SGPropertyNode * arg)
} }
#endif // TR_HIRES_SNAP #endif // TR_HIRES_SNAP
#if defined( _WIN32 ) && !defined(__MINGW32__)
extern void printScreen ();
static bool
do_print_dialog (const SGPropertyNode * arg)
{
printScreen();
return true;
}
#endif
extern void helpCb (); extern void helpCb ();
static bool static bool
do_help_dialog (const SGPropertyNode * arg) do_help_dialog (const SGPropertyNode * arg)
@ -60,9 +50,6 @@ static struct {
} deprecated_dialogs [] = { } deprecated_dialogs [] = {
#if defined(TR_HIRES_SNAP) #if defined(TR_HIRES_SNAP)
{ "old-hires-snapshot-dialog", do_hires_snapshot_dialog }, { "old-hires-snapshot-dialog", do_hires_snapshot_dialog },
#endif
#if defined( _WIN32 ) && !defined(__MINGW32__)
{ "old-print-dialog", do_print_dialog },
#endif #endif
{ "old-help-dialog", do_help_dialog }, { "old-help-dialog", do_help_dialog },
{ 0, 0 } { 0, 0 }

View file

@ -26,7 +26,11 @@
#endif #endif
#include "kln89_page_apt.hxx" #include "kln89_page_apt.hxx"
#include <ATCDCL/commlist.hxx> #if ENABLE_ATCDCL
# include <ATCDCL/commlist.hxx>
#else
#include <ATC/atcutils.hxx>
#endif
#include <Main/globals.hxx> #include <Main/globals.hxx>
#include <Airports/runways.hxx> #include <Airports/runways.hxx>
#include <Airports/simple.hxx> #include <Airports/simple.hxx>

View file

@ -62,9 +62,8 @@ FGInstrumentMgr::FGInstrumentMgr () :
SGPropertyNode *path_n = fgGetNode("/sim/instrumentation/path"); SGPropertyNode *path_n = fgGetNode("/sim/instrumentation/path");
if (path_n) { if (path_n) {
SGPath config( globals->get_fg_root() ); SGPath config = globals->resolve_aircraft_path(path_n->getStringValue());
config.append( path_n->getStringValue() );
SG_LOG( SG_ALL, SG_INFO, "Reading instruments from " SG_LOG( SG_ALL, SG_INFO, "Reading instruments from "
<< config.str() ); << config.str() );
try { try {

View file

@ -182,6 +182,8 @@ MK_VIII::PropertiesHandler::init ()
mk_node(altimeter_serviceable) = fgGetNode("/instrumentation/altimeter/serviceable", true); mk_node(altimeter_serviceable) = fgGetNode("/instrumentation/altimeter/serviceable", true);
mk_node(altitude) = fgGetNode("/position/altitude-ft", true); mk_node(altitude) = fgGetNode("/position/altitude-ft", true);
mk_node(altitude_agl) = fgGetNode("/position/altitude-agl-ft", true); mk_node(altitude_agl) = fgGetNode("/position/altitude-agl-ft", true);
mk_node(altitude_gear_agl) = fgGetNode("/position/gear-agl-ft", true);
mk_node(orientation_roll) = fgGetNode("/orientation/roll-deg", true);
mk_node(asi_serviceable) = fgGetNode("/instrumentation/airspeed-indicator/serviceable", true); mk_node(asi_serviceable) = fgGetNode("/instrumentation/airspeed-indicator/serviceable", true);
mk_node(asi_speed) = fgGetNode("/instrumentation/airspeed-indicator/indicated-speed-kt", true); mk_node(asi_speed) = fgGetNode("/instrumentation/airspeed-indicator/indicated-speed-kt", true);
mk_node(autopilot_heading_lock) = fgGetNode("/autopilot/locks/heading", true); mk_node(autopilot_heading_lock) = fgGetNode("/autopilot/locks/heading", true);
@ -712,7 +714,10 @@ MK_VIII::ConfigurationModule::read_options_select_group_1 (int value)
bool bool
MK_VIII::ConfigurationModule::read_radio_altitude_input_select (int value) MK_VIII::ConfigurationModule::read_radio_altitude_input_select (int value)
{ {
// unimplemented if (value >= 0 && value <= 2)
mk->io_handler.conf.use_gear_altitude = true;
else
mk->io_handler.conf.use_gear_altitude = false;
return (value >= 0 && value <= 4) || (value >= 251 && value <= 255); return (value >= 0 && value <= 4) || (value >= 251 && value <= 255);
} }
@ -732,7 +737,10 @@ MK_VIII::ConfigurationModule::read_navigation_input_select (int value)
bool bool
MK_VIII::ConfigurationModule::read_attitude_input_select (int value) MK_VIII::ConfigurationModule::read_attitude_input_select (int value)
{ {
// unimplemented if (value == 2)
mk->io_handler.conf.use_attitude_indicator=true;
else
mk->io_handler.conf.use_attitude_indicator=false;
return (value >= 0 && value <= 6) || value == 253 || value == 255; return (value >= 0 && value <= 6) || value == 253 || value == 255;
} }
@ -1144,9 +1152,13 @@ MK_VIII::IOHandler::update_inputs ()
mk_ainput(barometric_altitude_rate).set(mk_node(vs)->getDoubleValue() * 60); mk_ainput(barometric_altitude_rate).set(mk_node(vs)->getDoubleValue() * 60);
if (mk_ainput_feed(radio_altitude)) if (mk_ainput_feed(radio_altitude))
{ {
double agl;
if (conf.use_gear_altitude)
agl = mk_node(altitude_gear_agl)->getDoubleValue();
else
agl = mk_node(altitude_agl)->getDoubleValue();
// Some flight models may return negative values when on the // Some flight models may return negative values when on the
// ground or after a crash; do not allow them. // ground or after a crash; do not allow them.
double agl = mk_node(altitude_agl)->getDoubleValue();
mk_ainput(radio_altitude).set(SG_MAX2(0.0, agl)); mk_ainput(radio_altitude).set(SG_MAX2(0.0, agl));
} }
if (mk_ainput_feed(glideslope_deviation)) if (mk_ainput_feed(glideslope_deviation))
@ -1164,11 +1176,20 @@ MK_VIII::IOHandler::update_inputs ()
} }
if (mk_ainput_feed(roll_angle)) if (mk_ainput_feed(roll_angle))
{ {
if (conf.use_attitude_indicator)
{
// read data from attitude indicator instrument (requires vacuum system to work)
if (mk_node(ai_serviceable)->getBoolValue() && ! mk_node(ai_caged)->getBoolValue()) if (mk_node(ai_serviceable)->getBoolValue() && ! mk_node(ai_caged)->getBoolValue())
mk_ainput(roll_angle).set(mk_node(ai_roll)->getDoubleValue()); mk_ainput(roll_angle).set(mk_node(ai_roll)->getDoubleValue());
else else
mk_ainput(roll_angle).unset(); mk_ainput(roll_angle).unset();
} }
else
{
// use simulator source
mk_ainput(roll_angle).set(mk_node(orientation_roll)->getDoubleValue());
}
}
if (mk_ainput_feed(localizer_deviation)) if (mk_ainput_feed(localizer_deviation))
{ {
if (mk_node(nav0_serviceable)->getBoolValue() if (mk_node(nav0_serviceable)->getBoolValue()
@ -2624,6 +2645,8 @@ MK_VIII::SelfTestHandler::stop ()
button_pressed = false; button_pressed = false;
state = STATE_NONE; state = STATE_NONE;
// reset self-test handler position
current=0;
} }
} }
@ -3764,6 +3787,7 @@ MK_VIII::Mode4Handler::update_ab ()
} }
mk_unset_alerts(mk_alert(MODE4_TOO_LOW_FLAPS) | mk_alert(MODE4_TOO_LOW_GEAR)); mk_unset_alerts(mk_alert(MODE4_TOO_LOW_FLAPS) | mk_alert(MODE4_TOO_LOW_GEAR));
ab_bias=0.0;
} }
void void
@ -3789,6 +3813,7 @@ MK_VIII::Mode4Handler::update_ab_expanded ()
} }
mk_unset_alerts(mk_alert(MODE4AB_TOO_LOW_TERRAIN)); mk_unset_alerts(mk_alert(MODE4AB_TOO_LOW_TERRAIN));
ab_expanded_bias=0.0;
} }
void void
@ -3805,7 +3830,10 @@ MK_VIII::Mode4Handler::update_c ()
&& mk_data(radio_altitude).get() < mk_data(terrain_clearance).get()) && mk_data(radio_altitude).get() < mk_data(terrain_clearance).get())
handle_alert(mk_alert(MODE4C_TOO_LOW_TERRAIN), mk_data(terrain_clearance).get(), &c_bias); handle_alert(mk_alert(MODE4C_TOO_LOW_TERRAIN), mk_data(terrain_clearance).get(), &c_bias);
else else
{
mk_unset_alerts(mk_alert(MODE4C_TOO_LOW_TERRAIN)); mk_unset_alerts(mk_alert(MODE4C_TOO_LOW_TERRAIN));
c_bias=0.0;
}
} }
void void

View file

@ -200,6 +200,8 @@ class MK_VIII : public SGSubsystem
SGPropertyNode_ptr altimeter_serviceable; SGPropertyNode_ptr altimeter_serviceable;
SGPropertyNode_ptr altitude; SGPropertyNode_ptr altitude;
SGPropertyNode_ptr altitude_agl; SGPropertyNode_ptr altitude_agl;
SGPropertyNode_ptr altitude_gear_agl;
SGPropertyNode_ptr orientation_roll;
SGPropertyNode_ptr asi_serviceable; SGPropertyNode_ptr asi_serviceable;
SGPropertyNode_ptr asi_speed; SGPropertyNode_ptr asi_speed;
SGPropertyNode_ptr autopilot_heading_lock; SGPropertyNode_ptr autopilot_heading_lock;
@ -479,6 +481,8 @@ public:
bool alternate_steep_approach; bool alternate_steep_approach;
bool use_internal_gps; bool use_internal_gps;
bool localizer_enabled; bool localizer_enabled;
bool use_gear_altitude;
bool use_attitude_indicator;
} conf; } conf;
struct _s_input_feeders struct _s_input_feeders
@ -1358,7 +1362,7 @@ private:
} conf; } conf;
inline Mode4Handler (MK_VIII *device) inline Mode4Handler (MK_VIII *device)
: mk(device) {} : mk(device),ab_bias(0.0),ab_expanded_bias(0.0),c_bias(0.0) {}
double get_upper_agl (const EnvelopesConfiguration *c); double get_upper_agl (const EnvelopesConfiguration *c);
void update (); void update ();
@ -1402,7 +1406,7 @@ private:
public: public:
inline Mode5Handler (MK_VIII *device) inline Mode5Handler (MK_VIII *device)
: mk(device) {} : mk(device), soft_bias(0.0) {}
void update (); void update ();
}; };

View file

@ -38,7 +38,6 @@
#include <osgDB/FileNameUtils> #include <osgDB/FileNameUtils>
#include <simgear/scene/util/RenderConstants.hxx> #include <simgear/scene/util/RenderConstants.hxx>
#include <simgear/screen/extensions.hxx>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <Main/globals.hxx> #include <Main/globals.hxx>

View file

@ -240,7 +240,9 @@ static string fgScanForOption( const string& option ) {
// Read in configuration (files and command line options) but only set // Read in configuration (files and command line options) but only set
// fg_root // fg_root and aircraft_paths, which are needed *before* do_options() is called
// in fgInitConfig
bool fgInitFGRoot ( int argc, char **argv ) { bool fgInitFGRoot ( int argc, char **argv ) {
string root; string root;
@ -291,7 +293,7 @@ bool fgInitFGRoot ( int argc, char **argv ) {
SG_LOG(SG_INPUT, SG_INFO, "fg_root = " << root ); SG_LOG(SG_INPUT, SG_INFO, "fg_root = " << root );
globals->set_fg_root(root); globals->set_fg_root(root);
return true; return true;
} }
@ -299,6 +301,21 @@ bool fgInitFGRoot ( int argc, char **argv ) {
// Read in configuration (files and command line options) but only set // Read in configuration (files and command line options) but only set
// aircraft // aircraft
bool fgInitFGAircraft ( int argc, char **argv ) { bool fgInitFGAircraft ( int argc, char **argv ) {
string aircraftDir = fgScanForOption("--fg-aircraft=", argc, argv);
if (aircraftDir.empty()) {
aircraftDir = fgScanForOption("--fg-aircraft=");
}
const char* envp = ::getenv("FG_AIRCRAFT");
if (aircraftDir.empty() && envp) {
globals->append_aircraft_paths(envp);
}
if (!aircraftDir.empty()) {
globals->append_aircraft_paths(aircraftDir);
}
string aircraft; string aircraft;
// First parse command line options looking for --aircraft=, this // First parse command line options looking for --aircraft=, this
@ -501,13 +518,13 @@ do_options (int argc, char ** argv)
} }
template <class T> template <class T>
void fgFindAircraftInDir(const SGPath& dirPath, T* obj, bool (T::*pred)(const SGPath& p)) bool fgFindAircraftInDir(const SGPath& dirPath, T* obj, bool (T::*pred)(const SGPath& p))
{ {
if (!dirPath.exists()) { if (!dirPath.exists()) {
SG_LOG(SG_GENERAL, SG_WARN, "fgFindAircraftInDir: no such path:" << dirPath.str()); SG_LOG(SG_GENERAL, SG_WARN, "fgFindAircraftInDir: no such path:" << dirPath.str());
return; return false;
} }
bool recurse = true; bool recurse = true;
simgear::Dir dir(dirPath); simgear::Dir dir(dirPath);
simgear::PathList setFiles(dir.children(simgear::Dir::TYPE_FILE, "-set.xml")); simgear::PathList setFiles(dir.children(simgear::Dir::TYPE_FILE, "-set.xml"));
@ -520,20 +537,44 @@ void fgFindAircraftInDir(const SGPath& dirPath, T* obj, bool (T::*pred)(const SG
bool done = (obj->*pred)(*p); bool done = (obj->*pred)(*p);
if (done) { if (done) {
return; return true;
} }
} // of -set.xml iteration } // of -set.xml iteration
if (recurse) { if (!recurse) {
simgear::PathList subdirs(dir.children(simgear::Dir::TYPE_DIR | simgear::Dir::NO_DOT_OR_DOTDOT)); return false;
for (p = subdirs.begin(); p != subdirs.end(); ++p) { }
if (p->file() == "CVS") {
continue; simgear::PathList subdirs(dir.children(simgear::Dir::TYPE_DIR | simgear::Dir::NO_DOT_OR_DOTDOT));
} for (p = subdirs.begin(); p != subdirs.end(); ++p) {
if (p->file() == "CVS") {
fgFindAircraftInDir(*p, obj, pred); continue;
} }
} // of recursive case
if (fgFindAircraftInDir(*p, obj, pred)) {
return true;
}
} // of subdirs iteration
return false;
}
template <class T>
void fgFindAircraft(T* obj, bool (T::*pred)(const SGPath& p))
{
const string_list& paths(globals->get_aircraft_paths());
string_list::const_iterator it = paths.begin();
for (; it != paths.end(); ++it) {
bool done = fgFindAircraftInDir(SGPath(*it), obj, pred);
if (done) {
return;
}
} // of aircraft paths iteration
// if we reach this point, search the default location (always last)
SGPath rootAircraft(globals->get_fg_root());
rootAircraft.append("Aircraft");
fgFindAircraftInDir(rootAircraft, obj, pred);
} }
class FindAndCacheAircraft class FindAndCacheAircraft
@ -559,11 +600,8 @@ public:
n->setStringValue(globals->get_fg_root().c_str()); n->setStringValue(globals->get_fg_root().c_str());
n->setAttribute(SGPropertyNode::USERARCHIVE, true); n->setAttribute(SGPropertyNode::USERARCHIVE, true);
_cache->removeChildren("aircraft"); _cache->removeChildren("aircraft");
SGPath aircraftDir(globals->get_fg_root()); fgFindAircraft(this, &FindAndCacheAircraft::checkAircraft);
aircraftDir.append("Aircraft");
fgFindAircraftInDir(aircraftDir, this, &FindAndCacheAircraft::checkAircraft);
} }
if (_foundPath.str().empty()) { if (_foundPath.str().empty()) {

View file

@ -234,6 +234,82 @@ void FGGlobals::set_fg_scenery (const string &scenery)
} // of path list iteration } // of path list iteration
} }
void FGGlobals::append_aircraft_path(const std::string& path)
{
SGPath dirPath(path);
if (!dirPath.exists()) {
SG_LOG(SG_GENERAL, SG_WARN, "aircraft path not found:" << path);
return;
}
fg_aircraft_dirs.push_back(path);
}
void FGGlobals::append_aircraft_paths(const std::string& path)
{
string_list paths = sgPathSplit(path);
for (unsigned int p = 0; p<paths.size(); ++p) {
append_aircraft_path(paths[p]);
}
}
SGPath FGGlobals::resolve_aircraft_path(const std::string& branch) const
{
string_list pieces(sgPathBranchSplit(branch));
if ((pieces.size() < 3) || (pieces.front() != "Aircraft")) {
SG_LOG(SG_AIRCRAFT, SG_ALERT, "resolve_aircraft_path: bad path:" << branch);
return SGPath();
}
// check current aircraft dir first (takes precedence, allows Generics to be
// over-riden
const char* aircraftDir = fgGetString("/sim/aircraft-dir");
string_list aircraftDirPieces(sgPathBranchSplit(aircraftDir));
if (!aircraftDirPieces.empty() && (aircraftDirPieces.back() == pieces[1])) {
SGPath r(aircraftDir);
for (unsigned int i=2; i<pieces.size(); ++i) {
r.append(pieces[i]);
}
if (r.exists()) {
std::cout << "using aircraft-dir for:" << r.str() << std::endl;
return r;
}
} // of using aircraft-dir case
// try each fg_aircraft_dirs in turn
for (unsigned int p=0; p<fg_aircraft_dirs.size(); ++p) {
SGPath r(fg_aircraft_dirs[p]);
r.append(branch);
if (r.exists()) {
std::cout << "using aircraft directory for:" << r.str() << std::endl;
return r;
}
} // of fg_aircraft_dirs iteration
// finally, try fg_root
SGPath r(fg_root);
r.append(branch);
if (r.exists()) {
std::cout << "using FG_ROOT for:" << r.str() << std::endl;
return r;
}
SG_LOG(SG_AIRCRAFT, SG_ALERT, "resolve_aircraft_path: failed to resolve:" << branch);
return SGPath();
}
SGPath FGGlobals::resolve_maybe_aircraft_path(const std::string& branch) const
{
if (branch.find("Aircraft/") == 0) {
return resolve_aircraft_path(branch);
} else {
SGPath r(fg_root);
r.append(branch);
return r;
}
}
FGRenderer * FGRenderer *
FGGlobals::get_renderer () const FGGlobals::get_renderer () const

View file

@ -27,6 +27,7 @@
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/props/props.hxx> #include <simgear/props/props.hxx>
#include <simgear/structure/subsystem_mgr.hxx> #include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/misc/sg_path.hxx>
#include <vector> #include <vector>
#include <string> #include <string>
@ -181,6 +182,8 @@ private:
//Mulitplayer managers //Mulitplayer managers
FGMultiplayMgr *multiplayer_mgr; FGMultiplayMgr *multiplayer_mgr;
/// roots of Aircraft trees
string_list fg_aircraft_dirs;
public: public:
FGGlobals(); FGGlobals();
@ -212,6 +215,26 @@ public:
inline const string_list &get_fg_scenery () const { return fg_scenery; } inline const string_list &get_fg_scenery () const { return fg_scenery; }
void set_fg_scenery (const std::string &scenery); void set_fg_scenery (const std::string &scenery);
const string_list& get_aircraft_paths() const { return fg_aircraft_dirs; }
void append_aircraft_path(const std::string& path);
void append_aircraft_paths(const std::string& path);
/**
* Given a path to an aircraft-related resource file, resolve it
* against the appropriate root. This means looking at the location
* defined by /sim/aircraft-dir, and then aircraft_path in turn,
* finishing with fg_root/Aircraft.
*
* if the path could not be resolved, an empty path is returned.
*/
SGPath resolve_aircraft_path(const std::string& branch) const;
/**
* Same as above, but test for non 'Aircraft/' branch paths, and
* always resolve them against fg_root.
*/
SGPath resolve_maybe_aircraft_path(const std::string& branch) const;
inline const std::string &get_browser () const { return browser; } inline const std::string &get_browser () const { return browser; }
void set_browser (const std::string &b) { browser = b; } void set_browser (const std::string &b) { browser = b; }

View file

@ -342,7 +342,7 @@ static void fgMainLoop( void ) {
// implementation is an AI model and depends on that // implementation is an AI model and depends on that
globals->get_multiplayer_mgr()->Update(); globals->get_multiplayer_mgr()->Update();
#if ENABLE_ATCDCL #if ENABLE_ATCDCL
// Run ATC subsystem // Run ATC subsystem
if (fgGetBool("/sim/atc/enabled")) if (fgGetBool("/sim/atc/enabled"))
globals->get_ATC_mgr()->update(delta_time_sec); globals->get_ATC_mgr()->update(delta_time_sec);
@ -493,6 +493,20 @@ struct GeneralInitOperation : public GraphicsContextOperation
SG_LOG ( SG_GENERAL, SG_INFO, "Depth buffer bits = " << tmp ); SG_LOG ( SG_GENERAL, SG_INFO, "Depth buffer bits = " << tmp );
} }
}; };
osg::Node* load_panel(SGPropertyNode *n)
{
osg::Geode* geode = new osg::Geode;
geode->addDrawable(new FGPanelNode(n));
return geode;
}
SGPath resolve_path(const std::string& s)
{
return globals->resolve_maybe_aircraft_path(s);
}
} }
// This is the top level master main function that is registered as // This is the top level master main function that is registered as
@ -573,8 +587,10 @@ static void fgIdleFunction ( void ) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
globals->set_matlib( new SGMaterialLib ); globals->set_matlib( new SGMaterialLib );
simgear::SGModelLib::init(globals->get_fg_root()); simgear::SGModelLib::init(globals->get_fg_root());
simgear::SGModelLib::setPropRoot(globals->get_props());
simgear::SGModelLib::setResolveFunc(resolve_path);
simgear::SGModelLib::setPanelFunc(load_panel);
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Initialize the TG scenery subsystem. // Initialize the TG scenery subsystem.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View file

@ -114,6 +114,7 @@ fgSetDefaults ()
// Otherwise, default to Scenery being in $FG_ROOT/Scenery // Otherwise, default to Scenery being in $FG_ROOT/Scenery
globals->set_fg_scenery(""); globals->set_fg_scenery("");
} }
// Position (deliberately out of range) // Position (deliberately out of range)
fgSetDouble("/position/longitude-deg", 9999.0); fgSetDouble("/position/longitude-deg", 9999.0);
fgSetDouble("/position/latitude-deg", 9999.0); fgSetDouble("/position/latitude-deg", 9999.0);
@ -772,7 +773,7 @@ fgOptRoc( const char *arg )
static int static int
fgOptFgRoot( const char *arg ) fgOptFgRoot( const char *arg )
{ {
globals->set_fg_root(arg); // this option is dealt with by fgInitFGRoot
return FG_OPTIONS_OK; return FG_OPTIONS_OK;
} }
@ -783,6 +784,13 @@ fgOptFgScenery( const char *arg )
return FG_OPTIONS_OK; return FG_OPTIONS_OK;
} }
static int
fgOptFgAircraft(const char* arg)
{
// this option is dealt with by fgInitFGAircraft
return FG_OPTIONS_OK;
}
static int static int
fgOptFov( const char *arg ) fgOptFov( const char *arg )
{ {
@ -1339,6 +1347,7 @@ struct OptionDesc {
{"roc", true, OPTION_FUNC, "", false, "", fgOptRoc }, {"roc", true, OPTION_FUNC, "", false, "", fgOptRoc },
{"fg-root", true, OPTION_FUNC, "", false, "", fgOptFgRoot }, {"fg-root", true, OPTION_FUNC, "", false, "", fgOptFgRoot },
{"fg-scenery", true, OPTION_FUNC, "", false, "", fgOptFgScenery }, {"fg-scenery", true, OPTION_FUNC, "", false, "", fgOptFgScenery },
{"fg-aircraft", true, OPTION_FUNC, "", false, "", fgOptFgAircraft },
{"fdm", true, OPTION_STRING, "/sim/flight-model", false, "", 0 }, {"fdm", true, OPTION_STRING, "/sim/flight-model", false, "", 0 },
{"aero", true, OPTION_STRING, "/sim/aero", false, "", 0 }, {"aero", true, OPTION_STRING, "/sim/aero", false, "", 0 },
{"aircraft-dir", true, OPTION_STRING, "/sim/aircraft-dir", false, "", 0 }, {"aircraft-dir", true, OPTION_STRING, "/sim/aircraft-dir", false, "", 0 },
@ -1622,7 +1631,7 @@ fgParseArgs (int argc, char **argv)
bool verbose = false; bool verbose = false;
bool help = false; bool help = false;
SG_LOG(SG_GENERAL, SG_INFO, "Processing command line arguments"); SG_LOG(SG_GENERAL, SG_ALERT, "Processing command line arguments");
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
string arg = argv[i]; string arg = argv[i];

View file

@ -57,7 +57,6 @@
#include <osgDB/WriteFile> #include <osgDB/WriteFile>
#include <simgear/math/SGMath.hxx> #include <simgear/math/SGMath.hxx>
#include <simgear/screen/extensions.hxx>
#include <simgear/scene/material/matlib.hxx> #include <simgear/scene/material/matlib.hxx>
#include <simgear/scene/model/animation.hxx> #include <simgear/scene/model/animation.hxx>
#include <simgear/scene/model/placement.hxx> #include <simgear/scene/model/placement.hxx>

View file

@ -2,7 +2,6 @@
#ifndef __FG_RENDERER_HXX #ifndef __FG_RENDERER_HXX
#define __FG_RENDERER_HXX 1 #define __FG_RENDERER_HXX 1
#include <simgear/screen/extensions.hxx>
#include <simgear/scene/util/SGPickCallback.hxx> #include <simgear/scene/util/SGPickCallback.hxx>
#include <osg/ref_ptr> #include <osg/ref_ptr>

View file

@ -197,9 +197,10 @@ static osg::Node* fgCreateSplashCamera()
tpath.append( "Textures/Splash" ); tpath.append( "Textures/Splash" );
tpath.concat( num_str ); tpath.concat( num_str );
tpath.concat( ".png" ); tpath.concat( ".png" );
} else } else {
tpath.append( splash_texture ); tpath = globals->resolve_maybe_aircraft_path(splash_texture);
}
osg::Texture2D* splashTexture = new osg::Texture2D; osg::Texture2D* splashTexture = new osg::Texture2D;
splashTexture->setImage(osgDB::readImageFile(tpath.c_str())); splashTexture->setImage(osgDB::readImageFile(tpath.c_str()));

View file

@ -22,15 +22,6 @@
using std::vector; using std::vector;
using namespace simgear; using namespace simgear;
static
osg::Node* load_panel(SGPropertyNode *n)
{
osg::Geode* geode = new osg::Geode;
geode->addDrawable(new FGPanelNode(n));
return geode;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Global functions. // Global functions.
@ -39,7 +30,7 @@ osg::Node* load_panel(SGPropertyNode *n)
osg::Node * osg::Node *
fgLoad3DModelPanel(const string &path, SGPropertyNode *prop_root) fgLoad3DModelPanel(const string &path, SGPropertyNode *prop_root)
{ {
osg::Node* node = SGModelLib::loadModel(path, prop_root, load_panel); osg::Node* node = SGModelLib::loadModel(path, prop_root);
if (node) if (node)
node->setNodeMask(~SG_NODEMASK_TERRAIN_BIT); node->setNodeMask(~SG_NODEMASK_TERRAIN_BIT);
return node; return node;

View file

@ -750,8 +750,7 @@ void FGNasalSys::loadPropertyScripts()
while((fn = n->getChild("file", j)) != NULL) { while((fn = n->getChild("file", j)) != NULL) {
file_specified = true; file_specified = true;
const char* file = fn->getStringValue(); const char* file = fn->getStringValue();
SGPath p(globals->get_fg_root()); SGPath p = globals->resolve_maybe_aircraft_path(file);
p.append(file);
loadModule(p, module); loadModule(p, module);
j++; j++;
} }

View file

@ -69,13 +69,12 @@ FGFX::init()
SGPropertyNode *node = fgGetNode("/sim/sound", true); SGPropertyNode *node = fgGetNode("/sim/sound", true);
string path_str = node->getStringValue("path"); string path_str = node->getStringValue("path");
SGPath path( globals->get_fg_root() );
if (path_str.empty()) { if (path_str.empty()) {
SG_LOG(SG_GENERAL, SG_ALERT, "No path in /sim/sound/path"); SG_LOG(SG_GENERAL, SG_ALERT, "No path in /sim/sound/path");
return; return;
} }
path.append(path_str.c_str()); SGPath path = globals->resolve_aircraft_path(path_str);
SG_LOG(SG_GENERAL, SG_INFO, "Reading sound " << node->getName() SG_LOG(SG_GENERAL, SG_INFO, "Reading sound " << node->getName()
<< " from " << path.str()); << " from " << path.str());

View file

@ -34,8 +34,7 @@ FGSystemMgr::FGSystemMgr ()
SGPropertyNode *path_n = fgGetNode("/sim/systems/path"); SGPropertyNode *path_n = fgGetNode("/sim/systems/path");
if (path_n) { if (path_n) {
SGPath config( globals->get_fg_root() ); SGPath config = globals->resolve_aircraft_path(path_n->getStringValue());
config.append( path_n->getStringValue() );
SG_LOG( SG_ALL, SG_INFO, "Reading systems from " SG_LOG( SG_ALL, SG_INFO, "Reading systems from "
<< config.str() ); << config.str() );

View file

@ -33,7 +33,6 @@
* *
* TODO: * TODO:
* - Check the code for known portability issues * - Check the code for known portability issues
* - Find an alternative for the depricated Point3D class
* *
*****************************************************************************/ *****************************************************************************/

View file

@ -496,7 +496,6 @@ bool compareSchedules(FGAISchedule*a, FGAISchedule*b)
// double course; // double course;
// double dist; // double dist;
// Point3D temp;
// time_t // time_t
// totalTimeEnroute, // totalTimeEnroute,
// elapsedTimeEnroute; // elapsedTimeEnroute;

View file

@ -1,6 +1,6 @@
bin_PROGRAMS = est-epsilon gl-info alcinfo bin_PROGRAMS = est-epsilon gl-info alcinfo
noinst_PROGRAMS = test-gethostname test-mktime test-text test-up test-env-map noinst_PROGRAMS = test-gethostname test-mktime test-text test-env-map
if HAVE_FRAMEWORK_PLIB if HAVE_FRAMEWORK_PLIB
test_up_LDFLAGS = $(plib_FRAMEWORK) test_up_LDFLAGS = $(plib_FRAMEWORK)
@ -26,5 +26,3 @@ test_mktime_SOURCES = test-mktime.cxx
test_text_SOURCES = test-text.cxx test_text_SOURCES = test-text.cxx
test_up_SOURCES = test-up.cxx
test_up_LDADD = $(test_up_PLIB_LIBS) -lsgmath -lsgxml -lsgmisc -lsgdebug -lsgstructure -lsgtiming -lz $(base_LIBS)