Jump to content

help radar


Recommended Posts

how can I get the radar also rotate in 3d

thus http://prntscr.com/2xusz5

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 ); 
  
        
        -- 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/ten.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/arco.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 

Link to comment

i think it isnt possible, because the

dxDrawImageSection 

dont rotate the image, only rotate whole DX.

bool dxDrawImageSection ( float posX, float posY, float width, float height, float u, float v, float usize, float vsize, mixed image,  
[ float rotation = 0, float rotationCenterOffsetX = 0, float rotationCenterOffsetY = 0, int color = white, bool postGUI = false ] ) 

https://wiki.multitheftauto.com/wiki/DxDrawImageSection

bur you can drw this using others functions DX, but is difficult.

something like this can rotate:

dxDrawImage3D 

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