Add generic blackout/redout for all aircraft, along with a gui.
Based on previous work by vivian and myself.
This commit is contained in:
parent
318e5d28c5
commit
dd923792ec
4 changed files with 263 additions and 0 deletions
89
Nasal/redout.nas
Executable file
89
Nasal/redout.nas
Executable file
|
@ -0,0 +1,89 @@
|
|||
# Damped G value - starts at 1.
|
||||
var GDamped = 1.0;
|
||||
|
||||
var blackout = func {
|
||||
|
||||
var enabled = getprop("/sim/rendering/redout/enabled");
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
var blackout_start = getprop("/sim/rendering/redout/blackout-onset-g");
|
||||
var blackout_end = getprop("/sim/rendering/redout/blackout-complete-g");
|
||||
var redout_start = getprop("/sim/rendering/redout/redout-onset-g");
|
||||
var redout_end = getprop("/sim/rendering/redout/redout-complete-g");
|
||||
var internal = getprop("/sim/current-view/internal");
|
||||
|
||||
if ((blackout_start == nil) or
|
||||
(blackout_end == nil) or
|
||||
(redout_start == nil) or
|
||||
(redout_end == nil) )
|
||||
{
|
||||
# No valid properties - no point running
|
||||
return;
|
||||
}
|
||||
|
||||
var GCurrent = 1.0;
|
||||
|
||||
if (getprop("/sim/flight-model") == "jsb")
|
||||
{
|
||||
GCurrent = getprop("/accelerations/pilot/z-accel-fps_sec");
|
||||
if (GCurrent != nil) GCurrent = - GCurrent / 32;
|
||||
}
|
||||
else
|
||||
{
|
||||
GCurrent = getprop("/accelerations/pilot-g[0]");
|
||||
}
|
||||
|
||||
|
||||
if (GCurrent == nil) { GCurrent = 1.0; }
|
||||
|
||||
# Updated the GDamped using a filter.
|
||||
if (GDamped < 0)
|
||||
{
|
||||
# Redout happens faster and clears quicker
|
||||
GDamped = GDamped * 0.75 + GCurrent * 0.25;
|
||||
}
|
||||
else
|
||||
{
|
||||
GDamped = GDamped * 0.8 + GCurrent * 0.2;
|
||||
}
|
||||
|
||||
setprop("/accelerations/pilot-gdamped", GDamped);
|
||||
|
||||
if (internal)
|
||||
{
|
||||
if (GDamped > blackout_start)
|
||||
{
|
||||
# Blackout
|
||||
setprop("/sim/rendering/redout/red",0);
|
||||
setprop("/sim/rendering/redout/alpha",
|
||||
(GDamped - blackout_start) / (blackout_end - blackout_start));
|
||||
}
|
||||
elsif (GDamped < redout_start)
|
||||
{
|
||||
# Redout
|
||||
setprop("/sim/rendering/redout/red",1);
|
||||
setprop("/sim/rendering/redout/alpha",
|
||||
abs((GDamped - redout_start) / (redout_end - redout_start)));
|
||||
}
|
||||
else
|
||||
{
|
||||
setprop("/sim/rendering/redout/alpha",0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# Not in cockpit view - remove all redout/blackout
|
||||
setprop("/sim/rendering/redout/alpha",0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# Disabled - remove all redout/blackout
|
||||
setprop("/sim/rendering/redout/alpha",0);
|
||||
}
|
||||
|
||||
settimer(blackout, 0.1);
|
||||
}
|
||||
|
||||
_setlistener("/sim/signals/nasal-dir-initialized", func { blackout(); });
|
159
gui/dialogs/redout.xml
Normal file
159
gui/dialogs/redout.xml
Normal file
|
@ -0,0 +1,159 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<PropertyList>
|
||||
<name>redout</name>
|
||||
<layout>vbox</layout>
|
||||
<default-padding>4</default-padding>
|
||||
<modal>false</modal>
|
||||
|
||||
<text>
|
||||
<label>G-Force Blackout Settings</label>
|
||||
</text>
|
||||
|
||||
<hrule/>
|
||||
|
||||
<checkbox>
|
||||
<halign>left</halign>
|
||||
<label>Enable Blackout and Redout due to G-force.</label>
|
||||
<property>/sim/rendering/redout/enabled</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
</binding>
|
||||
</checkbox>
|
||||
|
||||
<hrule/>
|
||||
|
||||
<text>
|
||||
<halign>center</halign>
|
||||
<label>Blackout</label>
|
||||
</text>
|
||||
|
||||
<group>
|
||||
<layout>table</layout>
|
||||
<text>
|
||||
<row>0</row>
|
||||
<col>0</col>
|
||||
<label>Onset</label>
|
||||
</text>
|
||||
|
||||
<text>
|
||||
<row>0</row>
|
||||
<col>1</col>
|
||||
<halign>center</halign>
|
||||
<label>15.0</label>
|
||||
<format>%2.1f</format>
|
||||
<live>true</live>
|
||||
<property>/sim/rendering/redout/blackout-onset-g</property>
|
||||
</text>
|
||||
|
||||
<slider>
|
||||
<row>0</row>
|
||||
<col>2</col>
|
||||
<min>1.0</min>
|
||||
<max>15</max>
|
||||
<property>/sim/rendering/redout/blackout-onset-g</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
</binding>
|
||||
</slider>
|
||||
|
||||
<text>
|
||||
<row>1</row>
|
||||
<col>0</col>
|
||||
<label>Complete</label>
|
||||
</text>
|
||||
|
||||
<text>
|
||||
<row>1</row>
|
||||
<col>1</col>
|
||||
<halign>center</halign>
|
||||
<label>15.0</label>
|
||||
<format>%2.1f</format>
|
||||
<live>true</live>
|
||||
<property>/sim/rendering/redout/blackout-complete-g</property>
|
||||
</text>
|
||||
|
||||
<slider>
|
||||
<row>1</row>
|
||||
<col>2</col>
|
||||
<min>1.0</min>
|
||||
<max>15</max>
|
||||
<property>/sim/rendering/redout/blackout-complete-g</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
</binding>
|
||||
</slider>
|
||||
</group>
|
||||
|
||||
<hrule/>
|
||||
|
||||
<text>
|
||||
<halign>center</halign>
|
||||
<label>Redout</label>
|
||||
</text>
|
||||
|
||||
<group>
|
||||
<layout>table</layout>
|
||||
<text>
|
||||
<row>0</row>
|
||||
<col>0</col>
|
||||
<label>Onset</label>
|
||||
</text>
|
||||
|
||||
<text>
|
||||
<row>0</row>
|
||||
<col>1</col>
|
||||
<halign>center</halign>
|
||||
<label>15.0</label>
|
||||
<format>%2.1f</format>
|
||||
<live>true</live>
|
||||
<property>/sim/rendering/redout/redout-onset-g</property>
|
||||
</text>
|
||||
|
||||
<slider>
|
||||
<row>0</row>
|
||||
<col>2</col>
|
||||
<min>-1.0</min>
|
||||
<max>-15.0</max>
|
||||
<property>/sim/rendering/redout/redout-onset-g</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
</binding>
|
||||
</slider>
|
||||
|
||||
<text>
|
||||
<row>1</row>
|
||||
<col>0</col>
|
||||
<label>Complete</label>
|
||||
</text>
|
||||
|
||||
<text>
|
||||
<row>1</row>
|
||||
<col>1</col>
|
||||
<label>15.0</label>
|
||||
<format>%2.1f</format>
|
||||
<live>true</live>
|
||||
<property>/sim/rendering/redout/redout-complete-g</property>
|
||||
</text>
|
||||
|
||||
<slider>
|
||||
<row>1</row>
|
||||
<col>2</col>
|
||||
<min>-1.0</min>
|
||||
<max>-15.0</max>
|
||||
<property>/sim/rendering/redout/redout-complete-g</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
</binding>
|
||||
</slider>
|
||||
</group>
|
||||
|
||||
<button>
|
||||
<legend>Close</legend>
|
||||
<default>true</default>
|
||||
<key>Esc</key>
|
||||
<binding>
|
||||
<command>dialog-close</command>
|
||||
</binding>
|
||||
</button>
|
||||
</PropertyList>
|
|
@ -122,6 +122,14 @@
|
|||
</binding>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<label>G-force Options</label>
|
||||
<binding>
|
||||
<command>dialog-show</command>
|
||||
<dialog-name>redout</dialog-name>
|
||||
</binding>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<label>Adjust View Distance</label>
|
||||
<binding>
|
||||
|
|
|
@ -101,6 +101,13 @@ Started September 2000 by David Megginson, david@megginson.com
|
|||
<shadows-debug type="bool" userarchive="y">false</shadows-debug>
|
||||
<fps-display type="bool" userarchive="y">false</fps-display>
|
||||
<glide-slope-tunnel type="bool" userarchive="y">false</glide-slope-tunnel>
|
||||
<redout>
|
||||
<enabled type="bool" userarchive="y">true</enabled>
|
||||
<blackout-onset-g>3.5</blackout-onset-g>
|
||||
<blackout-complete-g>5</blackout-complete-g>
|
||||
<redout-onset-g>-2</redout-onset-g>
|
||||
<redout-complete-g>-4</redout-complete-g>
|
||||
</redout>
|
||||
</rendering>
|
||||
<model-hz type="int">120</model-hz>
|
||||
<navdb>
|
||||
|
|
Loading…
Add table
Reference in a new issue