From 7c87dff37b505092f575a68a5a24f9e540a1d8d2 Mon Sep 17 00:00:00 2001 From: Thorsten Renk Date: Fri, 1 Sep 2017 12:31:09 +0300 Subject: [PATCH] Add light and JBD controls and wave motion to USS Harry Truman --- Models/Geometry/Nimitz/truman.xml | 400 ++++++++++++++++++++++++++---- gui/dialogs/truman.xml | 72 +++++- 2 files changed, 419 insertions(+), 53 deletions(-) diff --git a/Models/Geometry/Nimitz/truman.xml b/Models/Geometry/Nimitz/truman.xml index 810a9c747..55f11a1a6 100755 --- a/Models/Geometry/Nimitz/truman.xml +++ b/Models/Geometry/Nimitz/truman.xml @@ -23,9 +23,13 @@ by Thorsten Renk 2017 var pathc = cmdarg().getPath(); var self = cmdarg(); + + # times for components to move to their position + var elevator_transit_time = 30.0; var door_transit_time = 60.0; var rail_transit_time = 4.0; + var jbd_transit_time = 5.0; # search for the next free slot in the AI menu and register the Truman control menu @@ -45,7 +49,19 @@ by Thorsten Renk 2017 setprop("/controls/truman/crew", 0); setprop("/controls/truman/deck-park",0); + setprop("/controls/truman/wave-motion",0); + setprop("/controls/truman/lights", 0); + setprop(pathc~"/wave-motion/pitch", 0.0); + setprop(pathc~"/wave-motion/roll", 0.0); + + + # init JBD + + setprop("/controls/truman/jbd[0]/state", 0); + setprop("/controls/truman/jbd[1]/state", 0); + setprop("/controls/truman/jbd[2]/state", 0); + setprop("/controls/truman/jbd[3]/state", 0); # init flight-operations flag (whip antenna animation) @@ -109,10 +125,10 @@ by Thorsten Renk 2017 ################ # elevator doors - var door1 = aircraft.door.new(pathc~"/surface-positions/elevator-door[0]", 60, 0); - var door2 = aircraft.door.new(pathc~"/surface-positions/elevator-door[1]", 60, 0); - var door3 = aircraft.door.new(pathc~"/surface-positions/elevator-door[2]", 60, 0); - var door4 = aircraft.door.new(pathc~"/surface-positions/elevator-door[3]", 60, 0); + var door1 = aircraft.door.new(pathc~"/surface-positions/elevator-door[0]", door_transit_time, 0); + var door2 = aircraft.door.new(pathc~"/surface-positions/elevator-door[1]", door_transit_time, 0); + var door3 = aircraft.door.new(pathc~"/surface-positions/elevator-door[2]", door_transit_time, 0); + var door4 = aircraft.door.new(pathc~"/surface-positions/elevator-door[3]", door_transit_time, 0); var door_array = [door1, door2, door3, door4]; @@ -122,6 +138,17 @@ by Thorsten Renk 2017 var whip_antennas = aircraft.door.new(pathc~"/surface-positions/whip-antennas", 6); + ################ + # jet blast deflectors + + var jbd1 = aircraft.door.new(pathc~"/surface-positions/jbd[0]", jbd_transit_time, 0); + var jbd2 = aircraft.door.new(pathc~"/surface-positions/jbd[1]", jbd_transit_time, 0); + var jbd3 = aircraft.door.new(pathc~"/surface-positions/jbd[2]", jbd_transit_time, 0); + var jbd4 = aircraft.door.new(pathc~"/surface-positions/jbd[3]", jbd_transit_time, 0); + + var jbd_array = [jbd1, jbd2, jbd3, jbd4]; + + print("LOAD ",carrier," prop-path: ", pathc); @@ -171,7 +198,118 @@ by Thorsten Renk 2017 an_spn_46_timer.restart(6); + var wave_manager = { + wave_loop_flag: 0, + amp_pitch: 0.2, + amp_roll: 0.7, + + pitch: 0.0, + roll: 0.0, + + ramp_factor: 0.0, + ramp_flag: 0, + + beam: 40.0, + length: 310.0, + + toggle: func { + var tgt = getprop("/controls/truman/wave-motion"); + + if (tgt == 1) + { + me.wave_loop_flag = 1; + print ("Wave motion on"); + me.wave_loop(); + me.ramp(1); + } + else + { + me.wave_loop_flag = 0; + me.ramp(0); + } + + }, + + + setup: func { + + var wind_angle = getprop("/environment/wind-from-heading-deg"); + #var wavelength = (2.0 * math.pi)/getprop("/environment/wave/freq"); + var freq = getprop("/environment/wave/freq"); + var course = getprop(pathc~"/controls/base-course-deg"); + var speed = getprop(pathc~"/controls/base-speed-kts") * 0.5144; + + + var encounter_angle_rad = (wind_angle - course) * math.pi/180.0; + + var encounter_freq = freq * (1.0 - freq * speed/9.81 * math.cos(encounter_angle_rad)); + + # the shader generates visible waves at x * freq spacing + var lambda = (2.0 * math.pi)/encounter_freq; + + + print ("Encounter angle: ", encounter_angle_rad * 180/math.pi); + print ("Encounter wavelength: ", lambda); + print ("Wavelength: ", (2.0 * math.pi)/freq); + + }, + + ramp: func (tgt) { + + if (math.abs(me.ramp_factor -tgt) < 0.01) + { + me.ramp_factor = tgt; + if (tgt == 0) + { + me.pitch = 0.0; + me.roll = 0.0; + setprop(pathc~"/wave-motion/pitch", 0.0); + setprop(pathc~"/wave-motion/roll", 0.0); + } + return; + } + else + { + if (tgt > me.ramp_factor) + { + me.ramp_factor = me.ramp_factor + 0.01; + } + else + { + me.ramp_factor = me.ramp_factor - 0.01; + } + } + if (tgt == 0) + { + setprop(pathc~"/wave-motion/pitch", me.pitch * me.ramp_factor); + setprop(pathc~"/wave-motion/roll", me.roll * me.ramp_factor); + } + + + settimer(func {me.ramp(tgt); }, 0.0); + }, + + wave_loop: func { + + if (me.wave_loop_flag ==0) {return;} + + var t = getprop("/sim/time/elapsed-sec"); + + me.pitch = me.ramp_factor * me.amp_pitch * math.sin(0.6 * t); + setprop(pathc~"/wave-motion/pitch", me.pitch); + + me.roll = me.ramp_factor * me.amp_roll * math.sin(0.8 * t); + setprop(pathc~"/wave-motion/roll", me.roll); + + settimer(func {me.wave_loop(); } , 0.0); + }, + + + }; + + + var check_rails = func (i) { @@ -255,6 +393,40 @@ by Thorsten Renk 2017 print ("Whip antennas deploy."); } + } + + var jbd_operate = func (i) { + + var tgt = getprop("/controls/truman/jbd["~i~"]/state"); + if (tgt == 1) + { + print ("JBD ", i+1, " up."); + jbd_array[i].open(); + } + else + { + print ("JBD ", i+1, " down."); + jbd_array[i].close(); + } + + + } + + var toggle_lights = func { + + var state = getprop(pathc~"/controls/lighting/deck-lights"); + + if (state == 0) + { + setprop(pathc~"/controls/lighting/deck-lights", 1); + setprop(pathc~"/controls/lighting/flood-lights-red-norm", 0.7); + } + else + { + setprop(pathc~"/controls/lighting/deck-lights", 0); + setprop(pathc~"/controls/lighting/flood-lights-red-norm", 0.0); + } + } @@ -270,7 +442,17 @@ by Thorsten Renk 2017 var l_door3 = setlistener("/controls/truman/door[2]/state", func {door_operate(2);},0,0); var l_door4 = setlistener("/controls/truman/door[3]/state", func {door_operate(3);},0,0); + var l_jbd1 = setlistener("/controls/truman/jbd[0]/state", func {jbd_operate(0);},0,0); + var l_jbd2 = setlistener("/controls/truman/jbd[1]/state", func {jbd_operate(1);},0,0); + var l_jbd3 = setlistener("/controls/truman/jbd[2]/state", func {jbd_operate(2);},0,0); + var l_jbd4 = setlistener("/controls/truman/jbd[3]/state", func {jbd_operate(3);},0,0); + + var l_wave = setlistener("/controls/truman/wave-motion", func {wave_manager.toggle();},0,0); + var l_lights = setlistener("/controls/truman/lights", func {toggle_lights();},0,0); + + #var l_wavetest = setlistener("/test/wave", func {wave_manager.setup();},0,0); + ]]> @@ -295,6 +491,38 @@ by Thorsten Renk 2017 --> + + rotate + wave-motion/pitch + 1 +
+ 40 + 0 + 0 +
+ + 0 + 1 + 0 + +
+ + + rotate + wave-motion/roll + 1 +
+ 40 + 0 + 0 +
+ + 1 + 0 + 0 + +
+ Models/Geometry/Nimitz/Models/flols.xml @@ -1061,8 +1289,8 @@ by Thorsten Renk 2017 rotate JBD-1 - surface-positions/jbd-pos-norm - + surface-positions/jbd[0]/position-norm + 0.00000 0.0833-12.2 @@ -1102,8 +1330,8 @@ by Thorsten Renk 2017 rotate JBD-1-strut-a JBD-1-strut-b - surface-positions/jbd-pos-norm - + surface-positions/jbd[0]/position-norm + 0.00000 0.08335 @@ -1142,8 +1370,8 @@ by Thorsten Renk 2017 rotate JBD-1-strut-b - surface-positions/jbd-pos-norm - + surface-positions/jbd[0]/position-norm + 0.00000 0.0833-23.4 @@ -1183,8 +1411,8 @@ by Thorsten Renk 2017 rotate JBD-2 - surface-positions/jbd-pos-norm - + surface-positions/jbd[1]/position-norm + 0.00000 0.0833-12.2 @@ -1224,8 +1452,8 @@ by Thorsten Renk 2017 rotate JBD-2-strut-a JBD-2-strut-b - surface-positions/jbd-pos-norm - + surface-positions/jbd[1]/position-norm + 0.00000 0.08335 @@ -1264,8 +1492,8 @@ by Thorsten Renk 2017 rotate JBD-2-strut-b - surface-positions/jbd-pos-norm - + surface-positions/jbd[1]/position-norm + 0.00000 0.0833-23.4 @@ -1305,8 +1533,8 @@ by Thorsten Renk 2017 rotate JBD-3 - surface-positions/jbd-pos-norm - + surface-positions/jbd[2]/position-norm + 0.00000 0.0833-12.2 @@ -1346,8 +1574,8 @@ by Thorsten Renk 2017 rotate JBD-3-strut-a JBD-3-strut-b - surface-positions/jbd-pos-norm - + surface-positions/jbd[2]/position-norm + 0.00000 0.08335 @@ -1386,8 +1614,8 @@ by Thorsten Renk 2017 rotate JBD-3-strut-b - surface-positions/jbd-pos-norm - + surface-positions/jbd[2]/position-norm + 0.00000 0.0833-23.4 @@ -1427,8 +1655,8 @@ by Thorsten Renk 2017 rotate JBD-4 - surface-positions/jbd-pos-norm - + surface-positions/jbd[3]/position-norm + 0.00000 0.0833-12.2 @@ -1468,8 +1696,8 @@ by Thorsten Renk 2017 rotate JBD-4-strut-a JBD-4-strut-b - surface-positions/jbd-pos-norm - + surface-positions/jbd[3]/position-norm + 0.00000 0.08335 @@ -1508,8 +1736,8 @@ by Thorsten Renk 2017 rotate JBD-4-strut-b - surface-positions/jbd-pos-norm - + surface-positions/jbd[3]/position-norm + 0.00000 0.0833-23.4 @@ -3234,6 +3462,14 @@ by Thorsten Renk 2017 Elevator-2-Deck Elevator-3-Deck Elevator-4-Deck + JBD1 + JBD2 + JBD3 + JBD4 + cat-deck-1 + cat-deck-2 + cat-deck-3 + cat-deck-4 /sim/time/sun-angle-rad @@ -3356,26 +3592,89 @@ by Thorsten Renk 2017 pick JBD1 - JBD2 - JBD3 - JBD4 + false - nasal - + property-toggle + /controls/truman/jbd[0]/state set-tooltip - cat-release - + jbd1 + + + pick + JBD2 + + + + false + + property-toggle + /controls/truman/jbd[1]/state + + + + + set-tooltip + jbd2 + + + + + + + pick + JBD3 + + + + false + + property-toggle + /controls/truman/jbd[2]/state + + + + + set-tooltip + jbd3 + + + + + + + pick + JBD4 + + + + false + + property-toggle + /controls/truman/jbd[3]/state + + + + + set-tooltip + jbd4 + + + + + + + pick Flightdeck @@ -3383,15 +3682,16 @@ by Thorsten Renk 2017 false - nasal - --> diff --git a/gui/dialogs/truman.xml b/gui/dialogs/truman.xml index 35e512ddf..107b47c16 100644 --- a/gui/dialogs/truman.xml +++ b/gui/dialogs/truman.xml @@ -122,7 +122,7 @@ table - + 0 0 @@ -215,6 +215,50 @@ + + left + 3 + 0 + + /controls/truman/jbd[0]/state + + dialog-apply + + + + + left + 3 + 1 + + /controls/truman/jbd[1]/state + + dialog-apply + + + + + left + 3 + 2 + + /controls/truman/jbd[2]/state + + dialog-apply + + + + + left + 3 + 3 + + /controls/truman/jbd[3]/state + + dialog-apply + + + @@ -242,8 +286,8 @@ left - 2 - 0 + 1 + 1 /controls/truman/crew @@ -251,6 +295,28 @@ + + left + 2 + 0 + + /controls/truman/lights + + dialog-apply + + + + + left + 2 + 1 + + /controls/truman/wave-motion + + dialog-apply + + +