Custom blackout system: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
m (Added a word)
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This is instruction on how to include a more realistic custom mandatory blackout/redout system based of a description of how that worked in a 1979 Langley F-16 simulator. The system is time based, so the longer time you spend at a high G the darker the screen gets. We have long used this system in Operation Red Flag virtual airforce, but its time to share it.
This is instruction on how to include a more realistic custom mandatory blackout/redout system based of a description of how that worked in a 1979 Langley F-16 simulator. The system is time based, so the longer time you spend at a high G the darker the screen gets.


Per default to clear the darkness you must get below 5G for blackout and above -1.5G for redout. It also features G priming, so that if you for example pull some high Gs for a while and then go negative the redout will take longer to come into effect, and vice versa, as the blood flows to or from the pilots brain.
Per default to clear the darkness you must get below 5G for blackout and above -2G for redout. It also features G priming, so that if you for example pull some high Gs for a while and then go negative the redout will take longer to come into effect, and vice versa, as the blood flows to or from the pilots brain.
 
A variant of this system will be included in FG 2017.1.1, so if that is detected this Nasal system will not run.


==Install in an aircraft==
==Install in an aircraft==
Line 14: Line 16:
## Author: Nikolai V. Chr.                                                      ##
## Author: Nikolai V. Chr.                                                      ##
##                                                                              ##
##                                                                              ##
## Version 1.0            License: GPL 2.0                                      ##
## Version 1.05            License: GPL 2.0                                      ##
##                                                                              ##
##                                                                              ##
###################################################################################
###################################################################################
Line 22: Line 24:


var invert = func (acc) {
var invert = func (acc) {
var g_inv = -1 * (acc - 5);
var g_inv = -1 * (acc - 2);
return g_inv;
return g_inv;
}
}
Line 43: Line 45:
var blackout_onset      =    5;
var blackout_onset      =    5;
var blackout_fast      =    9;
var blackout_fast      =    9;
var redout_onset        = -1.5;
var redout_onset        = -2.0;
var redout_fast        =  -4;
var redout_fast        =  -4;


Line 79: Line 81:
if (fdm == "jsb") {
if (fdm == "jsb") {
# JSBSim
# JSBSim
g = getprop("fdm/jsbsim/accelerations/Nz");
g = -getprop("accelerations/pilot/z-accel-fps_sec")/32.174;
} else {
} else {
# Yasim
# Yasim
Line 156: Line 158:
     setprop("/sim/rendering/redout/alpha", sum);
     setprop("/sim/rendering/redout/alpha", sum);
     }
     }
    settimer(blackout_loop, 0);
}
}


Line 164: Line 164:
fdm = getprop("/sim/flight-model");
fdm = getprop("/sim/flight-model");


blackout_loop();
if (getprop("sim/rendering/redout/internal/log/g-force") == nil) {
var timer = maketimer(0, func blackout_loop() );
timer.start();
}
}
}


Line 173: Line 176:
removelistener(blackout_init_listener);
removelistener(blackout_init_listener);
}, 0, 0);
}, 0, 0);
var test = func (blackout_onset, blackout_fast, blackout_onset_time, blackout_fast_time) {
var blackout_onset_log = math.log10(blackout_onset);
var blackout_fast_log = math.log10(blackout_fast);
var g = 5;
print();
while(g <= 20) {
var g_log = g <= 1?0:math.log10(g);
var curr_time = math.log10(blackout_onset_time) + ((g_log - blackout_onset_log) / (blackout_fast_log - blackout_onset_log)) * (math.log10(blackout_fast_time) - math.log10(blackout_onset_time));
curr_time = math.pow(10, curr_time);
curr_time = clamp(curr_time, 0, 1000);
printf("%0.1f, %0.2f", g, curr_time);
g += .5;
}
print();
}
</syntaxhighlight>
</syntaxhighlight>


Line 213: Line 192:
== Adjusting the numbers ==
== Adjusting the numbers ==


