dofile(LockOn_Options.script_path.."config.lua")



shape_name = shape
if not new_shape then
    shift    = {-0.228, 5.0, 0}
    rotation = math.rad(5.17)
end

ambient_light    = {255, 255, 255}

ambient_color_day_texture    = {72, 100, 160}
ambient_color_night_texture  = {40, 60, 150}

ambient_color_from_devices   = {50, 50, 40}
ambient_color_from_panels    = {35, 25, 25}

dusk_border                  = 0.4

draw_old_cockpit             = false
draw_pilot                   = false

external_model_canopy_arg    = 38
external_model_canopy_trucks_arg = 118

-- main panel shaking
shake_filter_Y_Left_ = {IsHPF = false, B = 1/6.0, C = 1.0, Freq0 = 7.7, K = 0.013}
shake_filter_Y_Right_ = {IsHPF = false, B = 1/6.2, C = 1.0, Freq0 = 8.0, K = 0.015}
shake_filter_Z_ = {IsHPF = false, B = 1/4.0, C = 1.0, Freq0 = 7.5, K = 0.014}
        
rot_x_k = 1.0
cross_accel = 0.5

-- gun-sight shaking
sight_shake_filter_Y_ = {IsHPF = false, B = 1/6.0, C = 1.0, Freq0 = 10.7, K = 0.01}
sight_shake_filter_Z_ = {IsHPF = false, B = 1/4.0, C = 1.0, Freq0 = 11.5, K = 0.01}

shaking_dt          = 0.01

--use_external_views = true
cockpit_local_point = {-1.03, 0.72, 0.0}

day_texture_set_value   = 0.0
night_texture_set_value = 0.1

---------------------------------------------------------------
-- CONTROLLERS
---------------------------------------------------------------

local controllers = LoRegisterPanelControls()
--[[
mirrors_data = 
{
    center_point    = {0.488,0.139,0}, 
    width           = 0.35, --integrated (keep in mind that mirrors can be none planar )
    aspect          = 3.0,
    rotation        = math.rad(1);
    animation_speed = 2.0;
    near_clip       = 0.1;
    middle_clip     = 10;
    far_clip        = 60000;
}
--]]

mirrors_present = false;


mirrors_draw                    = CreateGauge()
mirrors_draw.arg_number         = 183
mirrors_draw.input              = {0,1}
mirrors_draw.output             = {1,0}
mirrors_draw.controller         = controllers.mirrors_draw

draw_arcade                  = LockOn_Options.flight.easy_radar or LockOn_Options.flight.auto_lockon


args_initial_state = {}

if not LockOn_Options.cockpit.mirrors then
   args_initial_state[183] = 1.0
end

-- Common Panel Shaker (Z)
Panel_Shake_Z               = CreateGauge()
Panel_Shake_Z.arg_number    = 146
Panel_Shake_Z.input         = {-1, 1}
Panel_Shake_Z.output        = {-0.8, 0.8}
Panel_Shake_Z.controller    = controllers.Panel_Shake_Z

-- Common Panel Shaker (Y)
Panel_Shake_Y               = CreateGauge()
Panel_Shake_Y.arg_number    = 147
Panel_Shake_Y.input         = {-1, 1}
Panel_Shake_Y.output        = {-0.8 ,0.8}
Panel_Shake_Y.controller    = controllers.Panel_Shake_Y

-- Common Panel Shaker (X)
Panel_Rot_X                 = CreateGauge()
Panel_Rot_X.arg_number      = 1489
Panel_Rot_X.input           = {-1, 1}
Panel_Rot_X.output          = {-0.5, 0.5}
Panel_Rot_X.controller      = controllers.Panel_Rot_X

-- Stick (Pitch)
StickPitch                  = CreateGauge()
StickPitch.arg_number       = 105
StickPitch.input            = {-1.0, 1.0}
StickPitch.output           = {-1.0, 1.0}
StickPitch.controller       = controllers.StickPitch

-- Stick (Roll)
StickBank                   = CreateGauge()
StickBank.arg_number        = 106
StickBank.input             = {-1.0, 1.0}
StickBank.output            = {-1.0, 1.0}
StickBank.controller        = controllers.StickBank

