RenanPG Posted March 5, 2014 Share Posted March 5, 2014 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 Link to comment
Moderators Citizen Posted March 5, 2014 Moderators Share Posted March 5, 2014 This might help you: viewtopic.php?f=91&t=65746&p=619388&hilit=dxSetShaderTransform&sid=50a5002b669ef97d724d2848a19d8175#p619388 Link to comment
Spajk Posted March 5, 2014 Share Posted March 5, 2014 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. Link to comment
Moderators Citizen Posted March 5, 2014 Moderators Share Posted March 5, 2014 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. Link to comment
Karuzo Posted March 5, 2014 Share Posted March 5, 2014 Yeah but won't go the map outside of the radar ? I think youll need a rendertarget either , if im right. Sorry if im not. Link to comment
RenanPG Posted March 5, 2014 Author Share Posted March 5, 2014 (edited) i only want to rotate the image not the dxDrawImageSection. see this: i think is -45 deegres on Y axe Edited March 5, 2014 by Guest Link to comment
Karuzo Posted March 5, 2014 Share Posted March 5, 2014 What image? The radar is the image section. Link to comment
Moderators Citizen Posted March 5, 2014 Moderators Share Posted March 5, 2014 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). Link to comment
RenanPG Posted March 5, 2014 Author Share Posted March 5, 2014 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 Link to comment
Moderators Citizen Posted March 5, 2014 Moderators Share Posted March 5, 2014 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 Link to comment
RenanPG Posted March 5, 2014 Author Share Posted March 5, 2014 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) Link to comment
Jacobob14 Posted March 5, 2014 Share Posted March 5, 2014 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 Link to comment
Karuzo Posted March 5, 2014 Share Posted March 5, 2014 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. Link to comment
Jacobob14 Posted March 5, 2014 Share Posted March 5, 2014 works for me well and I published recently that had a problem with the script Link to comment
Karuzo Posted March 5, 2014 Share Posted March 5, 2014 I don't mean that i won't work. Ofc it works. Im using it myself. But the image would go out of the rectangle and that looks ugly. Link to comment
Jacobob14 Posted March 5, 2014 Share Posted March 5, 2014 leaves the rectangle when the image is small I Use a map with dds format Link to comment
Karuzo Posted March 5, 2014 Share Posted March 5, 2014 What? Btw, how should he use the .dds picture if he doesn't have it lol Link to comment
RenanPG Posted March 5, 2014 Author Share Posted March 5, 2014 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. Link to comment
arezu Posted March 6, 2014 Share Posted March 6, 2014 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. Link to comment
RenanPG Posted March 6, 2014 Author Share Posted March 6, 2014 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. Link to comment
Jacobob14 Posted March 6, 2014 Share Posted March 6, 2014 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 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now