util.PixelVisible

From Garry's Mod
Jump to: navigation, search
 util.PixelVisible( )

Contents

Description

Returns the visibility of a sphere in the world.

Arguments

Vector position

The center of the visibility test.

Arguments

number radius

The radius of the sphere to check for visibility.

Arguments

pixelvis handle t PixVis

The PixVis handle created with util.GetPixelVisibleHandle.

WARNING

Don't use the same handle twice per tick or it will give unpredictable results.

Returns

number

Visibility, ranges from 0-1. 0 when none of the area is visible, 1 when all of it is visible.

Examples

Example

Draws a box when the center of the map is visible on your screen.

local PixVis
function SetupPixVis()
	PixVis = util.GetPixelVisibleHandle()
end
hook.Add("Initialize", "SetupPixVis", SetupPixVis)
 
function TestPixelVisibility()
	local visible = util.PixelVisible(Vector(0, 0, 0), 16, PixVis)
 
	if visible && visible != 0 then
		draw.RoundedBox( 10, 0, 0, 100, 100, Color(0, 0, 0, 200 * visible) )
	end
end
hook.Add("HUDPaint", "TestPixelVisibility", TestPixelVisibility)


Personal tools
Navigation