Garry's Mod Wiki

Revision Difference

render.DrawBox#546286

<function name="DrawBox" parent="render" type="libraryfunc"> <description> Draws a box in 3D space. <rendercontext hook="false" type="3D"></rendercontext> </description> <realm>Client</realm> <args> <arg name="position" type="Vector">Origin of the box.</arg> <arg name="angles" type="Angle">Orientation of the box.</arg> <arg name="mins" type="Vector">Start position of the box, relative to origin.</arg> <arg name="maxs" type="Vector">End position of the box, relative to origin.</arg> <arg name="color" type="table" default="Color( 255, 255, 255 )">The color of the box. Uses the <page>Color</page>.</arg> </args> </function> ⤶ <example>⤶ <description>Draws a white box at the position you are looking.</description>⤶ <code>⤶ local x = Vector(5, 5, 5)⤶ hook.Add("PostDrawTranslucentRenderables", "Boxxie", function()⤶ local pos = LocalPlayer():GetEyeTrace().HitPos -- position to render box at⤶ ⤶ render.SetColorMaterial() -- white material for easy coloring⤶ ⤶ cam.IgnoreZ(true) -- makes next draw calls ignore depth and draw on top⤶ render.DrawBox(pos, Angle(0, 0, 0), x, -x, color_white) -- draws the box ⤶ cam.IgnoreZ(false) -- disables previous call⤶ end)⤶ </code>⤶ ⤶ </example>