The model manager allows to add models at runtime. Most often
they are static (-> geo.put_model()), but one can also
register them with adjustable position/orientation properties.
If the object was moving (independently or placed relative
to a moving aircraft), then one used to run into a nasty
fluttering problem: the model didn't keep a constant distance
to the aircraft, but -- depending on the speed -- fell behind,
jumped forward again, etc.
This should now be fixed. It's possible to attach objects
to an aircraft or to put an independently moving object
(e.g. tanker) in the scenery without any flickering/fluttering.
It's possible to put a jeep in the C130, let an animated
(female) flight attendent bring coffee to the cockpit etc. :-)
See the attached example -- put it in ~/.fgfs/Nasal/. It
will place a cow in front of the aircraft.
m.
var model = props.globals.getNode("/models");
# find first free /models/model[*] slot
for (var i = 0; 1; i += 1) {
if (model.getChild("model", i, 0) == nil) {
model = model.getChild("model", i, 1);
break;
}
}
# create entry for the model manager
var data = "/sim/model/cow/";
model.setValues({
"path": "Models/Fauna/cow.ac",
"latitude-deg-prop": data ~ "latitude-deg",
"longitude-deg-prop": data ~ "longitude-deg",
"elevation-ft-prop": data ~ "altitude-ft",
"heading-deg-prop": data ~ "heading-deg",
"pitch-deg-prop": data ~ "pitch-deg",
"roll-deg-prop": data ~ "roll-deg",
});
# load the model (and remove the "load" node immediately)
model.getNode("load", 1).remove();
var update_model = func {
var heading = getprop("/orientation/heading-deg");
var pitch = getprop("/orientation/pitch-deg");
var roll = getprop("/orientation/roll-deg");
var ac = geo.aircraft_position();
ac.apply_course_distance(heading, 10);
setprop(data ~ "latitude-deg", ac.lat());
setprop(data ~ "longitude-deg", ac.lon());
setprop(data ~ "altitude-ft", ac.alt() * geo.M2FT);
setprop(data ~ "heading-deg", heading + 180);
setprop(data ~ "pitch-deg", -pitch);
setprop(data ~ "roll-deg", -roll);
settimer(update_model, 0);
}
update_model();
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel