Jump to content

Visualizaciones


Recommended Posts

Bueno estaba aburrido asi que hice esto:

local handl = nil 
local sX, sY = guiGetScreenSize() 
local colors = { tocolor(255,0,0),tocolor(0,255,0) } 
local state = 1 
local size = 200 
local tick = 0 
  
function clientRenderFunc() 
    if(handl) then 
        local posX = sX/2 
        local posY = sY/2 
        if state == 1 then 
            local bt = getSoundFFTData ( handl, 16384, 1921 ) 
            if(not bt) then return end 
            for i = 1, 1920 do 
                local x = (i) 
                local y = 853*bt[i - 1] 
                local x2 = (i+1) 
                local y2 = 853*bt[i] 
                dxDrawLine(x, sY - 200 - y, x2, sY - 200 - y2, tocolor(255, 255, 255, 255) ) 
                dxDrawLine(x, sY - 200 - y, x2, sY, tocolor(0, 0, 0, 100) ) 
            end 
            dxDrawImage(posX - size, posY-size, size*2, size*2, "logohd.png") 
        elseif state == 2 then 
            local bt = getSoundFFTData ( handl, 16384, 257 ) 
            if(not bt) then return end 
            for i = 1, 256 do 
                local x = (i)*7.5 
                local y = 853*bt[i - 1] 
                local x2 = (i+1)*7.5 
                local y2 = 853*bt[i] 
                dxDrawLine(x, sY - 200 - y, x2, sY - 200 - y2, tocolor(255, 255, 255, 255) ) 
                dxDrawLine(x, sY - 200 - y, x2, sY, tocolor(0, 0, 0, 100) ) 
            end 
            dxDrawImage(posX - size, posY-size, size*2, size*2, "logohd.png") 
        elseif state == 3 then 
            local bt = getSoundFFTData ( handl, 16384, 513 ) 
            if(not bt) then return end 
            for i = 1, 512 do 
                local x = (i)*3.75 
                local y = 853*bt[i - 1] 
                local x2 = (i+1)*3.75 
                local y2 = 853*bt[i] 
                dxDrawLine(x, sY - 200 - y, x2, sY - 200 - y2, tocolor(255, 255, 255, 255) ) 
                dxDrawLine(x, sY - 200 - y, x2, sY, tocolor(0, 0, 0, 100) ) 
            end 
            dxDrawImage(posX - size, posY-size, size*2, size*2, "logohd.png") 
        elseif state == 4 then 
            local bt = getSoundWaveData ( handl, 16384, 3610) 
            if(not bt) then return end 
            local posX = sX/2 
            local posY = sY/2 
            local sample = 270 
            for i = 90, 270 do 
                local ID = 2*(sample-i)+1 
                local ID2 = 2*(sample-i) 
                local x = math.cos((i-1)*(3.14159265359/180)) * (size + math.max((bt[ID]*128), 0)) 
                local y = math.sin((i-1)*(3.14159265359/180)) * (size + math.max((bt[ID]*128), 0)) 
                local x2 = math.cos(i*(3.14159265359/180)) * (size + math.max((bt[ID2]*128), 0)) 
                local y2 = math.sin(i*(3.14159265359/180)) * (size + math.max((bt[ID2]*128), 0)) 
                local x3 = math.cos(i*(3.14159265359/180)) * size 
                local y3 = math.sin(i*(3.14159265359/180)) * size 
                dxDrawLine(posX + x3, posY + y3 , posX + x, posY + y, tocolor(0, 0, 0, 255) ) 
            end 
            for i = 270, 450 do 
                local ID = (2*i)-270 
                local ID2 = (i == 360 and 0 or (2*i)-269) 
                local x = math.cos((i-1)*(3.14159265359/180)) * (size + math.max((bt[ID]*128), 0)) 
                local y = math.sin((i-1)*(3.14159265359/180)) * (size + math.max((bt[ID]*128), 0)) 
                local x2 = math.cos(i*(3.14159265359/180)) * (size + math.max((bt[ID2]*128), 0)) 
                local y2 = math.sin(i*(3.14159265359/180)) * (size + math.max((bt[ID2]*128), 0)) 
                local x3 = math.cos(i*(3.14159265359/180)) * size 
                local y3 = math.sin(i*(3.14159265359/180)) * size 
                dxDrawLine(posX + x3, posY + y3 , posX + x, posY + y, tocolor(0, 0, 0, 255) ) 
            end 
            dxDrawImage(posX - size, posY-size, size*2, size*2, "logohd.png") 
        elseif state == 5 then 
             
            local bt = getSoundFFTData ( handl, 16384, 1920 ) 
            if(not bt) then return end 
            local posX = sX/2 
            local posY = sY/2 
            for i = 1, 360 do 
                local x = math.cos((i-1)*(3.14159265359/180)) * (size + (bt[i-1]*853)) 
                local y = math.sin((i-1)*(3.14159265359/180)) * (size + (bt[i-1]*853)) 
                local x2 = math.cos(i*(3.14159265359/180)) * (size + (bt[(i == 360 and 0 or i)]*853)) 
                local y2 = math.sin(i*(3.14159265359/180)) * (size + (bt[(i == 360 and 0 or i)]*853)) 
                dxDrawLine(posX + x2, posY + y2, posX + x, posY + y, tocolor(0, 0, 0, 255) ) 
            end 
            dxDrawImage(posX - size, posY-size, size*2, size*2, "logohd.png") 
        elseif state == 6 then 
            local bt = getSoundFFTData ( handl, 16384, 1920 ) 
            if(not bt) then return end 
            local posX = sX/2 
            local posY = sY/2 
            for i = 1, 360 do 
                local x = math.cos((i-1)*(3.14159265359/180)) * (size + (bt[i-1]*853)) 
                local y = math.sin((i-1)*(3.14159265359/180)) * (size + (bt[i-1]*853)) 
                local x2 = math.cos(i*(3.14159265359/180)) * (size + (bt[i]*853)) 
                local y2 = math.sin(i*(3.14159265359/180)) * (size + (bt[i]*853)) 
                local x3 = math.cos(i*(3.14159265359/180)) * size 
                local y3 = math.sin(i*(3.14159265359/180)) * size 
                dxDrawLine(posX + x3, posY + y3 , posX + x, posY + y, tocolor(0, 0, 0, 255) ) 
            end 
            dxDrawImage(posX - size, posY-size, size*2, size*2, "logohd.png") 
        elseif state == 7 then 
            local bt = getSoundFFTData ( handl, 16384, 3610) 
            if(not bt) then return end 
            local posX = sX/2 
            local posY = sY/2 
            local sample = 270 
            for i = 90, 270 do 
                local ID = sample-i+1 
                local ID2 = sample-i 
                local x = math.cos((i-1)*(3.14159265359/180)) * (size + (bt[ID]*853)) 
                local y = math.sin((i-1)*(3.14159265359/180)) * (size + (bt[ID]*853)) 
                local x2 = math.cos(i*(3.14159265359/180)) * (size + (bt[ID2]*853)) 
                local y2 = math.sin(i*(3.14159265359/180)) * (size + (bt[ID2]*853)) 
                dxDrawLine(posX + x2, posY + y2, posX + x, posY + y, tocolor(0, 0, 0, 255) ) 
            end 
            for i = 270, 450 do 
                local ID = i-270 
                local ID2 = (i == 360 and 0 or i-269) 
                local x = math.cos((i-1)*(3.14159265359/180)) * (size + (bt[ID]*853)) 
                local y = math.sin((i-1)*(3.14159265359/180)) * (size + (bt[ID]*853)) 
                local x2 = math.cos(i*(3.14159265359/180)) * (size + (bt[ID2]*853)) 
                local y2 = math.sin(i*(3.14159265359/180)) * (size + (bt[ID2]*853)) 
                dxDrawLine(posX + x2, posY + y2, posX + x, posY + y, tocolor(0, 0, 0, 255) ) 
            end 
            dxDrawImage(posX - size, posY-size, size*2, size*2, "logohd.png") 
        elseif state == 8 then 
            local bt = getSoundFFTData ( handl, 16384, 3610) 
            if(not bt) then return end 
            local posX = sX/2 
            local posY = sY/2 
            local sample = 270 
            for i = 90, 270 do 
                local ID = sample-i+1 
                local ID2 = sample-i 
                local x = math.cos((i-1)*(3.14159265359/180)) * (size + math.min((bt[ID]*1000), 500)) 
                local y = math.sin((i-1)*(3.14159265359/180)) * (size + math.min((bt[ID]*1000), 500)) 
                local x2 = math.cos(i*(3.14159265359/180)) * (size + math.min((bt[ID2]*1000), 500)) 
                local y2 = math.sin(i*(3.14159265359/180)) * (size + math.min((bt[ID2]*1000), 500)) 
                local x3 = math.cos(i*(3.14159265359/180)) * size 
                local y3 = math.sin(i*(3.14159265359/180)) * size 
                dxDrawLine(posX + x3, posY + y3 , posX + x, posY + y, tocolor(0, 0, 0, 255) ) 
            end 
            for i = 270, 450 do 
                local ID = i-270 
                local ID2 = (i == 360 and 0 or i-269) 
                local x = math.cos((i-1)*(3.14159265359/180)) * (size + math.min((bt[ID]*1000), 500)) 
                local y = math.sin((i-1)*(3.14159265359/180)) * (size + math.min((bt[ID]*1000), 500)) 
                local x2 = math.cos(i*(3.14159265359/180)) * (size + math.min((bt[ID2]*1000), 500)) 
                local y2 = math.sin(i*(3.14159265359/180)) * (size + math.min((bt[ID2]*1000), 500)) 
                local x3 = math.cos(i*(3.14159265359/180)) * size 
                local y3 = math.sin(i*(3.14159265359/180)) * size 
                dxDrawLine(posX + x3, posY + y3 , posX + x, posY + y, tocolor(0, 0, 0, 255) ) 
            end 
            dxDrawImage(posX - size, posY-size, size*2, size*2, "logohd.png") 
        end 
    end 
     
    if getKeyState("num_8") then 
        size = size + 5 
    elseif getKeyState("num_2") then 
        size = size - 5 
    end 
