geo.nas:
- add put_model() function to place models at given lon/lat. If elevation is nil, then it will be put on the surface. The path is relative to $FG_ROOT. - let geo.click_position() and geo.aircraft_position() return copies of the Coord class, not just a reference view.nas: adaptation for geo.nas change; minor changes
This commit is contained in:
parent
1a19f8a8e5
commit
02b4dc58e8
2 changed files with 31 additions and 8 deletions
|
@ -289,6 +289,29 @@ var tile_path = func(lon, lat) {
|
|||
}
|
||||
|
||||
|
||||
var put_model = func(path, lon, lat, elev_m = nil, hdg = 0, pitch = 0, roll = 0) {
|
||||
if (elev_m == nil)
|
||||
elev_m = elevation(lon, lat);
|
||||
if (elev_m == nil)
|
||||
die("can't get elevation for " ~ lon ~ "/" ~ lat);
|
||||
var n = props.globals.getNode("/models");
|
||||
for (var i = 0; 1; i += 1)
|
||||
if (n.getChild("model", i, 0) == nil)
|
||||
break;
|
||||
n = n.getChild("model", i, 1);
|
||||
n.getNode("path", 1).setValue(path);
|
||||
n.getNode("longitude-deg", 1).setDoubleValue(lon);
|
||||
n.getNode("latitude-deg", 1).setDoubleValue(lat);
|
||||
n.getNode("elevation-ft", 1).setDoubleValue(elev_m * FT2M);
|
||||
n.getNode("heading-deg", 1).setDoubleValue(hdg);
|
||||
n.getNode("pitch-deg", 1).setDoubleValue(pitch);
|
||||
n.getNode("roll-deg", 1).setDoubleValue(roll);
|
||||
n.getNode("load", 1).setBoolValue(1);
|
||||
n.removeChildren("load");
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
var terr_tree = nil;
|
||||
var terr_lon = nil;
|
||||
var terr_lat = nil;
|
||||
|
@ -305,13 +328,12 @@ var elevation = func(lon, lat) {
|
|||
var aircraft_lon = nil;
|
||||
var aircraft_lat = nil;
|
||||
var aircraft_alt = nil;
|
||||
var aircraft_coord = Coord.new();
|
||||
|
||||
var aircraft_position = func {
|
||||
var lon = aircraft_lon.getValue();
|
||||
var lat = aircraft_lat.getValue();
|
||||
var alt = aircraft_alt.getValue() * FT2M;
|
||||
return aircraft_coord.set_lonlat(lon, lat, alt);
|
||||
return Coord.new().set_lonlat(lon, lat, alt);
|
||||
}
|
||||
|
||||
|
||||
|
@ -329,7 +351,7 @@ _setlistener("/sim/signals/click", func {
|
|||
});
|
||||
|
||||
var click_position = func {
|
||||
return click_coord.is_defined() ? click_coord : nil;
|
||||
return click_coord.is_defined() ? Coord.new(click_coord) : nil;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -151,16 +151,17 @@ var flyby = {
|
|||
me.currview == me.number or return;
|
||||
me.chase = -getprop("/sim/chase-distance-m");
|
||||
me.course = me.hdgN.getValue();
|
||||
me.coord = geo.Coord.new().set(geo.aircraft_position());
|
||||
me.dist = 20;
|
||||
me.coord = geo.aircraft_position();
|
||||
me.setpos(1);
|
||||
me.dist = 20;
|
||||
me._loop_(me.loopid);
|
||||
},
|
||||
setpos : func(force = 0) {
|
||||
var pos = geo.aircraft_position();
|
||||
var dist = me.coord.distance_to(pos);
|
||||
if (dist < 1.7 * me.chase and !force)
|
||||
return;
|
||||
return 1.13;
|
||||
|
||||
var side = (rand() - 0.5 < 0) ? -90 : 90;
|
||||
var course = me.hdgN.getValue();
|
||||
pos.apply_course_distance(course, dist * 0.8);
|
||||
|
@ -177,11 +178,11 @@ var flyby = {
|
|||
me.latN.setValue(lat);
|
||||
me.altN.setValue(alt * geo.M2FT);
|
||||
me.coord.set_lonlat(lon, lat, alt);
|
||||
return 6.3;
|
||||
},
|
||||
_loop_ : func(id) {
|
||||
id == me.loopid or return;
|
||||
me.setpos();
|
||||
settimer(func { me._loop_(id) }, 6.3);
|
||||
settimer(func { me._loop_(id) }, me.setpos());
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue