Jump to content

[PLEASE HELP]dxDrawMaterialLine3D and dxDrawText


Recommended Posts

Posted

Anyone help me ?

My code;

local minX = 2

tex = dxCreateTexture("texture.png")

function test3DGUI()
minX = getElementBoundingBox(localPlayer)
x,y,z,lx,ly,lz,x2,y2,z2 = getPositionFromElementOffset(minX-1,0,minX+0.5,1)
dxDrawMaterialLine3D(x2,y2,z2+0.5,x,y,z+0.5, tex, 1, tocolor(0,0,0,150),lx,ly,lz)
dxDrawMaterialLine3D(x2,y2,z2+0.5,x,y,z2+0.32, tex, 1, tocolor(255,0,29,255),lx,ly,lz)
local sx,sy = getScreenFromWorldPosition ( x2,y2,z2, 0 ) 
dxDrawText ( "3D text", sx, sy - 30, sx, sy - 30, tocolor(255,255,255,255), 1, "bankgothic", "center", "bottom", false, false, false ) 
end
addEventHandler("onClientRender", root, test3DGUI)

function getPositionFromElementOffset(offX,offY,offX2,offY2)
	local offZ = -0.5
	local m = getElementMatrix ( localPlayer )
	local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1]  
	local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2]
	local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3]
	
	local x2 = offX2 * m[1][1] + offY2 * m[2][1] + offZ * m[3][1] + m[4][1] 
	local y2 = offX2 * m[1][2] + offY2 * m[2][2] + offZ * m[3][2] + m[4][2]
	local z2 = offX2 * m[1][3] + offY2 * m[2][3] + offZ * m[3][3] + m[4][3]
	
	offZ = 0.5
	local x3 = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] 
	local y3 = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2]
	local z3 = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3]
	
	return x, y, z, x2, y2, z2, x3, y3, z3    
end

 

Posted

Look at this post and edit/add the needed details accordingly

In short, tell us what's not working, any debug errors and steps you tried to solve your problem so far.

  • Like 1
  • Moderators
Posted
11 hours ago, MysticEmpire said:

Up

Your order: spaghetti with marinara sauce + egg noodles and ketchup is not ready yet, I am terrible sorry. I have no clue what you want.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

  • Moderators
Posted

Render both as 2D.

 Then capture them with a render target.

https://wiki.multitheftauto.com/wiki/DxCreateRenderTarget

 

And as last render the rendertarget(image/texture format) in 3D.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

  • Moderators
Posted

There is already an example on wiki, which only require copy past.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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