Jump to content

Drawing bounding box around objects


megaman54

Recommended Posts

How can i draw a bounding box around all objects that are currently streamed in?

I tried with this code but it doesnt draw anything and i dont know why

function render() 
    for i,v in ipairs(getElementsByType("object", root, true))do 
        local x,y,z = getElementPosition(v) 
        local mix,miy,miz,max,may,maz = getElementBoundingBox(v) 
        local x1,y1 = getScreenFromWorldPosition(mix+x,miy+y,miz+z) 
        local x2,y2 = getScreenFromWorldPosition(max+x,may+y,maz+z) 
        dxDrawLine(x1,y1,x2,y2,tocolor(255,0,0,255)) 
    end 
end 
addEventHandler("onClientRender", root, render) 

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