Garry's Mod Wiki

Garry's Mod Wiki

  number render.ComputePixelDiameterOfSphere( Vector point, number radius )

Description

Calculates diameter of a 3D sphere on a 2D screen.

This is a rendering function that requires a 3d rendering context.

This means that it will only work in 3d Rendering Hooks.

Arguments

1 Vector point
The position of the sphere in 3D space.
2 number radius
The radius of the sphere in 3D space.

Returns

1 number
The diameter of the sphere in 2D screen space.

Example

hook.Add( "HUDPaint", "HUDPaint_PixelDiameterOfSphereExample", function() local point = Vector( 0, 0, 0 ) cam.Start3D() local diameter = render.ComputePixelDiameterOfSphere( point, 10 ) cam.End3D() local pos2D = point:ToScreen() surface.DrawCircle( pos2D.x, pos2D.y, diameter / 2, Color( 255, 120, 0 ) ) end )

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated twice a day. Edits and history are not available.

Last Parsed: Loading...