Jump to content

[HELP]3D Perspective dxDraw when cursor moves in screen


Recommended Posts

Hello everybody.

I saw a video on YouTube a new MTA server comes names called "Drift Paradise".

I see their

and I got eyegasm.

I want to code myself this panel but I don't how to start how to build this code up how to achieve it.

(SORRY FOR MY "not good at all" ENGLISH :( )

Someone could help me to see how it should be made it?

I think need to use:

GetCursorPosition() 
dxDrawRectangle() 
dxDrawText() 

I would really appreciate if someone would help me... :)

Here is the video if you not found the link in the TEXT:

Link to comment
  • 1 month later...

First thing to do is to create a texture shader. Just a simple one which will store your interface (dxCreateShader).

Then, you should make a render target (dxCreateRenderTarget) and draw all your interface in it (dxSetRenderTarget)

After that, calculations come in. Your 0;0 position is mid-screen. Specify how hard you want to rotate the shader: like -15 to 15 degrees. Do some math for degrees calculation:

local ox,oy = 0,0 -- We will use it for current offset
	local mx,my = 15,15 -- 15 degrees for x and y position
	local rt = dxCreateRenderTarget(sx,sy,true) --replace sx,sy with the size of the box
	local shader = dxCreateShader(shaderfile) -- replace shaderfile with path to your texture shader
	function updateRotation()
	  dxSetRenderTarget(rt)
	  -- Draw your interface here
	  dxSetRenderTarget()
	  dxSetShaderValue(shader,"texture",rt) -- Pass the render target to the shader
	  local px,py = getCursorPosition()
	  ox,oy = (px-0.5)*mx,(py-0.5)*my -- mid screen (0.5) will make 0 for ox,oy values. Others are relative
	  dxSetShaderTransform(shader,ox,oy) -- Here goes your main magic
	  -- And just draw your shader mid-screen here with dxDrawImage
	end
	addEventHandler("onClientRender",root,updateRotation) -- We wanna do it each frame, right?

  • Like 1
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...