X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2Ffg_commands.cxx;h=cf5efb8a5df4dc4e0a9d3fe3c3ee6edf99b414c3;hb=18d1593c42c2df60d7fb44ace722ca3e8a7fd82c;hp=96e7175afcd0f7e371272349a5ae84059368ab04;hpb=d9bfd5a425df1bad7e3c53a64adce871e299a6b9;p=flightgear.git diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index 96e7175af..cf5efb8a5 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -45,9 +46,9 @@ #include "viewmgr.hxx" #include "main.hxx" -SG_USING_STD(string); -SG_USING_STD(ifstream); -SG_USING_STD(ofstream); +using std::string; +using std::ifstream; +using std::ofstream; @@ -1179,6 +1180,33 @@ do_gui_redraw (const SGPropertyNode * arg) } +/** + * Adds model to the scenery. The path to the added branch (/models/model[*]) + * is returned in property "property". + */ +static bool +do_add_model (const SGPropertyNode * arg) +{ + SGPropertyNode * model = fgGetNode("models", true); + for (int i = 0;; i++) { + if (i < 0) + return false; + if (!model->getChild("model", i, false)) { + model = model->getChild("model", i, true); + break; + } + } + copyProperties(arg, model); + if (model->hasValue("elevation-m")) + model->setDoubleValue("elevation-ft", model->getDoubleValue("elevation-m") + * SG_METER_TO_FEET); + model->getNode("load", true); + model->removeChildren("load"); + const_cast(arg)->setStringValue("property", model->getPath()); + return true; +} + + /** * Set mouse cursor coordinates and cursor shape. */ @@ -1519,6 +1547,7 @@ static struct { { "dialog-update", do_dialog_update }, { "dialog-apply", do_dialog_apply }, { "gui-redraw", do_gui_redraw }, + { "add-model", do_add_model }, { "set-cursor", do_set_cursor }, { "play-audio-sample", do_play_audio_sample }, { "presets-commit", do_presets_commit },