Untitled

mail@pastecode.io avatar
unknown
lua
15 days ago
1.8 kB
5
Indexable
Never
    function DrawEntityBoundingBox(entity, r, g, b, a)
        local min, max = GetModelDimensions(GetEntityModel(entity))
        local corners = {
            GetOffsetFromEntityInWorldCoords(entity, min.x, max.y, max.z),
            GetOffsetFromEntityInWorldCoords(entity, max.x, max.y, max.z),
            GetOffsetFromEntityInWorldCoords(entity, min.x, min.y, max.z),
            GetOffsetFromEntityInWorldCoords(entity, max.x, min.y, max.z),
            GetOffsetFromEntityInWorldCoords(entity, min.x, max.y, min.z),
            GetOffsetFromEntityInWorldCoords(entity, max.x, max.y, min.z),
            GetOffsetFromEntityInWorldCoords(entity, min.x, min.y, min.z),
            GetOffsetFromEntityInWorldCoords(entity, max.x, min.y, min.z)
        }

        local function DrawQuad(v1, v2, v3, v4)
            DrawPoly(v1.x, v1.y, v1.z, v2.x, v2.y, v2.z, v3.x, v3.y, v3.z, r, g, b, a)
            DrawPoly(v1.x, v1.y, v1.z, v3.x, v3.y, v3.z, v4.x, v4.y, v4.z, r, g, b, a)
            DrawPoly(v3.x, v3.y, v3.z, v2.x, v2.y, v2.z, v1.x, v1.y, v1.z, r, g, b, a)
            DrawPoly(v4.x, v4.y, v4.z, v3.x, v3.y, v3.z, v1.x, v1.y, v1.z, r, g, b, a)
        end

        DrawQuad(corners[1], corners[2], corners[4], corners[3])
        DrawQuad(corners[5], corners[6], corners[8], corners[7])
        DrawQuad(corners[1], corners[2], corners[6], corners[5])
        DrawQuad(corners[3], corners[4], corners[8], corners[7])
        DrawQuad(corners[1], corners[3], corners[7], corners[5])
        DrawQuad(corners[2], corners[4], corners[8], corners[6])

        for i = 1, 4 do
            DrawLine(corners[i], corners[(i % 4) + 1], r, g, b, a)
            DrawLine(corners[i + 4], corners[((i - 1) % 4) + 5], r, g, b, a)
            DrawLine(corners[i], corners[i + 4], r, g, b, a)
        end
    end
Leave a Comment