From 5049ebd0bc24387c6939c2f03f324b83119e784f Mon Sep 17 00:00:00 2001 From: Erik Hofman Date: Tue, 11 Apr 2017 13:39:25 +0200 Subject: [PATCH] Prepare for windsock turbulence animation --- Nasal/windsock.nas | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Nasal/windsock.nas diff --git a/Nasal/windsock.nas b/Nasal/windsock.nas new file mode 100644 index 000000000..2f4448563 --- /dev/null +++ b/Nasal/windsock.nas @@ -0,0 +1,28 @@ +############################################################################### +## +## Windsock turbulence animation +## +############################################################################### + +var dt = 0.0; +var windsock = func { + var wind = getprop("/environment/wind-speed-kt") or 0; + var mag1 = getprop("/environment/turbulence/magnitude-norm") or 0; + var mag2 = getprop("/environment/turbulence/raw-magnitude-norm") or 0; + var sens = getprop("/environment/turbulence/sensitivity") or 0; + var rate = 3.1514*getprop("/environment/turbulence/rate-hz") or 0; + var tot1 = math.sin(dt*rate)*mag1*mag1; + var tot2 = math.sin(3.33*dt*rate/sens)*sens*mag2*mag2; + tot2 = mag2*tot2 + (1-mag2)*math.tan(dt/10)/5; + var total = wind + tot2 + tot1*tot2; + + interpolate("/environment/windsock/wind-speed-kt", total, 0.3); + + total += 5*mag2; + interpolate("/environment/windsock/wind-speed-12.5kt", total, 0.1); + + dt += 0.08 + 0.02*(math.sin(dt)+math.cos(dt/(mag2+0.01))*0.33); + settimer(windsock, 0.25); +} + +windsock();