Advanced weather: Difference between revisions

m
→‎Creating custom Weather Tiles: http://forum.flightgear.org/viewtopic.php?f=69&t=23120&p=210238#p210214
m (→‎Creating custom Weather Tiles: http://forum.flightgear.org/viewtopic.php?f=69&t=23120&p=210238#p210206)
m (→‎Creating custom Weather Tiles: http://forum.flightgear.org/viewtopic.php?f=69&t=23120&p=210238#p210214)
Line 105: Line 105:
Advanced Weather allows to specify a weather effect volume by function (like the distribution of lift inside thermals is implemented) and such a dedicated windshear function could be simulated close to the ground. The required tool is Nasal, FGs scripting language.
Advanced Weather allows to specify a weather effect volume by function (like the distribution of lift inside thermals is implemented) and such a dedicated windshear function could be simulated close to the ground. The required tool is Nasal, FGs scripting language.


There are other possibilities, you might for instance try to alter the generic boundary layer code of Advanced Weather to add automatic windshear detection, or you might alter the C++ code of Basic Weather - it really depends on what information you have and what you'd like to do.
Nasal files are usually *.nas files, they are program code, not just "configuration files". So you will want to check out $FG_ROOT/Nasal/local_weather and in particular, see the various "tiles" in weather_tiles.nas
 


You probably want to have a look at the effect volume management routines. Basically you want to write something analogous to thermal_lift_start(), thermal_lift_stop() and thermal_lift_loop() in /Nasal/local_weather/local_weather.nas and use the management routines of effect_volume_loop()
You probably want to have a look at the effect volume management routines. Basically you want to write something analogous to thermal_lift_start(), thermal_lift_stop() and thermal_lift_loop() in /Nasal/local_weather/local_weather.nas and use the management routines of effect_volume_loop()
You'd have the best control over weather just defining your own specific tile (see the various tiles in weather_tiles.nas - a minimal structure might be


<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
####################################
# my own tile
####################################
var set_my_own_tile = func {
setprop(lw~"tiles/code","myown");
tile_start();
var x = 0.0;
var y = 0.0;
var lat = 0.0;
var lon = 0.0;
var alpha = getprop(lw~"tmp/tile-orientation-deg");
var phi = alpha * math.pi/180.0;
var alt_offset = getprop(lw~"tmp/tile-alt-offset-ft");
# get tile center coordinates
var blat = getprop(lw~"tiles/tmp/latitude-deg");
var blon = getprop(lw~"tiles/tmp/longitude-deg");
calc_geo(blat);
# first weather info for tile center (lat, lon, visibility, temperature, dew point, pressure)
local_weather.set_weather_station(blat, blon, alt_offset, 45000.0, 14.0, 12.0, 29.78);
var alt_offset = getprop(lw~"tmp/tile-alt-offset-ft");
# draw some clouds
create_2_8_altocumulus_streaks(blat, blon, 12000+alt_offset, alpha) ;
create_6_8_stratus(blat, blon, 3000+alt_offset, alpha) ;


# set visibility and light attenuation as a function of altitude
local_weather.set_atmosphere_ipoint(blat, blon, 45000.0, 3000.0, 45000.0, 0.0, 15000.0, 17000.0, 0.8, 12000.0, 17000.0);
append(weather_dynamics.tile_convective_altitude,3000.0);
append(weather_dynamics.tile_convective_strength,0.0);
tile_finished();
}
</syntaxhighlight>
</syntaxhighlight>
which controls all clouds/visibility. Turbulence can be coded into that as an effect volume spanning the whole tile (as e.g. for the coldfront). Wind is read from the menu, so the properties need to be set accordingly.
METAR strings give you a lower level of control (you can't control the precise clouds being drawn and the vertical structure of the atmosphere that way).


If you have a Nasal subroutine creating the wind field, Thorsten (get in touch via the forum) volunteers to provide integration help you with implementing it in the correct places.
If you have a Nasal subroutine creating the wind field, Thorsten (get in touch via the forum) volunteers to provide integration help you with implementing it in the correct places.
There are other possibilities, you might for instance try to alter the generic boundary layer code of Advanced Weather to add automatic windshear detection, or you might alter the C++ code of Basic Weather - it really depends on what information you have and what you'd like to do.


== Related Discussions ==
== Related Discussions ==