add "add-model" command, which adds model properties to the first
free /models/model[*] slot and lets the model manager load the model. The target address is returned under "property". Simple use in Nasal: fgcommand("add-model", props.Node.new({ "path": "Models/Fauna/cow.ac", "latitude-deg": 16.234, "longitude-deg": 48.321, "elevation-ft": 300, }); An "elevation-m" property can alternatively be used and overrides the "elevation-ft" property. Each of the properties "latitude-deg", "longitude-deg", "elevation-ft", "heading-deg", "pitch-deg", and "roll-deg" can alternatively be used with "-prop" suffix. Their values must then be property path strings pointing to a node that can be changed at runtime to move the model.
This commit is contained in:
parent
54744f58e0
commit
12cf1c41ad
1 changed files with 28 additions and 0 deletions
|
@ -1180,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<SGPropertyNode *>(arg)->setStringValue("property", model->getPath());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set mouse cursor coordinates and cursor shape.
|
||||
*/
|
||||
|
@ -1520,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 },
|
||||
|
|
Loading…
Add table
Reference in a new issue