Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2020-12-06, 12:15


xyzzzikk

.gg






Wiek: 19
Na forum: 2915 dni
Posty: 175
Nick w MP: aspyk

Piwa: 6564

Respekt: 30,5

Pytanie, jak zrobi? efekt ruszania np. t?a jak ukazane jest na tym filmie?
https://www.youtube.com/watch?v=kdBDRBeEWDs

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-06, 12:44


_jvneczek







Wiek: 22
Na forum: 4466 dni
Posty: 1509
Nick w MP: _jvneczek

Piwa: 3960

Respekt: 337,5
Respekt: 337,5Respekt: 337,5Respekt: 337,5

Zrobi?em co? takiego w do?? prosty spos?b.
PLIK RT.lua

local PATH_SHADER = "files/shaders/"

function rt3DCreate( w, h )
    local rt = { }
    rt.w = w
    rt.h = h
    rt.shader = dxCreateShader( PATH_SHADER.."texture3d.fx" )
    rt.renderTarget = dxCreateRenderTarget( w, h, true )
    rt.fallback = not rt.renderTarget or not rt.shader

    return rt
end

function rt3DDestroy( rt )
    if isElement( rt.shader ) then
        destroyElement( rt.shader )
        return nil
    end
end

function rt3DSet( rt )
    if not rt then return end

    if rt.renderTarget and not rt.fallback then
        dxSetRenderTarget( rt.renderTarget, true )
    end
end

function rt3DDraw( rt, x, y, w, h ) 
    if rt.fallback then return end

    dxSetShaderValue( rt.shader, "sPicTexture", rt.renderTarget )
    dxDrawImage( x, y, w, h, rt.shader, 0, 0, 0, tocolor( 255, 255, 255, 245 ), true )
end

function rt3DTransform( rt, rx, ry, offset ) 
    if rt.fallback then return end
    if not offset then offset = 0 end

    dxSetShaderTransform( rt.shader, rx, ry, 0, 0, 0, offset )
end


PLIK client.lua

local renderTarget = false
function login()
        rt3DSet( renderTarget )
        dxDrawImage(0, 0, sx, sy, 'img.png', 0, 0, 0, tocolor(255,255,255, 255))

        dxSetRenderTarget( )

        if renderTarget then
            rt3DDraw( renderTarget, 0, 0, sx, sy )
            local mx, my=getCursorPosition( )

            if isCursorShowing ( ) then
            mx=mx*sx
            my=my*sy

            if not isCursorShowing( ) then
            mx, my=0*sx, 0*sy
            end

            local rx=-( mx-sx/2 )/sx*10
            local ry=( my-sy/2 )/sy*10
    
            rt3DTransform( renderTarget, rx, ry, 0 )
        end
    end
end

function startRes()
    addEventHandler('onClientRender', root, login)
    showCursor(true)
    if renderTarget then
        rt3DDestroy( renderTarget )
        renderTarget=nil
    end

    renderTarget = rt3DCreate( sx, sy )
    
end
addEventHandler('onClientResourceStart', getRootElement(), startRes)


i texture3d.fx

//
// Example shader - hud_mask.fx
//

#include "matrix.fx"

///////////////////////////////////////////////////////////////////////////////
// Global variables
///////////////////////////////////////////////////////////////////////////////
texture sPicTexture;

float2 gUVPrePosition = float2( 0, 0 );
float2 gUVScale = float( 1 );                     // UV scale
float2 gUVScaleCenter = float2( 0.5, 0.5 );
float gUVRotAngle = float( 0 );                   // UV Rotation
float2 gUVRotCenter = float2( 0.5, 0.5 );
float2 gUVPosition = float2( 0, 0 );              // UV position


///////////////////////////////////////////////////////////////////////////////
// Functions
///////////////////////////////////////////////////////////////////////////////


//-------------------------------------------
// Returns UV transform using external settings
//-------------------------------------------
float3x3 getTextureTransform()
{
    return makeTextureTransform( gUVPrePosition, gUVScale, gUVScaleCenter, gUVRotAngle, gUVRotCenter, gUVPosition );
}

///////////////////////////////////////////////////////////////////////////////
// Techniques
///////////////////////////////////////////////////////////////////////////////
technique hello
{
    pass P0
    {
        // Set up texture stage 0
        Texture[0] = sPicTexture;
        TextureTransform[0] = getTextureTransform();
        TextureTransformFlags[0] = Count2;
        AddressU[0] = Clamp;
        AddressV[0] = Clamp;
        // Color mix texture and diffuse
        ColorOp[0] = Modulate;
        ColorArg1[0] = Texture;
        ColorArg2[0] = Diffuse;
        // Alpha mix texture and diffuse
        AlphaOp[0] = Modulate;
        AlphaArg1[0] = Texture;
        AlphaArg2[0] = Diffuse;
    }
}



Efekt taki sam.
texture3d.fx jako file, RT i client po stronie clitenta + texture3d musisz sobie zmieni? folder

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-10, 12:31


xyzzzikk

.gg






Wiek: 19
Na forum: 2915 dni
Posty: 175
Nick w MP: aspyk

Piwa: 6564

Respekt: 30,5

zrobilem tak:
    exports["r_tex3d"]:rt3DSet( renderTarget )
        dxDrawRectangle(screenW * 0.2804, screenH * 0.2930, screenW * 0.4414, screenH * 0.0534, tocolor(25, 75, 125, 255), false)      
        dxSetRenderTarget( )


na koncu
  if renderTarget then
          exports["r_tex3d"]:rt3DDraw( renderTarget, 0, 0, sx, sy )
          local mx, my=getCursorPosition( )
        
          if isCursorShowing ( ) then
          mx=mx*sx
          my=my*sy
        
          if not isCursorShowing( ) then
          mx, my=0*sx, 0*sy
          end
        
          local rx=-( mx-sx/2 )/sx*10
          local ry=( my-sy/2 )/sy*10
        
          exports["r_tex3d"]:rt3DTransform( renderTarget, rx, ry, 0 )
        end
        end

oraz
addEventHandler("onClientResourceStart", resourceRoot, function()
  guiSetVisible(uzytkownik, true)
  guiSetVisible(haslo, true)
  addEventHandler("onClientRender", root, gui)
  showChat(false)
  showCursor(true)
  setPlayerHudComponentVisible("all", false)
  muzyka = playSound("muzyka.mp3", true)
  fadeCamera(true)
  triggerServerEvent("sprawdzBana", localPlayer)
  if renderTarget then
    exports["r_tex3d"]: rt3DDestroy( renderTarget )
    renderTarget=nil
end

aa
export w mecie tex3d to tak:
Kod:

<export function="rt3DSet" type="client" />
<export function="rt3DCreate" type="client" />
<export function="rt3DDestroy" type="client" />
<export function="rt3DDraw" type="client" />
<export function="rt3DTransform" type="client" />


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-10, 14:53


_jvneczek







Wiek: 22
Na forum: 4466 dni
Posty: 1509
Nick w MP: _jvneczek

Piwa: 3960

Respekt: 337,5
Respekt: 337,5Respekt: 337,5Respekt: 337,5

tworzysz to bez export?w, w mecie na pewno da?e? pierwszy skrypt RT.lua po stronie clienta? musi by? przed.

Postaw piwo autorowi tego posta
 

 
Tagi: efekt :: ruszania
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku