20,741
edits
(→Orbital Map: new section) |
|||
Line 105: | Line 105: | ||
<syntaxhighlight lang="nasal"> | <syntaxhighlight lang="nasal"> | ||
var groundtrack = root.createChild("path"); | var groundtrack = root.createChild("path"); | ||
</syntaxhighlight> | |||
== Orbital Map == | |||
{{FGCquote | |||
| [[File:Shuttle canvas.jpg|right|400px|[[Canvas]] and [[Nasal]] used for visualizing space shuttle trajectories]] | |||
this is probably rather crude, but it (sort of) works - I'm getting the current position of the shuttle as well as the selected landing site displayed. | |||
|{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=238358#p238358 | |||
|title=<nowiki>Re: Using Canvas for visualizing orbital flights (cont'd PM)</nowiki> | |||
|author=<nowiki>Thorsten</nowiki> | |||
|date=<nowiki>Sat Apr 11</nowiki> | |||
}} | |||
}} | |||
<syntaxhighlight lang="nasal"> | |||
var sym_shuttle = {}; | |||
var sym_landing_site = {}; | |||
var create_map = func { | |||
var window = canvas.Window.new([800,400],"dialog"); | |||
var mapCanvas = window.createCanvas().set("background", canvas.style.getColor("bg_color")); | |||
var root = mapCanvas.createGroup(); | |||
var path = "Aircraft/SpaceShuttle/Dialogs/MapOfEarth.png"; | |||
var child=root.createChild("image") | |||
.setFile( path ) | |||
.setTranslation(0,0) | |||
.setSize(800,400); | |||
sym_shuttle = mapCanvas.createGroup(); | |||
canvas.parsesvg(sym_shuttle, "/Nasal/canvas/map/Images/boeingAirplane.svg"); | |||
sym_shuttle.setScale(0.2); | |||
sym_landing_site = mapCanvas.createGroup(); | |||
canvas.parsesvg(sym_landing_site, "/gui/dialogs/images/ndb_symbol.svg"); | |||
sym_landing_site.setScale(0.6); | |||
map_update(); | |||
} | |||
var map_update = func { | |||
var lat = getprop("/position/latitude-deg"); | |||
var lon = getprop("/position/longitude-deg"); | |||
var x = 400.0 + lon /180. * 400.0 -10.0; | |||
var y = 200.0 - lat /90. * 200.0 -10.0; | |||
var heading = getprop("/orientation/heading-deg"); | |||
sym_shuttle.setTranslation(x,y); | |||
#symbol.setRotation(heading); | |||
x = 400.0 + landing_site.lon()/180 * 400.0 -10.0; | |||
y = 200.0 - landing_site.lat()/90. * 200.0 -10.0; | |||
sym_landing_site.setTranslation(x,y); | |||
settimer(map_update, 1.0); | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> |