Jump to content

Rotate ImageSection


RenanPG

Recommended Posts

Posted

hi everybody, i am making a radar in gta v style. but i dont know how to make this rotate.

    texture = dxDrawImageSection(telax, telay, tamanhox, tamanhoy, px, py, alt, alt, imagem, 0, 60, 60, tocolor(225, 225, 225, 180)) 

i know i can make this using this below, but i really don't understand about shaders.

dxCreateShader 
dxCreateRenderTarget 
dxSetRenderTarget 
dxSetShaderValue 
dxSetShaderTransform 
dxDrawImage 

Posted

Citizen, there's no need for that, ImageSection supports rotations:

rotation: the rotation, in degrees for the image.

rotationCenterOffsetX: the absolute X offset from the image center for which to rotate the image from.

rotationCenterOffsetY: the absolute Y offset from the image center for which to rotate the image from.

Also, since MTA 1.3.5, dx text also has these arguments.

  • Moderators
Posted

Yeah I know but isn't the GTA V radar a bit rotated on the 3rd axis ? (I never played it, just saw some videos). But yeah if he just need to rotate/spining on the screen plan, then yeah you are right, the dxDrawImageSection is just fine.

Posted (edited)

i only want to rotate the image not the dxDrawImageSection.

see this:

Radar.png

i think is -45 deegres on Y axe

Edited by Guest
  • Moderators
Posted
i only want to rotate the image not the dxDrawImageSection.

see this:

removed

i think is -45 deegres on Y axe

So I was totally right, he wants the image to be rotated a bit like if the top of the radar image being drawn was going inside the screen (I mean like the star wars credits at the end).

Posted
i only want to rotate the image not the dxDrawImageSection.

see this:

removed

i think is -45 deegres on Y axe

So I was totally right, he wants the image to be rotated a bit like if the top of the radar image being drawn was going inside the screen (I mean like the star wars credits at the end).

Yes, this i want

Posted
yeah so did you checked azeru's code ? This is for texts but you can easily modify it to make it work with an image:

viewtopic.php?f=91&t=65746&p=619388&hilit=dxSetShaderTransform&sid=50a5002b669ef97d724d2848a19d8175#p619388

is this correct?

local renderTarget = dxCreateRenderTarget(50 , 50, true) 
local shader = dxCreateShader("textureReplace.fx") 
  
function updateRenderTarget() 
    dxSetRenderTarget(renderTarget, true) 
    dxDrawImage (0, 0, 100, 100, "agua.png") 
    dxSetRenderTarget() 
    dxSetShaderValue(shader, "tex", renderTarget) 
end 
updateRenderTarget() 
  
addEventHandler("onClientRestore", root, 
function(didClear) 
    if(didClear)then 
        updateRenderTarget() 
    end 
end) 
  
addEventHandler("onClientRender", root, 
function() 
    dxSetShaderTransform(shader, 45, 0, 0)  
    local width, height = dxGetMaterialSize(renderTarget) 
    dxDrawImage((w/2), (h/2), 300, 300, shader) 
end) 
  
  

Posted

I give an example of an advance on my radar rotation

local screenx, screeny = guiGetScreenSize( ); 
local posX = 30; 
local posY = 157; 
-- Make sure it's the right values 
local width = 135; 
local height = 135; 
-- 
local scale = 2.2; 
local texture = dxCreateTexture( 'files/sattelite.dds', 'dxt5', true, 'clamp' ); 
imageWidth, imageHeight = dxGetMaterialSize( texture ); 
  
showPlayerHudComponent( "radar", false ) 
  
addEventHandler("onClientRender",root, 
    function( ) 
    
        local px ,py, pz = getElementPosition( localPlayer ) 
        local mapX = px / ( 6000 / imageWidth ) + ( imageWidth / 2 ) - ( width / scale / 2 ); 
        local mapY = py / ( -6000 / imageHeight ) + ( imageHeight / 2 ) - ( height / scale / 2 ); 
        local cx,cy,cz,tx,ty,tz = getCameraMatrix( ); 
        local rotation = findRotation( cx,cy,tx,ty ); 
  
        dxDrawImageSection( posX, screeny - posY, width, height, mapX, mapY, width / scale, height / scale, texture, rotation, 0, 0, tocolor( 255, 255, 255, 255 ), false ); 
        dxDrawText("Latin Server", screeny - posY, width, height, mapX, mapY, width / scale, height / scale, texture, rotation, 0, 0, tocolor( 255, 255, 255, 255 ), tocolor(9, 70, 245, 255), 0.65, "bankgothic", "left", "top", false, false, true, false, false) 
; 
        
        -- You can use a rectangle 
        --dxDrawRectangle( posX + width / 2, screeny - posY + height / 2, 5, 5, tocolor( 0, 0, 255, 255 ) ); 
        
        -- Or 
        dxDrawImage( posX + width / 2, screeny - posY + height / 2, 5, 5, "files/sattelite.dds" ); 
        
        
        --[[for i, v in ipairs( getElementsByType('player') ) do --Don't care to this. 
            if v ~= localPlayer then 
                local scale = 256/(3000*2) 
                local apx,apy,apz = getElementPosition(v) 
                local point_xx = box_screen_x+apx*scale 
                local point_yy = box_screen_y+apy*scale 
                dxDrawImage(point_xx, point_yy, ppx, ppy,"files/sattelite.dds") 
            end 
        end]] 
    end 
) 
  
function findRotation( x1, y1, x2, y2 ) 
    local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) ) 
    if t < 0 then 
        t = t + 360 
    end 
    return t 
end 

Posted

On yours?

That posted a guy(don't remember his name) on my radar topic.

Please don't say copied scripts are yours.

Btw that won't work. As the image would go out of the radar.

Posted

Jacobob14, if you don't know what we're talking about, don't help, yours radar rotate the dxDrawImageSection outside of the retangle. i want something that works correctly.

Posted

I tried making a gta V style radar in mta, but when rotating the image in 3d, the quality becomes horrible.

I had to change to a very high resolution map, but then the download is like 8mb.

Posted
I tried making a gta V style radar in mta, but when rotating the image in 3d, the quality becomes horrible.

I had to change to a very high resolution map, but then the download is like 8mb.

Can you pass your code to rotate for me via PM?? i will help you about quality image, probably using image with high compression in jpg can fix it.

Posted
Jacobob14, if you don't know what we're talking about, don't help, yours radar rotate the dxDrawImageSection outside of the retangle. i want something that works correctly.

I told him to take as example

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...