-- RudderPedals (Yaw)
RudderPedals                = CreateGauge()
RudderPedals.arg_number     = 102
RudderPedals.input          = {-1.0, 1.0}
RudderPedals.output         = {-1.0, 1.0}
RudderPedals.controller     = controllers.RudderPedals



Canopy_Trucks               = CreateGauge()
Canopy_Trucks.arg_number    = 162
Canopy_Trucks.input         = {0,1}
Canopy_Trucks.output        = {0,1}
Canopy_Trucks.controller    = controllers.Canopy_Trucks

Canopy_Visibility               = CreateGauge()
Canopy_Visibility.arg_number    = 163
Canopy_Visibility.input         = {0,1}
Canopy_Visibility.output        = {0,1}
Canopy_Visibility.controller    = controllers.Canopy_Visibility

Canopy_Crank                = CreateGauge()
Canopy_Crank.arg_number     = 147
Canopy_Crank.input          = {0.0, 1.0}
Canopy_Crank.output         = {0.0, 1.0}
Canopy_Crank.controller     = controllers.Canopy_Crank

--=================================================

Left_Wheel_Brake                = CreateGauge()
Left_Wheel_Brake.arg_number     = 103
Left_Wheel_Brake.input          = {0, 1}
Left_Wheel_Brake.output         = {0, 1}
Left_Wheel_Brake.controller     = controllers.Left_Wheel_Brake 

Right_Wheel_Brake               = CreateGauge()
Right_Wheel_Brake.arg_number    = 104
Right_Wheel_Brake.input         = {0, 1}
Right_Wheel_Brake.output        = {0, 1}
Right_Wheel_Brake.controller    = controllers.Right_Wheel_Brake

--[[Throttle
Throttle                    = CreateGauge()
Throttle.arg_number         = 43
Throttle.input              = {0, 1}
Throttle.output             = {0, 1}
Throttle.controller         = controllers.ThrottlePosition

--Propeller control
PropellerRPM                = CreateGauge()
PropellerRPM.arg_number     = 46
PropellerRPM.input          = {0, 1}
PropellerRPM.output         = {0, 1}
PropellerRPM.controller     = controllers.PropellerRPMPosition]]

-- Flight Instruments
-------------------------------------------------------
valMaxTurn = math.rad(2)

---------------------------------------------------
-- MW50 pressure
MW50_Pressure              			= CreateGauge()
MW50_Pressure.arg_number   			= 1
MW50_Pressure.input        			= {0.0, 3.0} -- kg/cm2
MW50_Pressure.output      	 		= {0.0, 1.0}
MW50_Pressure.controller   			= controllers.MW50_Pressure

---------------------------------------------------
--Airspeed Gauge
AirspeedNeedle              		= CreateGauge()
AirspeedNeedle.arg_number   		= 2
AirspeedNeedle.input        		= {0,   100,  150,   200,  700,  750,   900,  1000}
AirspeedNeedle.output       		= {0.0, 0.1,  0.15,  0.2,  0.7,  0.75,  0.9,  1.0}
AirspeedNeedle.controller   		= controllers.AirspeedNeedle

---------------------------------------------------
-- Artificial horizon Fl_22415
	--turn indicator
TurnNeedle              			= CreateGauge()
TurnNeedle.arg_number   			= 3
TurnNeedle.input        			= {-valMaxTurn, valMaxTurn}
TurnNeedle.output       			= {-1.0, 1.0}
TurnNeedle.controller   			= controllers.TurnNeedle

AHorizon_Bank                   	= CreateGauge()
AHorizon_Bank.arg_number        	= 4
AHorizon_Bank.input             	= {-math.pi, math.pi}
AHorizon_Bank.output            	= {1.0, -1.0}
AHorizon_Bank.controller        	= controllers.AHorizon_Bank

AHorizon_Pitch                  	= CreateGauge()
AHorizon_Pitch.arg_number       	= 5
AHorizon_Pitch.input            	= {-math.pi / 3.0, math.pi / 3.0}
AHorizon_Pitch.output           	= {1.0, -1.0}
AHorizon_Pitch.controller       	= controllers.AHorizon_Pitch

Slipball               				= CreateGauge()
Slipball.arg_number     			= 6
Slipball.input          			= {-1.0, 1.0}
Slipball.output         			= {-1.0, 1.0}
Slipball.controller     			= controllers.Slipball

