3D rectangle with an outline
This snippet was created and submitted by gl0ck.
Description
Draws a rectangle in 3D space with an outline.
posis a vector of world coordinateswis the width of the rectanglehis the height of the rectanglerrepresents the red value between0and255grepresents the green value between0and255brepresents the blue value between0and255arepresents the alpha value between0and255
Code
renderer.rectangle_outline_3d = function(pos, w, h, r, g, b, a)
local old = {}
for rot = 0, 360, 90 do
local rad_rot = math.rad(rot)
local cos_rot = math.cos(rad_rot)
local sin_rot = math.sin(rad_rot)
local line = vector(w * cos_rot + pos.x, h * sin_rot + pos.y, pos.z)
local w2s = { renderer.world_to_screen(line.x, line.y, line.z) }
if w2s[1] and old[1] then
for i = 1, 1 do
local i = i - 1
renderer.line(w2s[1], w2s[2] - i, old[1], old[2] - i, r, g, b, a)
end
end
old = { w2s[1], w2s[2] }
end
end