draw a box around an entity using it's OBBMax/Mins

derp, can anyone give me a hand here?

I just want to draw a green box around the entity, representing it’s OBB maxs and mins but for the life of me I can’t remember how to use surface.DrawLine.

Also, 3d2d cam or just 3d?

Here’s how surface.DrawLine() works:


hook.Add(“HUDPaint”, “DrawLinesAndShit”, function() – Hook to draw HUD elements with
local startpos = YOUR_VECTOR_HERE:ToScreen() – Define the start position, ToScreen() IS REQUIRED!
local endpos = YOUR_VECTOR_HERE:ToScreen() – Obviously replace the “YOUR_VECTOR_HERE” with a vector
local surface_color = Color(0,255,0,255) – Define what color you want the line to be
surface.SetDrawColor(surface_color) – Actually set the color
surface.DrawLine(startpos.x, startpos.y, endpos.x, endpos.y) – Draw your line
end) – end dis shit, yo


Hope I could help… I like helping…

[editline]19th May 2012[/editline]

I’m gonna make you a better one… since I have nothing better to do…

[editline]19th May 2012[/editline]

hook.Add(“HUDPaint”, “DrawOBBBox”, function()
for k, v in pairs(ents.FindByClass(“npc_*”)) do
local min, max = v:LocalToWorld(v:OBBMins()):ToScreen(), v:LocalToWorld(v:OBBMaxs()):ToScreen()
local draw_color = Color(0,255,0,255)

    surface.DrawLine(min.x, min.y, min.x, max.y)
    surface.DrawLine(max.x, min.y, max.x, max.y)
    surface.DrawLine(min.x, max.y, max.x, max.y)
    surface.DrawLine(min.x, min.y, max.x, min.y)


That will draw a box around all NPCs

Thank you!

Now I need to go bang my head against the wall until I can remember things like this again.