Garry's Mod Wiki

render.DrawSphere

render.DrawSphere( Vector position, number radius, number longitudeSteps, number latitudeSteps, table color = Color( 255, 255, 255 ) )

Description

Draws a sphere in 3D space. The material previously set with render.SetMaterial will be applied the sphere's surface.

See also render.DrawWireframeSphere for a wireframe equivalent.

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 position
Position of the sphere.
2 number radius
Radius of the sphere. Negative radius will make the sphere render inwards rather than outwards.
3 number longitudeSteps
The number of longitude steps. This controls the quality of the sphere. Higher quality will lower performance significantly. 50 is a good number to start with.
4 number latitudeSteps
The number of latitude steps. This controls the quality of the sphere. Higher quality will lower performance significantly. 50 is a good number to start with.
5 table color = Color( 255, 255, 255 )
The color of the sphere. Uses the Color.

Example

This will draw a blue, half-translucent sphere (force field) at the position local player is looking.

hook.Add( "PostDrawTranslucentRenderables", "test", function() --[[ when you draw a sphere, you have to specify what material the sphere is going to have before rendering it, render.SetColorMaterial() just sets it to a white material so we can recolor it easily. --]] render.SetColorMaterial() -- The position to render the sphere at, in this case, the looking position of the local player local pos = LocalPlayer():GetEyeTrace().HitPos -- Draw the sphere! render.DrawSphere( pos, 50, 30, 30, Color( 0, 175, 175, 100 ) ) end )

Page Links


Special Pages


Wikis

?

Render Time: 42ms

DB GetPage 3
Generate Html 16
SaveChanges (1) 9
Render Body 0
Render Sidebar 11