Dorex
Rick
Wiek: 28 Na forum: 4856 dni Posty: 108
Piwa : 2471
Funkcja podzielona (Serwer i Klient)
Sk?adnia:
float float float interpolateBetween ( float x1 , float y1 , float z1 , float x2 , float y2 , float z2 , float fProgress , string strEasingType , [ float fEasingPeriod , float fEasingAmplitude , float fEasingOvershoot ] )
InterpolateBetween - jest to interpolacja wektora 3D, kt?ry wylicza pomi?dzy warto?ci? pocz?tkow? a docelow?, mo?na by? r?wnie? stosowana do interopolacji 2D, operuje si? na niej przy pomocy parametr?w x,y,z.
Wymagane argumenty:
- x1, y1, z1 - wsp??rz?dne pocz?tkowe wektora 3D lub warto?ci
- x2, y2, z2 - wsp??rz?dne docelowe wektora 3D lub warto?ci
- fProgress - warto?? zmiennoprzecinkowa pomi?dzy 0 a 1, kt?ra to okre?la post?p interpolacji (0 warto?? pocz?tkowa, 1 warto?? docelowa)
- strEasingType - okre?lenie z?agodzenia dla interpolacji (t?umacz?c oznacza to wyb?r profilu funkcji dla naszej interpolacji)
Profile funkcji:
https://wiki.multitheftauto.com/wiki/Easing
Opcjonalne argumenty:
- fEasingPeriod - Okre?la zmian? dynamiki funkcji (tylko niekt?re funkcje mog? przyjmowa? ten argument) (domy?lnie przyjmuje warto?? 0,3)
- fEasingAmplitude - Okre?la amplitud? dla profilu funkcji (domy?lnie przyjmuje warto?? 1,0)
- fEasingOvershoot - Okre?la regulacje podczas zmiany dynamiki (domy?lnie przyjmuje warto?? 1,701)
Zwroty:
Zwraca interpolacje 3D wektora x, y, z, w przypadku b??du argumentu przyjmuje warto?? false.
Przyk?ad:
Przyk?ad wykorzystuje r??nice mi?dzy getTickCount oraz pozwala ustali? czas zako?czenia interpolacji, okres dla profilu funkcji, amplitud?, regulacje podczas zmiany dynamiki
Strona Klienta:
local sW , sH = guiGetScreenSize ( )
Used = false
EasingType = { "Linear" , "InQuad" , "OutQuad" , "InOutQuad" , "OutInQuad" , "InElastic" , "OutElastic" , "InOutElastic" , "OutInElastic" , "InBack" , "OutBack" , "InOutBack" , "OutInBack" , "InBounce" , "OutBounce" , "InOutBounce" , "OutInBounce" , "SineCurve" , "CosineCurve" }
function onClientRenderInterpolate ()
local czas_uplyniety = getTickCount ( ) - czas_poczatkowy
local czas_trwania = czas_koncowy - czas_poczatkowy
local postep = czas_uplyniety / czas_trwania
local x , y , z = interpolateBetween ( start_X , start_Y , start_Z , end_X , end_Y , end_Z , postep , profil_funkcji , okres_funkcji , amplituda_funkcji , regulacja_funkcji )
local tekst = profil_funkcji .. " " .. tonumber ( postep * 100 ) .. "% [" .. okres_funkcji .. ", " .. amplituda_funkcji .. ", " .. regulacja_funkcji .. "]"
setElementPosition ( G_marker , x , y , z )
if postep >= 1 then
Used = false
if isElement ( G_marker ) then destroyElement ( G_marker ) end
outputChatBox ( tekst )
removeEventHandler ( "onClientRender" , getRootElement (), onClientRenderInterpolate )
end
local width = dxGetTextWidth ( tekst , 2 , "default-bold" )
local height = dxGetFontHeight ( 2 , "default-bold" )
dxDrawText ( tekst , sW / 2 - width / 2 , sH / 2 - height / 2 , width , height , tocolor ( 255 , 255 , 255 , 255 ), 2 , "default-bold" )
end
function Interpolacja ( CMD , profil , czas , okres , amplituda , regulacja )
if not profil then
outputChatBox ( "Sk?adania /" .. CMD .. " nazwa profilu funkcji [czas trwania, okres, amplituda, regulacja]" , 175 , 0 , 0 )
return
end
if Used then
outputChatBox ( "Interpolacja jest w?a?nie wykonywana prosz? poczeka?" , 175 , 0 , 0 )
return
end
for i , v in ipairs ( EasingType ) do
outputConsole ( v )
if v == profil then
czas_poczatkowy = getTickCount ( )
czas_koncowy = getTickCount ( )+( tonumber ( czas ) ~= nil and tonumber ( czas ) or 2500 )
profil_funkcji = tostring ( v )
okres_funkcji = ( tonumber ( okres ) ~= nil and tonumber ( okres ) or 0.3 )
amplituda_funkcji = ( tonumber ( amplituda ) ~= nil and tonumber ( amplituda ) or 1.0 )
regulacja_funkcji = ( tonumber ( regulacja ) ~= nil and tonumber ( regulacja ) or 1.701 )
Used = true
local x , y , z = getElementPosition ( localPlayer )
local _ , _ , rz = getElementRotation ( localPlayer , "default" , true )
local rz = math . rad ( 360 - rz )
local x = x + 1.0 * math . sin ( rz )
local y = y + 1.0 * math . cos ( rz )
local z = z + 2
start_X , start_Y , start_Z = x , y , z
end_X , end_Y , end_Z = x , y , z - 3
G_marker = createMarker ( x , y , z , "cylinder" , 1.0 , 255 , 0 , 0 , 155 )
addEventHandler ( "onClientRender" , getRootElement (), onClientRenderInterpolate )
return
end
end
outputChatBox ( "Nie znaleziono profilu funkcji o nazwie " .. tostring ( profil ), 175 , 0 , 0 )
end
addCommandHandler ( "interpolacja" , Interpolacja )
Pokaz wideo:
VIDEO
PEŁNY EKRAN Odnośnik YouTube
Podpis
Nie bądź 🐷 postaw piwo.