AHorizon_Caged                  	= CreateGauge()
AHorizon_Caged.arg_number       	= 7
AHorizon_Caged.input            	= {0.0, 1.0}
AHorizon_Caged.output           	= {0.0, 1.0}
AHorizon_Caged.controller       	= controllers.AHorizon_Caged

---------------------------------------------------
--Altitude Gauge
Altimeter_FinePtr              		= CreateGauge()
Altimeter_FinePtr.arg_number   		= 8
Altimeter_FinePtr.input        		= {0.0, 1000.0}
Altimeter_FinePtr.output       		= {0.0, 1.0}
Altimeter_FinePtr.controller   		= controllers.Altimeter_FinePtr

Altimeter_CoarsePtr                 = CreateGauge()
Altimeter_CoarsePtr.arg_number      = 9
Altimeter_CoarsePtr.input           = {0.0, 13000.0}
Altimeter_CoarsePtr.output          = {0.0, 1.0}
Altimeter_CoarsePtr.controller      = controllers.Altimeter_CoarsePtr

Altimeter_Pressure                  = CreateGauge()
Altimeter_Pressure.arg_number       = 10
Altimeter_Pressure.input            = {712.56, 780.07}
Altimeter_Pressure.output           = {0.0, 1.0}
Altimeter_Pressure.controller       = controllers.Altimeter_Pressure

Pressure_Setter_Pinion              = CreateGauge()
Pressure_Setter_Pinion.arg_number   = 11
Pressure_Setter_Pinion.input        = {0.0, 1440.0}
Pressure_Setter_Pinion.output       = {0.0, 1.0}
Pressure_Setter_Pinion.controller   = controllers.Pressure_Setter_Pinion

---------------------------------------------------
-- AN5730 remote compass
CompassHeading                  	= CreateGauge()
CompassHeading.arg_number       	= 13
CompassHeading.input            	= {0.0, math.pi * 2.0}
CompassHeading.output           	= {0.0, 1.0}
CompassHeading.controller       	= controllers.CompassHeading

CommandedCourse                 	= CreateGauge()
CommandedCourse.arg_number      	= 12
CommandedCourse.input           	= {0.0, math.pi * 2.0}
CommandedCourse.output          	= {0.0, 1.0}
CommandedCourse.controller      	= controllers.CommandedCourse

----------------------------------------------------
-- AFN2 blind landing system
AFN2_Horizontal_Needle		  		= CreateGauge()
AFN2_Horizontal_Needle.arg_number   = 14
AFN2_Horizontal_Needle.input        = {-1.0, 1.0}
AFN2_Horizontal_Needle.output       = {-1.0, 1.0}
AFN2_Horizontal_Needle.controller   = controllers.AFN2_Horizontal_Needle

AFN2_Vertical_Needle		  	  	= CreateGauge()
AFN2_Vertical_Needle.arg_number   	= 15
AFN2_Vertical_Needle.input        	= {0.0, 1.0}
AFN2_Vertical_Needle.output       	= {0.0, 1.0}
AFN2_Vertical_Needle.controller   	= controllers.AFN2_Vertical_Needle

AFN2_Signal_Lamp		  	  		= CreateGauge()
AFN2_Signal_Lamp.arg_number   		= 16
AFN2_Signal_Lamp.input        		= {0.0, 1.0}
AFN2_Signal_Lamp.output       		= {0.0, 1.0}
AFN2_Signal_Lamp.controller   		= controllers.AFN2_Signal_Lamp

---------------------------------------------------
----------------------------------------------------
--Dual-Range Pressure Gauge
Fuel_Pressure               		= CreateGauge()
Fuel_Pressure.arg_number    		= 25
Fuel_Pressure.input        			= {0.0, 2.0} -- kg/cm2
Fuel_Pressure.output        		= {0.0, 1.0}
Fuel_Pressure.controller    		= controllers.Fuel_Pressure

Oil_Pressure                        = CreateGauge()
Oil_Pressure.arg_number             = 26
Oil_Pressure.input                  = {0.0, 10.0} 
Oil_Pressure.output                 = {0, 1.0}
Oil_Pressure.controller             = controllers.Oil_Pressure