The default numbers are for G-suits anno 1979. We have done alot of research into this and for more modern fighters 1995+ I recommend some more like this:
The default numbers are for G-suits anno 1979. We have done a lot of research into this and for more modern fighters 1995+ you could set it to something like this:


<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
var blackout_onset      =    5;
var blackout_onset      =    5;
var blackout_fast      =    8;
var blackout_fast      =    8;
var redout_onset        = -1.5;
var redout_onset        =   -2;
var redout_fast        =  -4;
var redout_fast        =  -4;


Line 232: Line 211:
[[F-16|General Dynamics YF-16]]
[[F-16|General Dynamics YF-16]]


[[Mirage 2000-5]]
== Related content ==
=== Wiki articles ===
* [[Howto:Add blackout and redout settings]]
 
=== Forum topics ===
* [https://forum.flightgear.org/viewtopic.php?f=4&t=30985 More realistic Blackout/Redout] – Development topic
 
== External links ==
* {{cite web
| url            = http://www.dtic.mil/dtic/tr/fulltext/u2/a109127.pdf
| title          = AFHRL-TP-80-41 - Study and Design of High G Augmentation Devices for Flight Simulators
| author          = Kron, Gerald J.; Cardullo, Frank M.; Young, Laurence R.
| date            = December 1981
| publisher      = US Air Force Human Resources Laboratory
| format          = pdf
}}


[[Category:Aircraft enhancement]]
[[Category:Aircraft enhancement]]
[[Category:Nasal howto]]

Latest revision as of 19:23, 15 January 2017

This is instruction on how to include a more realistic custom mandatory blackout/redout system based of a description of how that worked in a 1979 Langley F-16 simulator. The system is time based, so the longer time you spend at a high G the darker the screen gets.

Per default to clear the darkness you must get below 5G for blackout and above -2G for redout. It also features G priming, so that if you for example pull some high Gs for a while and then go negative the redout will take longer to come into effect, and vice versa, as the blood flows to or from the pilots brain.

A variant of this system will be included in FG 2017.1.1, so if that is detected this Nasal system will not run.

Install in an aircraft

Copy this code into your aircraft's Nasal folder as blackout.nas file:

###################################################################################
##                                                                               ##
## Improved redout/blackout system for Flightgear                                ##
##                                                                               ##
## Author: Nikolai V. Chr.                                                       ##
##                                                                               ##
## Version 1.05            License: GPL 2.0                                      ##
##                                                                               ##
###################################################################################


var clamp = func(v, min, max) { v < min ? min : v > max ? max : v }

var invert = func (acc) {
	var g_inv = -1 * (acc - 2);
	return g_inv;
}


#
# Customize the values according to the quality of the G-suit the pilot is wearing. The times are in seconds.
#
# According to NASA (1979), this should be the blackout values for F-16:
#
# blackout_onset      =   5;
# blackout_fast       =   9;
# blackout_onset_time = 300;
# blackout_fast_time  =  10;
#
# That means at 9G it will take 10 seconds to blackout completely.
# At 5G it will take 300 seconds.
#

var blackout_onset      =    5;
var blackout_fast       =    9;
var redout_onset        = -2.0;
var redout_fast         =   -4;

var blackout_onset_time =  300;
var blackout_fast_time  =   10;
var redout_onset_time   =   45;
var redout_fast_time    =  7.5;

var fast_time_recover   =    7;
var slow_time_recover   =   15;






## Do not modify anything below this line ##

var fdm = "jsb";
var g1_log = math.log10(1);
var blackout_onset_log = math.log10(blackout_onset);
var blackout_fast_log = math.log10(blackout_fast);
var redout_onset_log = math.log10(invert(redout_onset));
var redout_fast_log = math.log10(invert(redout_fast));

var blackout = 0;
var redout   = 0;



var blackout_loop = func {
	setprop("/sim/rendering/redout/enabled", 0);# disable the Fg default redout/blackout system.
	var dt = getprop("sim/time/delta-sec");
	var g = 0;
	if (fdm == "jsb") {
		# JSBSim
		g = -getprop("accelerations/pilot/z-accel-fps_sec")/32.174;
	} else {
		# Yasim
		g = getprop("/accelerations/pilot-g[0]");
	}
	if (g == nil) {
		g = 1;
	}

	var g_log = g <= 1?0:math.log10(g);
	if (g < blackout_onset) {
		# reduce blackout

		var curr_time = fast_time_recover + ((g_log - g1_log) / (blackout_onset_log - g1_log)) * (slow_time_recover - fast_time_recover);

		curr_time = clamp(curr_time, 0, 1000);

		blackout -= (1/curr_time)*dt;

		blackout = clamp(blackout, 0, 1);

	} elsif (g >= blackout_onset) {
		# increase blackout

		var curr_time = math.log10(blackout_onset_time) + ((g_log - blackout_onset_log) / (blackout_fast_log - blackout_onset_log)) * (math.log10(blackout_fast_time) - math.log10(blackout_onset_time));

		curr_time = math.pow(10, curr_time);

		curr_time = clamp(curr_time, 0, 1000);

		blackout += (1/curr_time)*dt;

		blackout = clamp(blackout, 0, 1);

	}

	var g_inv = invert (g);
	var g_inv_log = g_inv <= 1?0:math.log10(g_inv);
	if (g > redout_onset) {
		# reduce redout

		var curr_time = fast_time_recover + ((g_inv_log - g1_log) / (redout_onset_log - g1_log)) * (slow_time_recover - fast_time_recover);

		curr_time = clamp(curr_time, 0, 1000);

		redout -= (1/curr_time)*dt;

		redout = clamp(redout, 0, 1);

	} elsif (g <= redout_onset) {
		# increase redout

		var curr_time = math.log10(redout_onset_time) + ((g_inv_log - redout_onset_log) / (redout_fast_log - redout_onset_log)) * (math.log10(redout_fast_time) - math.log10(redout_onset_time));

		curr_time = math.pow(10, curr_time);

		curr_time = clamp(curr_time, 0, 1000);

		redout += (1/curr_time)*dt;

		redout = clamp(redout, 0, 1);

	}

	var sum = blackout - redout;

	if (getprop("/sim/current-view/internal") == 0) {
		# not inside aircraft
		setprop("/sim/rendering/redout/red", 0);
    	setprop("/sim/rendering/redout/alpha", 0);
	} elsif (sum < 0) {
		setprop("/sim/rendering/redout/red", 1);
    	setprop("/sim/rendering/redout/alpha", -1 * sum);
    } else {
    	setprop("/sim/rendering/redout/red", 0);
    	setprop("/sim/rendering/redout/alpha", sum);
    }
}


var blackout_init = func {
	fdm = getprop("/sim/flight-model");

	if (getprop("sim/rendering/redout/internal/log/g-force") == nil) {
		var timer = maketimer(0, func blackout_loop() );
		timer.start();
	}
}



var blackout_init_listener = setlistener("sim/signals/fdm-initialized", func {
	blackout_init();
	removelistener(blackout_init_listener);
}, 0, 0);


Then in your aircraft-set.xml file under nasal tags add

<crash>
  <file>Aircraft/[aircraft name here]/Nasal/blackout.nas</file>
</crash>

And that is it. It will work even since blackout/redout is disabled in the flightsim cockpit dialog. If you enable blackout/redout in the dialog, it will revert back to being unselected, the reason is to disable the default blackout system.

Adjusting the numbers

The default numbers are for G-suits anno 1979. We have done a lot of research into this and for more modern fighters 1995+ you could set it to something like this:

var blackout_onset      =    5;
var blackout_fast       =    8;
var redout_onset        =   -2;
var redout_fast         =   -4;

var blackout_onset_time =  300;
var blackout_fast_time  =   30;
var redout_onset_time   =   45;
var redout_fast_time    =  7.5;

Aircraft that use this system

Saab JA-37 Viggen

General Dynamics YF-16

Related content

Wiki articles

Forum topics

External links