1
0
Fork 0

Advanced Weather update - new cloud placement algorithms part I

This commit is contained in:
Thorsten Renk 2013-04-09 09:41:27 +03:00
parent 55c599c8ca
commit 2f01deb6bd
5 changed files with 1056 additions and 143 deletions

View file

@ -384,13 +384,13 @@ else if (type == "Altocumulus"){
#characterize the cloud
cloudAssembly.bottom_shade = 0.7;
cloudAssembly.n_sprites = 10;
cloudAssembly.min_width = 400.0 * mult;
cloudAssembly.max_width = 700.0 * mult;
cloudAssembly.n_sprites = 6;
cloudAssembly.min_width = 40.0 * mult;
cloudAssembly.max_width = 600.0 * mult;
cloudAssembly.min_height = 400.0 * mult;
cloudAssembly.max_height = 700.0 * mult;
cloudAssembly.min_cloud_width = 1200 * mult * mult;
cloudAssembly.min_cloud_height = 1200 * mult * mult;
cloudAssembly.max_height = 600.0 * mult;
cloudAssembly.min_cloud_width = 1000 * mult * mult;
cloudAssembly.min_cloud_height = 1000 * mult * mult;
cloudAssembly.z_scale = 0.8;
#signal that new routines are used
@ -424,16 +424,15 @@ else if (type == "Stratus (structured)"){
#signal that new routines are used
path = "new";
}
else if (type == "Altocumulus perlucidus"){
# new code
else if (type == "Stratus structured CS"){
cloudAssembly = local_weather.cloud.new(type, subtype);
var mult = 1.0;
if (subtype == "small") {mult = 0.7;}
else {mult = 1.0;}
mult = mult * local_weather.cloud_size_scale;
# characterize the basic texture sheet
cloudAssembly.texture_sheet = "/Models/Weather/altocumulus_sheet1.rgb";
@ -441,7 +440,36 @@ else if (type == "Altocumulus perlucidus"){
cloudAssembly.num_tex_y = 3;
#characterize the cloud
cloudAssembly.bottom_shade = 0.8;
cloudAssembly.bottom_shade = 0.4;
cloudAssembly.n_sprites = 6;
cloudAssembly.min_width = 1000.0 * mult;
cloudAssembly.max_width = 1000.0 * mult;
cloudAssembly.min_height = 1000.0 * mult;
cloudAssembly.max_height = 1000.0 * mult;
cloudAssembly.min_cloud_width = 1305 * mult;
cloudAssembly.min_cloud_height = 1305.0 * mult;
cloudAssembly.z_scale = 0.3;
#signal that new routines are used
path = "new";
}
else if (type == "Altocumulus perlucidus"){
# new code
cloudAssembly = local_weather.cloud.new(type, subtype);
var mult = 1.0;
if (subtype == "small") {mult = 0.7;}
else if (subtype == "huge") {mult = 1.5;}
# characterize the basic texture sheet
cloudAssembly.texture_sheet = "/Models/Weather/altocumulus_sheet1.rgb";
cloudAssembly.num_tex_x = 3;
cloudAssembly.num_tex_y = 3;
#characterize the cloud
cloudAssembly.bottom_shade = 0.7;
cloudAssembly.n_sprites = 25;
cloudAssembly.min_width = 1700.0 * mult;
cloudAssembly.max_width = 2500.0 * mult;
@ -508,7 +536,7 @@ else if (type == "Cirrocumulus (cloudlet)") {
var mult = 1.0;
if (subtype == "small") {mult = 0.6;}
else {mult = 1.0;}
else if (subtype == "huge") {mult = 1.5;}
# characterize the basic texture sheet
cloudAssembly.texture_sheet = "/Models/Weather/cirrocumulus_sheet1.rgb";
@ -527,9 +555,6 @@ else if (type == "Cirrocumulus (cloudlet)") {
cloudAssembly.z_scale = 0.3;
path = "new";
}
else if (type == "Cirrocumulus (new)") {
@ -537,7 +562,7 @@ else if (type == "Cirrocumulus (new)") {
var mult = 1.0;
if (subtype == "small") {mult = 0.7;}
else {mult = 1.0;}
else {mult = 1.3;}
# characterize the basic texture sheet
cloudAssembly.texture_sheet = "/Models/Weather/cirrocumulus_sheet1.rgb";
@ -559,6 +584,36 @@ else if (type == "Cirrocumulus (new)") {
path = "new";
}
else if (type == "Fogpatch") {
cloudAssembly = local_weather.cloud.new(type, subtype);
var mult = 1.0;
if (subtype == "small") {mult = 0.7;}
else {mult = 1.0;}
mult = mult * local_weather.cloud_size_scale;
# characterize the basic texture sheet
cloudAssembly.texture_sheet = "/Models/Weather/fogpatch_sheet1.rgb";
cloudAssembly.num_tex_x = 1;
cloudAssembly.num_tex_y = 1;
#characterize the cloud
cloudAssembly.bottom_shade = 1.0;
cloudAssembly.n_sprites = 1;
cloudAssembly.min_width = 300.0 * mult;
cloudAssembly.max_width = 300.0 * mult;
cloudAssembly.min_height = 300.0 * mult;
cloudAssembly.max_height = 300.0 * mult;
cloudAssembly.min_cloud_width = 305.0 * mult;
cloudAssembly.min_cloud_height = 305.0 * mult;
cloudAssembly.z_scale = 0.5;
#signal that new routines are used
path = "new";
}
else if (type == "Nimbus") {
cloudAssembly = local_weather.cloud.new(type, subtype);
@ -698,6 +753,35 @@ else if (type == "Cirrostratus") {
path = "new";
}
else if (type == "Cirrostratus (small)") {
cloudAssembly = local_weather.cloud.new(type, subtype);
var mult = 1.0;
if (subtype == "small") {mult = 0.45;}
else {mult = 0.7;}
# characterize the basic texture sheet
cloudAssembly.texture_sheet = "/Models/Weather/cirrostratus_sheet1.rgb";
cloudAssembly.num_tex_x = 2;
cloudAssembly.num_tex_y = 2;
#characterize the cloud
cloudAssembly.bottom_shade = 1.0;
cloudAssembly.n_sprites = 2;
cloudAssembly.min_width = 3500.0 * mult;
cloudAssembly.max_width = 4000.0 * mult;
cloudAssembly.min_height = 3500.0 * mult;
cloudAssembly.max_height = 4000.0 * mult;
cloudAssembly.min_cloud_width = 4500.0 * mult;
cloudAssembly.min_cloud_height = 4500.0 * mult;
cloudAssembly.z_scale = 0.5;
#signal that new routines are used
path = "new";
}
else if (type == "Fog (thin)") {
if (subtype == "small") {
if (rn > 0.8) {path = "Models/Weather/stratus_thin1.xml";}

View file

@ -80,6 +80,190 @@ for (var i=0; i<ny; i=i+1)
}
###########################################################
# place an advanced undulatus pattern
###########################################################
var create_adv_undulatus = func (arg) {
var markov_array = [];
var rnd_array = [];
var max_num_clouds = int(arg.xsize/arg.cloud_spacing)+1;
var max_num_streaks = int(arg.ysize/arg.undulatus_spacing)+1;
var path = "Models/Weather/blank.ac";
var counter = 0;
append(markov_array,0.0);
var rn = 0.0;
arg.dir = arg.dir + 90.0;
for (var i=1; i<max_num_clouds; i=i+1)
{
rn = rand();
append(markov_array, markov_array[i-1] + 2.0 * (rn -0.5) * arg.undulatus_amplitude + arg.undulatus_slant);
append(rnd_array, rn);
}
for (i=0; i< max_num_streaks; i=i+1)
{
var streak_ypos = -0.5 * arg.ysize + i * arg.undulatus_spacing;
var aspect_num_clouds = int((arg.aspect + (1.0-arg.aspect) * i/max_num_streaks) * max_num_clouds);
for (var j = 0; j< aspect_num_clouds; j=j+1)
{
var y = streak_ypos + markov_array[j];
var x = -0.5 * arg.xsize + j * arg.cloud_spacing;
x = x - arg.Dx + 2.0 * rand() * arg.Dx;
y = y - arg.Dy + 2.0 * rand() * arg.Dy;
var flag = 0;
var bias =1.0 - (1.0* abs(i-0.5 * max_num_streaks)/max_num_streaks + 1.0* abs(j-0.5 * aspect_num_clouds)/aspect_num_clouds);
var comp = -.25 * rnd_array[j] + 0.75 * bias;
comp = comp + arg.size_bias;
if (comp > 0.7)
{
flag = 1;
path = select_cloud_model(arg.type,"large")
}
else if (comp > 0.4)
{
flag = 1;
path = select_cloud_model(arg.type,"small")
}
var lat = arg.blat + m_to_lat * (y * math.cos(arg.dir) - x * math.sin(arg.dir));
var lon = arg.blon + m_to_lon * (x * math.cos(arg.dir) + y * math.sin(arg.dir));
var alt = arg.balt + arg.alt_var * 2 * (rand() - 0.5);
if (flag > 0)
{create_cloud_vec(path, lat, lon, alt, 0.0); counter = counter +1;}
}
}
print("Cloud count: ",counter);
}
###########################################################
# place a stick bundle pattern
###########################################################
var sgn = func (x) {
if (x<0.0) {return -1.0;}
else {return 1.0;}
}
var create_stick_bundle = func (arg) {
var path = "Models/Weather/blank.ac";
var base_size_scale = local_weather.cloud_size_scale;
for (var i = 0; i<arg.n_sticks; i=i+1)
{
var stick_x = 0.5 * math.pow(rand(),2.0) * arg.xsize * sgn(rand()-0.5);
var stick_y = 0.5 * math.pow(rand(),2.0) * arg.ysize * sgn(rand()-0.5);
var stick_length = arg.stick_length_min + int(rand() * (arg.stick_length_max - arg.stick_length_min) );
var stick_Dphi = arg.stick_Dphi_min + rand() * (arg.stick_Dphi_max - arg.stick_Dphi_min);
var stick_size_scale = 0.8 + 0.2 * rand();
for (var j=0; j<stick_length;j=j+1)
{
var y = stick_y;
var x = stick_x - 0.5 * stick_length * arg.cloud_spacing;
var inc = j * arg.cloud_spacing;
var pos_size_scale = base_size_scale + base_size_scale * 2.0* (1.0 - 2.0* abs(0.5 * stick_length - j)/stick_length);
local_weather.cloud_size_scale = pos_size_scale;
local_weather.cloud_size_scale = stick_size_scale * local_weather.cloud_size_scale;
inc = inc * stick_size_scale;
x = x + inc * math.cos(stick_Dphi);
y = y + inc * math.sin(stick_Dphi);
x = x - arg.Dx + 2.0 * rand() * arg.Dx;
y = y - arg.Dy + 2.0 * rand() * arg.Dy;
path = select_cloud_model(arg.type,"large");
var lat = arg.blat + m_to_lat * (y * math.cos(arg.dir) - x * math.sin(arg.dir));
var lon = arg.blon + m_to_lon * (x * math.cos(arg.dir) + y * math.sin(arg.dir));
var alt = arg.balt + arg.alt_var * 2 * (rand() - 0.5);
create_cloud_vec(path, lat, lon, alt, 0.0);
}
}
}
###########################################################
# place a nested domains pattern
###########################################################
var create_domains = func (arg) {
var path = "Models/Weather/blank.ac";
for (var j=0; j<arg.n_domains; j=j+1)
{
var domain_pos_x = -0.5 * arg.xsize + rand() * arg.xsize;
var domain_pos_y = -0.5 * arg.ysize + rand() * arg.ysize;
var domain_size_x = arg.min_domain_size_x + rand() * (arg.max_domain_size_x - arg.min_domain_size_x);
var domain_size_y = arg.min_domain_size_y + rand() * (arg.max_domain_size_y - arg.min_domain_size_y);
var n_node = int(arg.node_fraction * arg.n);
var n_halo = int(arg.halo_fraction * arg.n);
var n_bulk = arg.n - n_node - n_halo;
for (var i=0; i<n_halo; i=i+1)
{
var x = domain_pos_x - 0.5 * domain_size_x + rand() * domain_size_x;
var y = domain_pos_y - 0.5 * domain_size_y + rand() * domain_size_y;
var lat = arg.blat + m_to_lat * (y * math.cos(arg.dir) - x * math.sin(arg.dir));
var lon = arg.blon + m_to_lon * (x * math.cos(arg.dir) + y * math.sin(arg.dir));
var alt = arg.balt + arg.alt_var * 2 * (rand() - 0.5);
if ((abs(x-domain_pos_x) < 0.3 * domain_size_x) or (abs(y-domain_pos_y) < 0.3 * domain_size_y))
{path = select_cloud_model(arg.htype,arg.hsubtype);
create_cloud_vec(path, lat, lon, alt, 0.0);}
}
for (i=0; i<n_bulk; i=i+1)
{
x = domain_pos_x - 0.5 * 0.4* domain_size_x + rand() * 0.4* domain_size_x;
y = domain_pos_y - 0.5 * 0.4* domain_size_y + rand() * 0.4* domain_size_y;
lat = arg.blat + m_to_lat * (y * math.cos(arg.dir) - x * math.sin(arg.dir));
lon = arg.blon + m_to_lon * (x * math.cos(arg.dir) + y * math.sin(arg.dir));
alt = arg.balt + arg.alt_var * 2 * (rand() - 0.5);
if ((abs(x-domain_pos_x) < 0.4 * domain_size_x) or (abs(y-domain_pos_y) < 0.4 * domain_size_y))
{
path = select_cloud_model(arg.type,arg.subtype);
create_cloud_vec(path, lat, lon, alt, 0.0);
}
}
for (i=0; i<n_node; i=i+1)
{
x = domain_pos_x - 0.5 * 0.1* domain_size_x + rand() * 0.1* domain_size_x;
y = domain_pos_y - 0.5 * 0.1* domain_size_y + rand() * 0.1* domain_size_y;
lat = arg.blat + m_to_lat * (y * math.cos(arg.dir) - x * math.sin(arg.dir));
lon = arg.blon + m_to_lon * (x * math.cos(arg.dir) + y * math.sin(arg.dir));
alt = arg.balt + arg.alt_var * 2 * (rand() - 0.5);
path = select_cloud_model(arg.ntype,arg.nsubtype);
create_cloud_vec(path, lat, lon, alt, 0.0);
}
}
}
###########################################################
# place a Cumulus alley pattern

View file

@ -1224,7 +1224,7 @@ if (ev.vis_flag ==1)
# then set the new value in current and execute change
cNode.getNode("visibility-m").setValue(vis);
#compat_layer.setVisibility(vis);
#print(vis);
print(vis);
compat_layer.setVisibilitySmoothly(vis);
# then count the number of active volumes on entry (we need that to determine
@ -4125,11 +4125,11 @@ debug.dump(geodinfo(lat, lon));
#var info = {};
#for (var i = 0; i< 100000; i=i+1)
# {
# info = geodinfo(lat, lon);
#var info = {};
#for (var i = 0; i< 100000; i=i+1)
# {
# info = geodinfo(lat, lon);
# }
@ -4488,6 +4488,10 @@ if (lowest_layer_turbulence < 0.0) {lowest_layer_turbulence = 0.0;}
var top_shade = 1.0;
# global cloud size scale;
var cloud_size_scale = 1.0;
# globals keeping track of the lifetime when building a Cumulus from individual cloudlets
var cloud_fractional_lifetime = 0.0;
@ -4582,7 +4586,7 @@ setprop(lw~"effect-volumes/number-active-sat",0);
# setprop(lw~"config/max-vis-range-m", 120000.0);
setprop(lw~"config/temperature-offset-degc", 0.0);
# setprop("/sim/rendering/eye-altitude-m", getprop("/position/altitude-ft") * ft_to_m);
setprop("/sim/rendering/eye-altitude-m", getprop("/position/altitude-ft") * ft_to_m);
# create properties for tile management

View file

@ -122,9 +122,11 @@ time_lw = time_lw + dt_lw;
#var terminator_offset = sun_angle / 0.017451 * 110000.0;# + 250000.0;
#setprop("/environment/terminator-relative-position-m",terminator_offset);
# var viewpos = geo.viewer_position();
var viewpos = geo.viewer_position();
# setprop("/environment/alt-in-haze-m", getprop("/environment/ground-haze-thickness-m")-viewpos.alt());
# setprop("/sim/rendering/eye-altitude-m", viewpos.alt());
#setprop("/sim/rendering/eye-altitude-m", viewpos.alt());

File diff suppressed because it is too large Load diff