Coolant_Temperature                 = CreateGauge()
Coolant_Temperature.arg_number      = 27
Coolant_Temperature.input           = {-1,   0,   130} 
Coolant_Temperature.output          = {-1,   0,   1}
Coolant_Temperature.controller      = controllers.Coolant_Temperature

Oil_Temperature                     = CreateGauge()
Oil_Temperature.arg_number          = 28
Oil_Temperature.input               = {-1,   0,   130}  
Oil_Temperature.output              = {-1,   0,   1}
Oil_Temperature.controller          = controllers.Oil_Temperature

Engine_RPM                          = CreateGauge()
Engine_RPM.arg_number               = 29
Engine_RPM.input                    = {400.0, 3600.0} 
Engine_RPM.output                   = {0.0, 1.0}
Engine_RPM.controller               = controllers.Engine_RPM

-- propeller pitch indicator, changed 1hour every 6degrees of pitch change  
Propeller_Pitch_Hour				= CreateGauge()
Propeller_Pitch_Hour.arg_number		= 30
Propeller_Pitch_Hour.input			= {0.0, 12.0} 
Propeller_Pitch_Hour.output			= {0.0, 1.0}
Propeller_Pitch_Hour.controller		= controllers.Propeller_Pitch_Hour

Propeller_Pitch_Minute				= CreateGauge()
Propeller_Pitch_Minute.arg_number	= 31
Propeller_Pitch_Minute.input		= {0.0, 60.0} 
Propeller_Pitch_Minute.output		= {0.0, 1.0}
Propeller_Pitch_Minute.controller	= controllers.Propeller_Pitch_Minute


Manifold_Pressure                   = CreateGauge()
Manifold_Pressure.arg_number        = 32
Manifold_Pressure.input             = {0.6, 1.8} 
Manifold_Pressure.output            = {0.0, 1.0}
Manifold_Pressure.controller        = controllers.Manifold_Pressure

--fuel system
Fuel_Tank_Fuselage              	= CreateGauge()
Fuel_Tank_Fuselage.arg_number   	= 33
Fuel_Tank_Fuselage.input        	= {-1.0,  0.0, 100.0, 150.0, 200.0, 250.0, 300.0, 350.0,  400.0} -- Liters
Fuel_Tank_Fuselage.output       	= {-1.0,  0.0,  0.07, 0.175,  0.31,  0.52,  0.73,  0.88,    1.0}
Fuel_Tank_Fuselage.controller   	= controllers.Fuel_Tank_Fuselage

--oxygen pressure indicator
Oxygen_Pressure                 	= CreateGauge()
Oxygen_Pressure.arg_number      	= 34
Oxygen_Pressure.input          		= {0.0, 250.0}
Oxygen_Pressure.output          	= {0.0, 1.0}
Oxygen_Pressure.controller      	= controllers.Oxygen_Pressure

Oxygen_Flow_Blinker             	= CreateGauge()
Oxygen_Flow_Blinker.arg_number  	= 35
Oxygen_Flow_Blinker.input      	 	= {0.0, 1.0}
Oxygen_Flow_Blinker.output      	= {0.0, 1.0}
Oxygen_Flow_Blinker.controller  	= controllers.Oxygen_Flow_Blinker

Variometer                  		= CreateGauge()
Variometer.arg_number       		= 36
Variometer.input            		= {-30,  -10,  -5,    0,   5,    10,  30}
Variometer.output           		= {-0.3, -0.1, -0.05, 0.0, 0.05, 0.1, 0.3}
Variometer.controller       		= controllers.VariometerNeedle

--Weapon gauges

MG131_0_Shell_Counter               = CreateGauge()
MG131_0_Shell_Counter.arg_number    = 40
MG131_0_Shell_Counter.input         = {0.0, 500.0} 
MG131_0_Shell_Counter.output        = {0.0, 1.0}
MG131_0_Shell_Counter.controller    = controllers.MG131_0_Shell_Counter

MG131_1_Shell_Counter               = CreateGauge()
MG131_1_Shell_Counter.arg_number    = 41
MG131_1_Shell_Counter.input         = {0.0, 500.0} 
MG131_1_Shell_Counter.output        = {0.0, 1.0}
MG131_1_Shell_Counter.controller    = controllers.MG131_1_Shell_Counter

