Re: Gauges pour le Douglas C-47 (DC-3) AM 2.1.3 FSX P3D
Posté: Lun 5 Fév 2018 22:22
Echange et partage entre créateurs et réalisateurs de simulateurs de vol.
http://aircockpit.com/
jacquesvde a écrit:Bonjour,
Petite question vous faite comment pour poster une vidéo sur notre forum avec l'image incluse, moi je ne sais mettre qu'un lien via Youtube sans l'image ?
--------------------------------------------------
-- Airspeed indicator pour le Douglas C47
-- avec vibration des aiguilles en fonction du régime moteur
-- Jacques V
--------------------------------------------------
------------- Valeurs modèle pour les vibrations -------------------
-- sample Values for a modern single engine (Cessna, Piper, Robin)
-- frequency=40 -- increase the 40 value to slow down the overall vibrations for "slow running" engines (up to 100 max)
-- vibmax=80 --beginning of max vibrations in %power
-- valmax=0.05 -- range of max vibration values
-- vibmid=30 --beginning of medium vibrations in %power
-- valmid=0.07 -- range of medium vibration values
-- viblow=0.5 -- low idle
-- vallow=0.09 -- range of low vibration values
-- sample Values for a WWII Fighter
frequency=65 -- increase the 40 value to slow down the overall vibrations for "slow running" engines (up to 100 max)
vibmax=80 --beginning of max vibrations in %power
valmax=0.5 -- range of max vibration values
vibmid=30 --beginning of medium vibrations in %power
valmid=1 -- range of medium vibration values
viblow=0.25 -- low idle
vallow=2 -- range of low vibration values
-- sample values for a WW1 Fighter
-- frequency=70 -- increase the 40 value to slow down the overall vibrations for "slow running" engines (up to 100 max)
-- vibmax=75 --beginning of max vibrations in %power
-- valmax=4 -- range of max vibration values
-- vibmid=40 --beginning of medium vibrations in %power
-- valmid=2.5
-- viblow=0.1 --low idle
-- vallow=3.5
--------------------------Do not modify values beyond this line! ----------------------------------
-- Ne pas modifier les valeurs en dehors de cette ligne!
---------------------------------------------------------------------------------------------------------
img_add_fullscreen("AIRSEED_DC3.png")
img_aiguille=img_add_fullscreen("AIGUILLE.png")
mask_day = img_add_fullscreen("mask_day.png")
mask_light = img_add_fullscreen("mask_light.png")
mask_night = img_add_fullscreen("mask_night.png")
mask_dusk = img_add_fullscreen("mask_dusk.png")
--choix d'image en fontion de l'eclairage--
function new_light_FSX(light,ambiance,master)
lighted=light and master
img_visible(mask_light, lighted)
img_visible(mask_night, lighted == false and ambiance== 3)
img_visible(mask_dusk, lighted == false and ambiance== 2)
img_visible(mask_day, ambiance == 1)
end
--Images--
img_add_fullscreen("glass.png") -- Without glass insert two - at the beginning of the line
---------- Gestion des vibrations aiguille ---------------------------------------
local needlevalue=0
local rand=1
local val=0
local vibrationlvl=0
function vibrate(soundrpm) -- fonction pour FSX/P3D en fonction du volume sonore
if soundrpm<0.1 then
vibrationlvl=0
else
vibrationlvl=soundrpm
end
end
function timer_callback() -- function called every 40 mseconds, used to move the needle
rand=-rand -- offset value of the needle, alternatively to the left or to the right
-- setting up of the amplitude of vibrations depending of the % of sound produced, since engine vibration is not reliable
-- (Change val values to taste at the beginin of the code!)
if vibrationlvl>vibmax then -- high rpm, small amplitude
val=valmax
elseif vibrationlvl>vibmid then -- medium range rpm, larger amplitude of needle movements
val=valmid
elseif vibrationlvl>viblow then --slow rpm, smaller amplitude of needle movements
val=vallow
else -- engine stopped, no needle movements
val=0
end
needlepos=needlevalue+(rand*val) -- calculation of the needle movement (adding a random +/-value to the real value)
if needlevalue>=200 then
img_rotate(img_aiguille, (needlepos-200)*83/100+262)
elseif needlevalue>=160 then
img_rotate(img_aiguille, (needlepos-160)*67/40+195.5)
elseif needlevalue>=120 then
img_rotate(img_aiguille, (needlepos-120)*68/40+128)
elseif needlevalue>=100 then
img_rotate(img_aiguille, (needlepos-100)*32/20+95)
elseif needlevalue>=60 then
img_rotate(img_aiguille, (needlepos-60)*57/40+37)
elseif needlevalue>=40 then
img_rotate(img_aiguille, (needlepos-40)*1+17.5)
else
img_rotate(img_aiguille, (needlepos)*18/40)
end
end
function new_data(airspeed)
needlevalue = var_cap(airspeed,0, 300)
-- rotate the needle only if airspeed is above 20kts
if needlevalue<20 then needlevalue=0 end
end
--------------------------------------
-- Needle vibration related to engine sound volume -- vibration aiguille liée au volume sonore
fsx_variable_subscribe("GENERAL ENG COMBUSTION SOUND PERCENT:1","percent",vibrate)
--------------------------- Init airspeed- sends the needle to 0 at startup
new_data(0)
--------------------------- Timer used for engine vibration : frequency is used for vibration speed
timer_start(0,frequency,timer_callback)
-------------------------- Variables Subscription -------------------------
fsx_variable_subscribe("LIGHT PANEL","Bool",
"TIME OF DAY", "Enum",
"ELECTRICAL MASTER BATTERY", "Bool", new_light_FSX) -- FSX Variables night light
fsx_variable_subscribe("AIRSPEED INDICATED", "knots",new_data)
JacquesZ a écrit:Du coup, spécialement pour toi Jacques, voici la version "vibrante" de ta superbe jauge.
J'ai repris ton code en ajoutant la routine de vibration développée pour le DR 400. Elle est commentée (en anglais, désolé).
On peut jouer avec l'intensité des vibrations en changeant les paramètres au début du code.
La technique est applicable facilement aux jauges à aiguille, tu remarqueras que j'ai repris ton code pour les img_rotate.
- Code: Tout sélectionner
--------------------------------------------------
-- Airspeed indicator pour le Douglas C47
-- avec vibration des aiguilles en fonction du régime moteur
-- Jacques V
--------------------------------------------------
------------- Valeurs modèle pour les vibrations -------------------
-- sample Values for a modern single engine (Cessna, Piper, Robin)
-- frequency=40 -- increase the 40 value to slow down the overall vibrations for "slow running" engines (up to 100 max)
-- vibmax=80 --beginning of max vibrations in %power
-- valmax=0.05 -- range of max vibration values
-- vibmid=30 --beginning of medium vibrations in %power
-- valmid=0.07 -- range of medium vibration values
-- viblow=0.5 -- low idle
-- vallow=0.09 -- range of low vibration values
-- sample Values for a WWII Fighter
frequency=65 -- increase the 40 value to slow down the overall vibrations for "slow running" engines (up to 100 max)
vibmax=80 --beginning of max vibrations in %power
valmax=0.5 -- range of max vibration values
vibmid=30 --beginning of medium vibrations in %power
valmid=1 -- range of medium vibration values
viblow=0.25 -- low idle
vallow=2 -- range of low vibration values
-- sample values for a WW1 Fighter
-- frequency=70 -- increase the 40 value to slow down the overall vibrations for "slow running" engines (up to 100 max)
-- vibmax=75 --beginning of max vibrations in %power
-- valmax=4 -- range of max vibration values
-- vibmid=40 --beginning of medium vibrations in %power
-- valmid=2.5
-- viblow=0.1 --low idle
-- vallow=3.5
--------------------------Do not modify values beyond this line! ----------------------------------
-- Ne pas modifier les valeurs en dehors de cette ligne!
---------------------------------------------------------------------------------------------------------
img_add_fullscreen("AIRSEED_DC3.png")
img_aiguille=img_add_fullscreen("AIGUILLE.png")
mask_day = img_add_fullscreen("mask_day.png")
mask_light = img_add_fullscreen("mask_light.png")
mask_night = img_add_fullscreen("mask_night.png")
mask_dusk = img_add_fullscreen("mask_dusk.png")
--choix d'image en fontion de l'eclairage--
function new_light_FSX(light,ambiance,master)
lighted=light and master
img_visible(mask_light, lighted)
img_visible(mask_night, lighted == false and ambiance== 3)
img_visible(mask_dusk, lighted == false and ambiance== 2)
img_visible(mask_day, ambiance == 1)
end
--Images--
img_add_fullscreen("glass.png") -- Without glass insert two - at the beginning of the line
---------- Gestion des vibrations aiguille ---------------------------------------
local needlevalue=0
local rand=1
local val=0
local vibrationlvl=0
function vibrate(soundrpm) -- fonction pour FSX/P3D en fonction du volume sonore
if soundrpm<0.1 then
vibrationlvl=0
else
vibrationlvl=soundrpm
end
end
function timer_callback() -- function called every 40 mseconds, used to move the needle
rand=-rand -- offset value of the needle, alternatively to the left or to the right
-- setting up of the amplitude of vibrations depending of the % of sound produced, since engine vibration is not reliable
-- (Change val values to taste at the beginin of the code!)
if vibrationlvl>vibmax then -- high rpm, small amplitude
val=valmax
elseif vibrationlvl>vibmid then -- medium range rpm, larger amplitude of needle movements
val=valmid
elseif vibrationlvl>viblow then --slow rpm, smaller amplitude of needle movements
val=vallow
else -- engine stopped, no needle movements
val=0
end
needlepos=needlevalue+(rand*val) -- calculation of the needle movement (adding a random +/-value to the real value)
if needlevalue>=200 then
img_rotate(img_aiguille, (needlepos-200)*83/100+262)
elseif needlevalue>=160 then
img_rotate(img_aiguille, (needlepos-160)*67/40+195.5)
elseif needlevalue>=120 then
img_rotate(img_aiguille, (needlepos-120)*68/40+128)
elseif needlevalue>=100 then
img_rotate(img_aiguille, (needlepos-100)*32/20+95)
elseif needlevalue>=60 then
img_rotate(img_aiguille, (needlepos-60)*57/40+37)
elseif needlevalue>=40 then
img_rotate(img_aiguille, (needlepos-40)*1+17.5)
else
img_rotate(img_aiguille, (needlepos)*18/40)
end
end
function new_data(airspeed)
needlevalue = var_cap(airspeed,0, 300)
-- rotate the needle only if airspeed is above 20kts
if needlevalue<20 then needlevalue=0 end
end
--------------------------------------
-- Needle vibration related to engine sound volume -- vibration aiguille liée au volume sonore
fsx_variable_subscribe("GENERAL ENG COMBUSTION SOUND PERCENT:1","percent",vibrate)
--------------------------- Init airspeed- sends the needle to 0 at startup
new_data(0)
--------------------------- Timer used for engine vibration : frequency is used for vibration speed
timer_start(0,frequency,timer_callback)
-------------------------- Variables Subscription -------------------------
fsx_variable_subscribe("LIGHT PANEL","Bool",
"TIME OF DAY", "Enum",
"ELECTRICAL MASTER BATTERY", "Bool", new_light_FSX) -- FSX Variables night light
fsx_variable_subscribe("AIRSPEED INDICATED", "knots",new_data)
Amitiés
Jacques