diff --git a/Aircraft/c172p/Models/bumpspec-fuselage.eff b/Aircraft/c172p/Models/Effects/bumpspec-fuselage.eff similarity index 100% rename from Aircraft/c172p/Models/bumpspec-fuselage.eff rename to Aircraft/c172p/Models/Effects/bumpspec-fuselage.eff diff --git a/Aircraft/c172p/Models/bumpspec-tail.eff b/Aircraft/c172p/Models/Effects/bumpspec-tail.eff similarity index 100% rename from Aircraft/c172p/Models/bumpspec-tail.eff rename to Aircraft/c172p/Models/Effects/bumpspec-tail.eff diff --git a/Aircraft/c172p/Models/bumpspec-wing.eff b/Aircraft/c172p/Models/Effects/bumpspec-wing.eff similarity index 100% rename from Aircraft/c172p/Models/bumpspec-wing.eff rename to Aircraft/c172p/Models/Effects/bumpspec-wing.eff diff --git a/Aircraft/c172p/Models/Liveries/EI-MCF.xml b/Aircraft/c172p/Models/Liveries/EI-MCF.xml index 6e48e03a7..06b0f9eb6 100644 --- a/Aircraft/c172p/Models/Liveries/EI-MCF.xml +++ b/Aircraft/c172p/Models/Liveries/EI-MCF.xml @@ -3,33 +3,30 @@ - + + EI-MCF + 2 + Liveries/fuselage-eimcf.png + - - - EI-MCF - 2 - Liveries/fuselage.eimcf.png - - - - EI-MCF - 2 - Liveries/tail.png - + + EI-MCF + 2 + Liveries/tail.png + - EI-MCF - 2 - Liveries/wing.png - + EI-MCF + 2 + Liveries/wing.png + - - false + + false true false false - + diff --git a/Aircraft/c172p/Models/fuselage.eimcf.png b/Aircraft/c172p/Models/Liveries/fuselage-eimcf.png similarity index 100% rename from Aircraft/c172p/Models/fuselage.eimcf.png rename to Aircraft/c172p/Models/Liveries/fuselage-eimcf.png diff --git a/Aircraft/c172p/Models/Liveries/fuselage.n301dp.png b/Aircraft/c172p/Models/Liveries/fuselage-n301dp.png similarity index 100% rename from Aircraft/c172p/Models/Liveries/fuselage.n301dp.png rename to Aircraft/c172p/Models/Liveries/fuselage-n301dp.png diff --git a/Aircraft/c172p/Models/c172.14-fuselage.rgb b/Aircraft/c172p/Models/c172.14-fuselage.rgb deleted file mode 100644 index a8da40225..000000000 Binary files a/Aircraft/c172p/Models/c172.14-fuselage.rgb and /dev/null differ diff --git a/Aircraft/c172p/Models/c172.15-fuselage.rgb b/Aircraft/c172p/Models/c172.15-fuselage.rgb deleted file mode 100644 index 50a306a4d..000000000 Binary files a/Aircraft/c172p/Models/c172.15-fuselage.rgb and /dev/null differ diff --git a/Aircraft/c172p/Models/c172.16-fuselage.rgb b/Aircraft/c172p/Models/c172.16-fuselage.rgb deleted file mode 100644 index f63bc314b..000000000 Binary files a/Aircraft/c172p/Models/c172.16-fuselage.rgb and /dev/null differ diff --git a/Aircraft/c172p/Models/c172p-01.png b/Aircraft/c172p/Models/c172p-01.png new file mode 100644 index 000000000..a5dd6636b Binary files /dev/null and b/Aircraft/c172p/Models/c172p-01.png differ diff --git a/Aircraft/c172p/Models/c172p-01.rgb b/Aircraft/c172p/Models/c172p-01.rgb deleted file mode 100644 index b79aa20da..000000000 Binary files a/Aircraft/c172p/Models/c172p-01.rgb and /dev/null differ diff --git a/Aircraft/c172p/Models/c172p-02.png b/Aircraft/c172p/Models/c172p-02.png new file mode 100644 index 000000000..bce9c6303 Binary files /dev/null and b/Aircraft/c172p/Models/c172p-02.png differ diff --git a/Aircraft/c172p/Models/c172p-02.rgb b/Aircraft/c172p/Models/c172p-02.rgb deleted file mode 100644 index f4213b53f..000000000 Binary files a/Aircraft/c172p/Models/c172p-02.rgb and /dev/null differ diff --git a/Aircraft/c172p/Models/c172p-2d-panel.xml b/Aircraft/c172p/Models/c172p-2d-panel.xml index 161235788..4a2b3dcdf 100644 --- a/Aircraft/c172p/Models/c172p-2d-panel.xml +++ b/Aircraft/c172p/Models/c172p-2d-panel.xml @@ -17,7 +17,7 @@ Legacy 2D instruments and actions for the 3D C172P cockpit. - + labelbcn 495 -270 @@ -26,7 +26,7 @@ Legacy 2D instruments and actions for the 3D C172P cockpit. - + labelnav 458 -270 @@ -35,7 +35,7 @@ Legacy 2D instruments and actions for the 3D C172P cockpit. - + labelpto 422 -270 @@ -44,7 +44,7 @@ Legacy 2D instruments and actions for the 3D C172P cockpit. - + labelsto 525 -270 @@ -53,7 +53,7 @@ Legacy 2D instruments and actions for the 3D C172P cockpit. - + labeltax 493 -204 @@ -62,7 +62,7 @@ Legacy 2D instruments and actions for the 3D C172P cockpit. - + labellng 525 -204 diff --git a/Aircraft/c172p/Models/fuselage.n301dp.png b/Aircraft/c172p/Models/c172p-fuselage-skyhawk.png similarity index 100% rename from Aircraft/c172p/Models/fuselage.n301dp.png rename to Aircraft/c172p/Models/c172p-fuselage-skyhawk.png diff --git a/Aircraft/c172p/Models/c172p-int-01.png b/Aircraft/c172p/Models/c172p-int-01.png new file mode 100644 index 000000000..48a52a179 Binary files /dev/null and b/Aircraft/c172p/Models/c172p-int-01.png differ diff --git a/Aircraft/c172p/Models/c172p-int-01.rgb b/Aircraft/c172p/Models/c172p-int-01.rgb deleted file mode 100644 index 433d0eecc..000000000 Binary files a/Aircraft/c172p/Models/c172p-int-01.rgb and /dev/null differ diff --git a/Aircraft/c172p/Models/c172p-int-02.png b/Aircraft/c172p/Models/c172p-int-02.png new file mode 100644 index 000000000..8495d62e2 Binary files /dev/null and b/Aircraft/c172p/Models/c172p-int-02.png differ diff --git a/Aircraft/c172p/Models/c172p-int-02.rgb b/Aircraft/c172p/Models/c172p-int-02.rgb deleted file mode 100644 index e2e65a9d2..000000000 Binary files a/Aircraft/c172p/Models/c172p-int-02.rgb and /dev/null differ diff --git a/Aircraft/c172p/Models/c172p.ac b/Aircraft/c172p/Models/c172p.ac index eb59600a4..e2e65b2b7 100644 --- a/Aircraft/c172p/Models/c172p.ac +++ b/Aircraft/c172p/Models/c172p.ac @@ -44,7 +44,7 @@ name "BottomLink" loc 0.0176049 -0.0188099 0 data 8 Mesh.009 -texture "c172p-02.rgb" +texture "c172p-02.png" crease 30.000000 numvert 4 -1.048 -0.921304 0.020872 @@ -65,7 +65,7 @@ name "TopLink" loc 0.0274526 -0.0318764 0 data 8 Mesh.009 -texture "c172p-02.rgb" +texture "c172p-02.png" crease 30.000000 numvert 4 -0.881331 -0.859786 0.020872 @@ -6481,7 +6481,7 @@ OBJECT poly name "Panel_1" data 8 Mesh.026 -texture "c172p-int-02.rgb" +texture "c172p-int-02.png" crease 80.000000 numvert 27 -0.596017 0.059132 0.497091 @@ -21670,7 +21670,7 @@ OBJECT poly name "BackSeat" data 8 Mesh.099 -texture "c172p-int-01.rgb" +texture "c172p-int-01.png" crease 30.000000 numvert 28 1.0541 -0.62155 -0.460064 @@ -22051,7 +22051,7 @@ OBJECT poly name "BeaconSwitch" data 16 RockerSwitch.006 -texture "c172p-int-01.rgb" +texture "c172p-int-01.png" crease 30.000000 numvert 10 -0.355953 -0.258566 0.147111 @@ -25546,7 +25546,7 @@ OBJECT poly name "CopilotSeat" data 13 FrontSeat.002 -texture "c172p-int-01.rgb" +texture "c172p-int-01.png" crease 30.000000 numvert 24 0.324408 -0.59928 -0.432994 @@ -25811,7 +25811,7 @@ OBJECT poly name "Exhaust" data 8 Mesh.108 -texture "c172p-02.rgb" +texture "c172p-02.png" crease 30.000000 numvert 16 -1.29585 -0.770666 -0.290534 @@ -26519,7 +26519,7 @@ OBJECT poly name "LandingLightSwitch" data 16 RockerSwitch.007 -texture "c172p-int-01.rgb" +texture "c172p-int-01.png" crease 30.000000 numvert 10 -0.355953 -0.210915 0.122068 @@ -26847,7 +26847,7 @@ OBJECT poly name "LeftWheel" data 8 Mesh.013 -texture "c172p-02.rgb" +texture "c172p-02.png" crease 30.000000 numvert 64 0.660989 -1.02105 1.09349 @@ -27364,7 +27364,7 @@ OBJECT poly name "LeftWheelStrut" data 8 Mesh.014 -texture "fuselage.n301dp.png" +texture "c172p-fuselage-skyhawk.png" crease 30.000000 numvert 24 0.764081 -0.650906 0.414912 @@ -30339,7 +30339,7 @@ OBJECT poly name "NavLightSwitch" data 16 RockerSwitch.008 -texture "c172p-int-01.rgb" +texture "c172p-int-01.png" crease 30.000000 numvert 10 -0.355953 -0.258566 0.17285 @@ -30410,7 +30410,7 @@ OBJECT poly name "NoseWheel" data 8 Mesh.003 -texture "c172p-02.rgb" +texture "c172p-02.png" crease 30.000000 numvert 64 -1.0174 -1.06218 -0.04389 @@ -30927,7 +30927,7 @@ OBJECT poly name "NoseWheelStrut" data 8 Mesh.005 -texture "c172p-02.rgb" +texture "c172p-02.png" crease 30.000000 numvert 24 -0.951212 -0.69659 0.025989 @@ -33719,7 +33719,7 @@ OBJECT poly name "PilotSeat" data 13 FrontSeat.003 -texture "c172p-int-01.rgb" +texture "c172p-int-01.png" crease 30.000000 numvert 24 0.324408 -0.59928 0.05193 @@ -33926,7 +33926,7 @@ OBJECT poly name "PitotHeatSwitch" data 16 RockerSwitch.009 -texture "c172p-int-01.rgb" +texture "c172p-int-01.png" crease 30.000000 numvert 10 -0.355953 -0.258566 0.198937 @@ -33997,7 +33997,7 @@ OBJECT poly name "PitotTube" data 8 Mesh.111 -texture "c172p-02.rgb" +texture "c172p-02.png" crease 30.000000 numvert 9 -0.227717 0.464279 1.53536 @@ -35166,7 +35166,7 @@ OBJECT poly name "Propeller" data 8 Mesh.102 -texture "c172p-02.rgb" +texture "c172p-02.png" crease 30.000000 numvert 26 -1.80489 -0.18863 0.878791 @@ -35401,7 +35401,7 @@ OBJECT poly name "Propeller.Fast" data 8 Mesh.136 -texture "c172p-01.rgb" +texture "c172p-fuselage-skyhawk.png" crease 30.000000 numvert 32 -1.78664 0.657935 -0.710061 @@ -35622,7 +35622,7 @@ OBJECT poly name "Propeller.Slow" data 8 Mesh.137 -texture "c172p-01.rgb" +texture "c172p-fuselage-skyhawk.png" crease 30.000000 numvert 32 -1.78664 0.657935 -0.710061 @@ -36100,7 +36100,7 @@ OBJECT poly name "RightWheel" data 8 Mesh.070 -texture "c172p-02.rgb" +texture "c172p-02.png" crease 30.000000 numvert 64 0.66085 -1.02854 -1.22172 @@ -36617,7 +36617,7 @@ OBJECT poly name "RightWheelStrut" data 8 Mesh.004 -texture "fuselage.n301dp.png" +texture "c172p-fuselage-skyhawk.png" crease 30.000000 numvert 24 0.576418 -1.10992 -1.08343 @@ -36692,7 +36692,7 @@ OBJECT poly name "StrobeSwitch" data 16 RockerSwitch.010 -texture "c172p-int-02.rgb" +texture "c172p-int-02.png" crease 30.000000 numvert 10 -0.355953 -0.258566 0.122068 @@ -36763,7 +36763,7 @@ OBJECT poly name "TaxiLightSwitch" data 16 RockerSwitch.011 -texture "c172p-int-01.rgb" +texture "c172p-int-01.png" crease 30.000000 numvert 10 -0.355953 -0.211263 0.147111 @@ -42563,7 +42563,7 @@ OBJECT poly name "baggagedoor" data 8 Mesh.072 -texture "fuselage.n301dp.png" +texture "c172p-fuselage-skyhawk.png" crease 30.000000 numvert 44 1.45499 -0.166666 0.478551 @@ -44122,7 +44122,7 @@ OBJECT poly name "charniere3" data 8 Mesh.191 -texture "fuselage.n301dp.png" +texture "c172p-fuselage-skyhawk.png" crease 55.000000 numvert 28 -0.128478 -0.335913 0.535157 @@ -44317,7 +44317,7 @@ OBJECT poly name "charniere4" data 8 Mesh.141 -texture "fuselage.n301dp.png" +texture "c172p-fuselage-skyhawk.png" crease 55.000000 numvert 28 -0.128478 -0.335913 -0.535158 @@ -45270,7 +45270,7 @@ OBJECT poly name "fairing1" data 9 Plane.019 -texture "fuselage.n301dp.png" +texture "c172p-fuselage-skyhawk.png" crease 30.000000 numvert 324 -1.17802 -1.00328 0.034077 @@ -47857,7 +47857,7 @@ OBJECT poly name "fairing2" data 9 Plane.021 -texture "fuselage.n301dp.png" +texture "c172p-fuselage-skyhawk.png" crease 30.000000 numvert 324 0.444673 -0.918008 1.18589 @@ -50444,7 +50444,7 @@ OBJECT poly name "fairing3" data 9 Plane.020 -texture "fuselage.n301dp.png" +texture "c172p-fuselage-skyhawk.png" crease 30.000000 numvert 324 0.444673 -0.913253 -1.14083 @@ -53222,7 +53222,7 @@ OBJECT poly name "fuselage_1" data 8 Mesh.073 -texture "fuselage.n301dp.png" +texture "c172p-fuselage-skyhawk.png" crease 80.000000 numvert 1166 1.73839 0.167172 0 @@ -64254,7 +64254,7 @@ OBJECT poly name "leftdoor" data 8 Mesh.074 -texture "fuselage.n301dp.png" +texture "c172p-fuselage-skyhawk.png" crease 30.000000 numvert 125 -0.10498 -0.63518 0.50491 @@ -78790,7 +78790,7 @@ OBJECT poly name "rightdoor" data 8 Mesh.075 -texture "fuselage.n301dp.png" +texture "c172p-fuselage-skyhawk.png" crease 30.000000 numvert 125 -0.10498 -0.63518 -0.504908 diff --git a/Aircraft/c172p/Models/c172p.xml b/Aircraft/c172p/Models/c172p.xml index 6c5b0e21c..ddc67f296 100644 --- a/Aircraft/c172p/Models/c172p.xml +++ b/Aircraft/c172p/Models/c172p.xml @@ -2499,7 +2499,7 @@ LeftWheelStrut sim/model/livery/ texture - fuselage.n301dp.png + fuselage-n301dp.png @@ -2508,7 +2508,7 @@ fairing1 sim/model/livery/ texture - fuselage.n301dp.png + fuselage-n301dp.png @@ -2517,7 +2517,7 @@ fairing2 sim/model/livery/ texture - fuselage.n301dp.png + fuselage-n301dp.png @@ -2526,7 +2526,7 @@ fairing3 sim/model/livery/ texture - fuselage.n301dp.png + fuselage-n301dp.png @@ -2535,7 +2535,7 @@ fuselage sim/model/livery/ texture - fuselage.n301dp.png + fuselage-n301dp.png @@ -2547,7 +2547,7 @@ charniere4 sim/model/livery/ texture - fuselage.n301dp.png + fuselage-n301dp.png @@ -2556,7 +2556,7 @@ leftdoor sim/model/livery/ texture - fuselage.n301dp.png + fuselage-n301dp.png @@ -2565,7 +2565,7 @@ rightdoor sim/model/livery/ texture - fuselage.n301dp.png + fuselage-n301dp.png @@ -2574,7 +2574,7 @@ baggagedoor sim/model/livery/ texture - fuselage.n301dp.png + fuselage-n301dp.png diff --git a/Aircraft/c172p/Models/glass_shader.rgb b/Aircraft/c172p/Models/glass_shader.rgb deleted file mode 100644 index 2e89c032e..000000000 Binary files a/Aircraft/c172p/Models/glass_shader.rgb and /dev/null differ diff --git a/Effects/cloud.eff b/Effects/cloud.eff index c1f5c4183..bb6d3c31e 100644 --- a/Effects/cloud.eff +++ b/Effects/cloud.eff @@ -36,7 +36,7 @@ false - 9 + 10 DepthSortedBin diff --git a/Nasal/seaport.nas b/Nasal/seaport.nas new file mode 100644 index 000000000..5d9cb7fdb --- /dev/null +++ b/Nasal/seaport.nas @@ -0,0 +1,11 @@ +_setlistener("/sim/presets/latitude-deg", func { + print("*** NEW LOCATION ***"); + settimer(func { + var typ = getprop("/sim/type"); + var lat = getprop("/position/latitude-deg"); + var lon = getprop("/position/longitude-deg"); + var g = geodinfo(lat, lon); + if ((g != nil and g[1] != nil and g[1].solid) and (typ == "seaplane") ) + fgcommand("dialog-show", props.Node.new({ "dialog-name": "seaport" })); + }, 8); +}, 1); diff --git a/Nasal/wildfire.nas b/Nasal/wildfire.nas index 710cc103a..0e1188d26 100644 --- a/Nasal/wildfire.nas +++ b/Nasal/wildfire.nas @@ -8,7 +8,7 @@ ## ############################################################################### -# The cellular automata model used here is based on +# The cellular automata model used here is loosely based on # A. Hernandez Encinas, L. Hernandez Encinas, S. Hoya White, # A. Martin del Rey, G. Rodriguez Sanchez, # "Simulation of forest fire fronts using cellular automata", @@ -127,13 +127,14 @@ var MP_share_pp = "environment/wildfire/share-events"; var save_on_exit_pp = "environment/wildfire/save-on-exit"; var restore_on_startup_pp = "environment/wildfire/restore-on-startup"; var crash_fire_pp = "environment/wildfire/fire-on-crash"; +var impact_fire_pp = "environment/wildfire/fire-on-impact"; var report_score_pp = "environment/wildfire/report-score"; # Internal properties to control the models var models_enabled_pp = "environment/wildfire/models/enabled"; var fire_LOD_pp = "environment/wildfire/models/fire-lod"; var smoke_LOD_pp = "environment/wildfire/models/smoke-lod"; var LOD_High = 20; -var LOD_Low = 80; +var LOD_Low = 50; var mp_last_limited_event = {}; # source : time var score = { extinguished : 0, protected : 0, waste : 0 }; @@ -201,7 +202,7 @@ var parse_msg = func (source, msg) { var pos = Binary.decodeCoord(substr(msg, 6)); ignite(pos, 0); } else { - printlog("warn", "wildfire.nas: Ignored ignite event from " ~ + printlog("alert", "wildfire.nas: Ignored ignite event flood from " ~ source.getNode("callsign").getValue()); } mp_last_limited_event[i] = cur_time; @@ -239,13 +240,13 @@ var SimTime = { } }; -############################################################################### -# Class that maintains one fire cell. +############################################################################### +# Class that maintains the state of one fire cell. var FireCell = { ############################################################ new : func (x, y) { -# print("Creating FireCell[" ~ x ~ "," ~ y ~ "]"); + trace("Creating FireCell[" ~ x ~ "," ~ y ~ "]"); var m = { parents: [FireCell] }; m.lat = y * CAFire.CELL_SIZE/60.0 + 0.5 * CAFire.CELL_SIZE / 60.0; m.lon = x * CAFire.CELL_SIZE/60.0 + 0.5 * CAFire.CELL_SIZE / 60.0; @@ -268,7 +269,7 @@ var FireCell = { m.burn_rate = CAFire.BURN_RATE[mat]; } } - m.model = CellModel.new(x, y, m.alt); + CAFireModels.add(x, y, m.alt); append(CAFire.active, m); CAFire.cells_created += 1; return m; @@ -279,7 +280,7 @@ var FireCell = { trace("FireCell[" ~ me.x ~ "," ~me.y ~ "] Ignited!"); me.burning[CAFire.next] = 1; me.burning[CAFire.old] = 1; - me.model.set_type("fire"); + CAFireModels.set_type(me.x, me.y, "fire"); # Prevent update() on this cell in this generation. me.last = CAFire.generation; } else { @@ -299,16 +300,16 @@ var FireCell = { # Prevent update() on this cell in this generation. me.last = CAFire.generation; if ((me.state[CAFire.old] > 0.0) and (me.burning[CAFire.old] > 0)) { - me.model.set_type("soot"); + CAFireModels.set_type(me.x, me.y, "soot"); } else { # Use a model representing contamination here. - me.model.set_type(type); + CAFireModels.set_type(me.x, me.y, type); } return result; }, ############################################################ update : func () { -# print("FireCell[" ~ me.x ~ "," ~me.y ~ "] " ~ me.state[CAFire.old]); + trace("FireCell[" ~ me.x ~ "," ~me.y ~ "] " ~ me.state[CAFire.old]); if ((me.state[CAFire.old] == 1) and (me.burning[CAFire.old] == 0)) return 0; if ((me.burn_rate == 0) and (me.burning[CAFire.old] == 0)) @@ -336,7 +337,7 @@ var FireCell = { return 0; } me.burning[CAFire.next] = me.burning[CAFire.old]; - me.model.set_type(me.burning[CAFire.old] ? "fire" : "soot"); + CAFireModels.set_type(me.x, me.y, me.burning[CAFire.old] ? "fire" : "soot"); return 1; }, ############################################################ @@ -401,13 +402,13 @@ var CellModel = { me.model = nil; } me.type = type; - if (CAFire.MODEL[type] == "") return; + if (CAFireModels.MODEL[type] == "") return; # Always put "cheap" models for now. - if (CAFire.models_enabled or (type != "fire")) { + if (CAFireModels.models_enabled or (type != "fire")) { me.model = - geo.put_model(CAFire.MODEL[type], me.lat, me.lon, me.alt); -# print("Created 3d model " ~ type ~ " " ~ CAFire.MODEL[type]); + geo.put_model(CAFireModels.MODEL[type], me.lat, me.lon, me.alt); + trace("Created 3d model " ~ type ~ " " ~ CAFireModels.MODEL[type]); } }, ############################################################ @@ -419,7 +420,95 @@ var CellModel = { }; ############################################################################### -# Singleton that maintains the fire CA grid. +# Singleton that maintains the CA models. +var CAFireModels = {}; +# Constants +CAFireModels.MODEL = { # Model paths + "fire" : "Models/Effects/Wildfire/wildfire.xml", + "soot" : "Models/Effects/Wildfire/soot.xml", + "foam" : "Models/Effects/Wildfire/foam.xml", + "water" : "", + "protected" : "", + "none" : "", +}; +# State +CAFireModels.grid = {}; # Sparse cell model grid storage. +CAFireModels.pending = []; # List of pending model changes. +CAFireModels.models_enabled = 1; +CAFireModels.loopid = 0; +###################################################################### +# Public operations +############################################################ +CAFireModels.init = func { + # Initialization. + setlistener(models_enabled_pp, func (n) { + me.set_models_enabled(n.getValue()); + }, 1); + me.reset(1); +} +############################################################ +# Reset the model grid to the empty state. +CAFireModels.reset = func (enabled) { + # Clear the model grid. + foreach (var x; keys(me.grid)) { + foreach (var y; keys(me.grid[x])) { + if (me.grid[x][y] != nil) me.grid[x][y].remove(); + } + } + # Reset state. + me.grid = {}; + me.pending = []; + + me.loopid += 1; + me._loop_(me.loopid); +} +############################################################ +# Add a new cell model. +CAFireModels.add = func(x, y, alt) { + append(me.pending, { x: x, y: y, alt: alt }); +} +############################################################ +# Update a cell model. +CAFireModels.set_type = func(x, y, type) { + append(me.pending, { x: x, y: y, type: type }); +} +############################################################ +CAFireModels.set_models_enabled = func(on=1) { + me.models_enabled = on; + # We should do a pass over all cells here to add/remove models. + # For now I don't so only active cells will actually remove the + # models. All models will be hidden by their select animations, though. +} +###################################################################### +# Private operations +############################################################ +CAFireModels.update = func { + var work = size(me.pending)/10; + while (size(me.pending) > 0 and work > 0) { + var c = me.pending[0]; + me.pending = subvec(me.pending, 1); + work -= 1; + if (contains(c, "alt")) { + if (me.grid[c.x] == nil) { + me.grid[c.x] = {}; + } + me.grid[c.x][c.y] = CellModel.new(c.x, c.y, c.alt); + } + if (contains(c, "type")) { + me.grid[c.x][c.y].set_type(c.type); + } + } +} +############################################################ +CAFireModels._loop_ = func(id) { + id == me.loopid or return; + me.update(); + settimer(func { me._loop_(id); }, 0); +} +############################################################################### + +############################################################################### +# Singleton that maintains the fire cell CA grid. var CAFire = {}; # State CAFire.CELL_SIZE = 0.03; # "nm" (or rather minutes) @@ -465,14 +554,6 @@ CAFire.BURN_RATE = { # Burn rate DB. grid widths per second # ? "Landmass" : 0.0005 }; -CAFire.MODEL = { # Model paths - "fire" : "Models/Effects/Wildfire/wildfire.xml", - "soot" : "Models/Effects/Wildfire/soot.xml", - "foam" : "Models/Effects/Wildfire/foam.xml", - "water" : "", - "protected" : "", - "none" : "", -}; CAFire.NEIGHBOURS = # Neighbour index offsets. First row and column # and then diagonal. [[[-1, 0], [0, 1], [1, 0], [0, -1]], @@ -482,21 +563,13 @@ CAFire.NEIGHBOURS = # Neighbour index offsets. First row and column ############################################################ CAFire.init = func { # Initialization. - setlistener(models_enabled_pp, func (n) { - me.set_models_enabled(n.getValue()); - }, 1); me.reset(1, SimTime.current_time()); } ############################################################ # Reset the CA to the empty state and set its current time to sim_time. CAFire.reset = func (enabled, sim_time) { - # Clear the grid. - foreach (var x; keys(me.grid)) { - foreach (var y; keys(me.grid[x])) { - if (me.grid[x][y].model != nil) me.grid[x][y].model.remove(); - me.grid[x][y] = nil; - } - } + # Clear the model grid. + CAFireModels.reset(enabled); # Reset state. me.grid = {}; me.generation = int(sim_time/CAFire.GENERATION_DURATION); @@ -517,7 +590,7 @@ CAFire.reset = func (enabled, sim_time) { ############################################################ # Start a fire in the cell at pos. CAFire.ignite = func (lat, lon) { -# print("Fire at " ~ lat ~", " ~ lon ~ "."); + trace("CAFire.ignite: Fire at " ~ lat ~", " ~ lon ~ "."); var x = int(lon*60/me.CELL_SIZE); var y = int(lat*60/me.CELL_SIZE); var cell = me.get_cell(x, y); @@ -536,17 +609,16 @@ CAFire.ignite = func (lat, lon) { # radius - meter : double # Note: volume is unused ATM. CAFire.resolve_water_drop = func (lat, lon, radius, volume=0) { + trace("CAFire.resolve_water_drop: Dumping water at " ~ lat ~", " ~ lon ~ + " radius " ~ radius ~"."); var x = int(lon*60/me.CELL_SIZE); var y = int(lat*60/me.CELL_SIZE); var r = int(2*radius/(me.CELL_SIZE*1852.0)); -# print("Dumping water at " ~ lat ~", " ~ lon ~ -# ". Center (" ~ x ~ "," ~ y ~ ") radius " ~ r ~"."); var result = { extinguished : 0, protected : 0, waste : 0 }; for (var dx = -r; dx <= r; dx += 1) { for (var dy = -r; dy <= r; dy += 1) { var cell = me.get_cell(x + dx, y + dy); if (cell == nil) { -# print(" (" ~ (x + dx) ~ ", " ~ (y + dy) ~ ")"); cell = FireCell.new(x + dx, y + dy); me.set_cell(x + dx, y + dy, cell); @@ -583,17 +655,16 @@ CAFire.resolve_retardant_drop = func (lat, lon, radius, volume=0) { # radius - meter : double # Note: volume is unused ATM. CAFire.resolve_foam_drop = func (lat, lon, radius, volume=0) { + trace("CAFire.resolve_foam_drop: Dumping foam at " ~ lat ~", " ~ lon ~ + " radius " ~ radius ~"."); var x = int(lon*60/me.CELL_SIZE); var y = int(lat*60/me.CELL_SIZE); var r = int(2*radius/(me.CELL_SIZE*1852.0)); -# print("Dumping foam at " ~ lat ~", " ~ lon ~ -# ". Center (" ~ x ~ "," ~ y ~ ") radius " ~ r ~"."); var result = { extinguished : 0, protected : 0, waste : 0 }; for (var dx = -r; dx <= r; dx += 1) { for (var dy = -r; dy <= r; dy += 1) { var cell = me.get_cell(x + dx, y + dy); if (cell == nil) { -# print(" (" ~ (x + dx) ~ ", " ~ (y + dy) ~ ")"); cell = FireCell.new(x + dx, y + dy); me.set_cell(x + dx, y + dy, cell); @@ -660,12 +731,12 @@ CAFire.load_event_log = func (filename, skip_ahead_until=-1) { if (!fgcommand("loadxml", props.Node.new({ filename : filename, targetnode : logbase }))) { - printlog("warn", "Wildfire ... failed loading '" ~ filename ~ "'"); + printlog("alert", "Wildfire ... failed loading '" ~ filename ~ "'"); return; } # Fast forward the automaton from the first logged event to the current time. - me.set_models_enabled(0); + CAFireModels.set_models_enabled(0); var first = 1; var events = props.globals.getNode(logbase).getChildren("event"); foreach (var event; events) { @@ -719,14 +790,7 @@ CAFire.load_event_log = func (filename, skip_ahead_until=-1) { while (me.generation * me.GENERATION_DURATION < now) me.update(); } - me.set_models_enabled(getprop(models_enabled_pp)); -} -############################################################ -CAFire.set_models_enabled = func(on=1) { - me.models_enabled = on; - # We should do a pass over all cells here to add/remove models. - # For now I don't so only active cells will actually remove the - # models. All models will be hidden by there select animations, though. + CAFireModels.set_models_enabled(getprop(models_enabled_pp)); } ###################################################################### # Internal operations @@ -820,6 +884,7 @@ _setlistener("/sim/signals/nasal-dir-initialized", func { }); props.globals.initNode(MP_share_pp, 1, "BOOL"); props.globals.initNode(crash_fire_pp, 1, "BOOL"); + props.globals.initNode(impact_fire_pp, 1, "BOOL"); props.globals.initNode(save_on_exit_pp, 0, "BOOL"); props.globals.initNode(restore_on_startup_pp, 0, "BOOL"); props.globals.initNode(models_enabled_pp, 1, "BOOL"); @@ -855,6 +920,22 @@ _setlistener("/sim/signals/nasal-dir-initialized", func { wildfire.ignite(geo.aircraft_position()); }); +# Detect impact + var impact_node = props.globals.getNode("sim/ai/aircraft/impact/bomb", 1); + setlistener("sim/ai/aircraft/impact/bomb", func(n) { + + if (getprop(impact_fire_pp) and n.getBoolValue()){ + var node = props.globals.getNode(n.getValue(), 1); + var impactpos = geo.Coord.new(); + impactpos.set_latlon( + node.getNode("impact/latitude-deg").getValue(), + node.getNode("impact/longitude-deg").getValue() + ); + wildfire.ignite(impactpos); + } + + }); + printlog("info", "Wildfire ... initialized."); }); ############################################################################### @@ -917,6 +998,7 @@ var dialog = { ["Share over MP", MP_share_pp], ["Show 3d models", models_enabled_pp], ["Crash starts fire", crash_fire_pp], + ["Impact starts fire", impact_fire_pp], ["Report score", report_score_pp], ["Save on exit", save_on_exit_pp]]) { var w = content.addChild("checkbox"); diff --git a/Shaders/crop.frag b/Shaders/crop.frag index 555e673a2..c3534bc41 100644 --- a/Shaders/crop.frag +++ b/Shaders/crop.frag @@ -9,6 +9,8 @@ uniform sampler3D NoiseTex; uniform sampler2D SampleTex; uniform sampler1D ColorsTex; +varying vec4 constantColor; + uniform float snowlevel; // From /sim/rendering/snow-level-m const float scale = 1.0; @@ -57,7 +59,7 @@ void main (void) c1 = mix(c1, clamp(n+nvL[2]*4.1+vec4(0.1, 0.1, nvL[2]*2.2, 1.0), 0.7, 1.0), smoothstep(snowlevel+300.0, snowlevel+360.0, (rawpos.z)+nvL[1]*3000.0)); vec3 diffuse = gl_Color.rgb * max(0.0, dot(VNormal, gl_LightSource[0].position.xyz)); - vec4 ambient_light = gl_LightSource[0].diffuse * vec4(diffuse, 1.0); + vec4 ambient_light = constantColor + gl_LightSource[0].diffuse * vec4(diffuse, 1.0); c1 *= ambient_light; vec4 finalColor = c1; diff --git a/Shaders/crop.vert b/Shaders/crop.vert index b5c7314a5..9e70bfa6d 100644 --- a/Shaders/crop.vert +++ b/Shaders/crop.vert @@ -4,6 +4,7 @@ varying vec4 rawpos; varying vec4 ecPosition; varying vec3 VNormal; varying vec3 Normal; +varying vec4 constantColor; void main(void) { @@ -14,6 +15,10 @@ void main(void) VNormal = normalize(gl_NormalMatrix * gl_Normal); Normal = normalize(gl_Normal); - gl_FrontColor = gl_Color; + gl_FrontColor = gl_Color; + + constantColor = gl_FrontMaterial.emission + + gl_Color * (gl_LightModel.ambient + gl_LightSource[0].ambient); + gl_Position = ftransform(); } \ No newline at end of file diff --git a/gui/dialogs/seaport.xml b/gui/dialogs/seaport.xml new file mode 100644 index 000000000..08fab29ef --- /dev/null +++ b/gui/dialogs/seaport.xml @@ -0,0 +1,123 @@ + + + + seaport + vbox + + + + + var label = cmdarg().getNode("text/label"); + var apt = airportinfo("seaport"); + var rwys = apt.runways; + var lat = apt.lat; + var lon = apt.lon; + + label.setValue(" The nearest seaport is \"" ~ apt.name ~ "\" (" ~ apt.id ~ ") "); + + var goto_seaport = func { + var rwyid = keys(rwys)[0]; + var rwy = rwys[rwyid]; + print("SP: going to seaport ", apt.id, "/", rwyid, " (\"", apt.name, "\")"); + setprop("/sim/presets/airport-id", apt.id); + teleport(rwy.lat, rwy.lon); + settimer(verify, 4); + } + + var verify = func { + var p = geo.aircraft_position(); + if (on_water(p.lat(), p.lon())) { + print("SP: seaport center is on water"); + return; + } + + foreach (var r; keys(rwys)) { + print("SP: trying runway ", r); + var lat = rwys[r].lat; + var lon = rwys[r].lon; + if (on_water(lat, lon)) { + setprop("/sim/presets/runway", r); + setprop("/sim/presets/heading-deg", rwys[r].heading); + print("SP: runway ", r, " is on water"); + return teleport(lat, lon); + } + } + + print("SP: trying circle"); + for (var dist = 500; dist <= 1500; dist += 500) { + print("SP:\tat distance ", dist, " m"); + + for (var course = 0; course < 360; course += 60) { + print("SP:\t\tat course ", course, " degree"); + + p.set_latlon(apt.lat, apt.lon); + p.apply_course_distance(course, dist); + if (on_water(p.lat(), p.lon())) { + print("SP: found water"); + setprop("/sim/presets/heading-deg", course); + return teleport(p.lat(), p.lon()); + } + } + } + + print("SP: no water found"); + } + + var teleport = func(lat, lon) { + setprop("/sim/presets/latitude-deg", lat); + setprop("/sim/presets/longitude-deg", lon); + fgcommand("presets-commit"); + } + + var on_water = func(lat, lon) { + var g = geodinfo(lat, lon); + return g != nil and g[1] != nil and !g[1].solid; + } + + + + + hbox + 1 + + + + + + 1 + + + + + + + + + + hbox + + + + + diff --git a/preferences.xml b/preferences.xml index 8cd338604..0c4debbd9 100644 --- a/preferences.xml +++ b/preferences.xml @@ -597,7 +597,9 @@ Started September 2000 by David Megginson, david@megginson.com true true + false + false 1.0