MG131_0_Klappanker		          	= CreateGauge()
MG131_0_Klappanker.arg_number   	= 42
MG131_0_Klappanker.input        	= {0.0, 60.0} 
MG131_0_Klappanker.output       	= {0.0, 1.0}
MG131_0_Klappanker.controller   	= controllers.MG131_0_Klappanker

MG131_1_Klappanker     		     	= CreateGauge()
MG131_1_Klappanker.arg_number   	= 43
MG131_1_Klappanker.input        	= {0.0, 60.0} 
MG131_1_Klappanker.output       	= {0.0, 1.0}
MG131_1_Klappanker.controller   	= controllers.MG131_1_Klappanker


LeftWing_MG151_Control_Lamp          	 = CreateGauge()
LeftWing_MG151_Control_Lamp.arg_number   = 44
LeftWing_MG151_Control_Lamp.input        = {0.0, 1.0} 
LeftWing_MG151_Control_Lamp.output       = {0.0, 1.0}
LeftWing_MG151_Control_Lamp.controller   = controllers.LeftWing_MG151_Control_Lamp

RightWing_MG151_Control_Lamp          	  = CreateGauge()
RightWing_MG151_Control_Lamp.arg_number   = 45
RightWing_MG151_Control_Lamp.input        = {0.0, 1.0} 
RightWing_MG151_Control_Lamp.output       = {0.0, 1.0}
RightWing_MG151_Control_Lamp.controller   = controllers.RightWing_MG151_Control_Lamp


---------------------------------------------------
--REVI_16B_Gunsight
BodyState              					= CreateGauge()
BodyState.arg_number   					= 46
BodyState.input        					= {0.0, 0.15,0.25, 1.0}
BodyState.output       					= {0.0, 0.15,0.25, 1.0}
BodyState.controller   					= controllers.BodyState

SmokedScreen            				= CreateGauge()
SmokedScreen.arg_number   				= 47
SmokedScreen.input        				= {0.0,  1.0}
SmokedScreen.output       				= {0.0,  1.0}
SmokedScreen.controller   				= controllers.SmokedScreen

SightBrightness            				= CreateGauge()
SightBrightness.arg_number   			= 48
SightBrightness.input        			= {0.0,  1.0}
SightBrightness.output       			= {0.0,  1.0}
SightBrightness.controller   			= controllers.SightBrightness

------------------------------------------------------
LandingGearRedLight                 	 = CreateGauge()
LandingGearRedLight.arg_number      	 = 56
LandingGearRedLight.input           	 = {0.0, 1.0} 
LandingGearRedLight.output          	 = {0.0, 1.0}
LandingGearRedLight.controller      	 = controllers.LandingGearRedLight

LandingGearGreenLightLeft               = CreateGauge()
LandingGearGreenLightLeft.arg_number    = 57
LandingGearGreenLightLeft.input         = {0.0, 1.0} 
LandingGearGreenLightLeft.output        = {0.0, 1.0}
LandingGearGreenLightLeft.controller    = controllers.LandingGearGreenLightLeft

LandingGearGreenLightRight               = CreateGauge()
LandingGearGreenLightRight.arg_number    = 58
LandingGearGreenLightRight.input         = {0.0, 1.0} 
LandingGearGreenLightRight.output        = {0.0, 1.0}
LandingGearGreenLightRight.controller    = controllers.LandingGearGreenLightRight

Fuel_Reserve_Lamp               = CreateGauge()
Fuel_Reserve_Lamp.arg_number    = 135
Fuel_Reserve_Lamp.input     	= {0.0, 29.0}
Fuel_Reserve_Lamp.output        = {0.0, 1.0}
Fuel_Reserve_Lamp.controller    = controllers.Fuel_Reserve_Lamp



pilot_draw                      = CreateGauge()
pilot_draw.arg_number           = 540
pilot_draw.input                = {0.0, 1.0}
pilot_draw.output               = {0.0, 1.0}
pilot_draw.controller           = controllers.pilot_draw

Z_test =
{
    near = 0.05,
    far  = 4.0,
} 
need_to_be_closed = true -- close lua state after initialization 

dofile(LockOn_Options.common_script_path.."tools.lua")
livery = find_custom_livery("Bf-109K-4","default")