end 
  
  
  
function changeMode(cmd, st) 
    state = state + 1 
end 
addCommandHandler("changeMode", changeMode) 
  
function clientSoundStopFunc(_) 
    if(source == handl) then 
    removeEventHandler("onClientRender",root,clientRenderFunc) 
    removeEventHandler("onClientSoundStopped",root,clientSoundStopFunc) 
    handl = nil 
    end 
end 
  
function musicStartFunc() 
    if(not handl) then 
        handl = playSound('music.mp3') 
        setSoundSpeed ( handl, 1 ) 
        setSoundPosition ( handl, 47 ) 
        addEventHandler("onClientRender",root,clientRenderFunc) 
    addEventHandler("onClientSoundStopped",root,clientSoundStopFunc) 
    end 
end 
  
function musicStopFunc() 
    if(handl) then 
        stopSound(handl) 
        handl = nil 
        removeEventHandler("onClientRender",root,clientRenderFunc) 
    removeEventHandler("onClientSoundStopped",root,clientSoundStopFunc) 
    end 
end 
  
bindKey("9","down",musicStartFunc) 
bindKey("0","down",musicStopFunc) 

Si, no es para nada eficiente ni adaptado a todas las resoluciones, no hice esto para algo en concreto solo para pasar el tiempo. Ya que vi un vídeo en youtube que usaba una cosa como esta estas pero con After Effect que queda mucho mejor y dije por que no...

Edited by Guest
Link to comment
Se ve bien, pero para pc con pocos recurso de procesamiento de datos (procesador de baja capacidad), seguro dará muchos problemas.

Por lo general me gusta.

Es matemática básica, no hay nada distinto de lo que el juego por sí solo ejecuta en cada frame.

Por cierto, concuerdo con Alexs, pensé que nada podía aún sorprenderme en MTA, ¡buen trabajo!

Link to comment
  • 3 weeks later...
Se te copiaron en el apartado inglés jaja, teneis las mismas ideas.

Explícate como que se me copiaron? Te refieres a Samake?

Si es así no se copio ya que el hizo una versión bastante mas extendida y mejorada con shaders y varias cosas mas según yo se

Link to comment
  • 7 months later...
On 6/1/2017 at 0:54 AM, Jose76Tron said:

Es posible recrear esto pero con shaders en una pared por ejemplo? Estaría muy bueno

Si, es posible utilizando un renderTarget y dxDrawMaterialLine3D. En general los shaders se utilizan para transformación compleja de colores a nivel de GPU y para cosas como esta deben utilizarse las posibilidades directas que entrega la librería gráfica (todas esas funciones que empiezan por dx, jé).

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...