render.DrawSphere

From Garry's Mod
Jump to: navigation, search
 render.DrawSphere( )

Contents

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.

NOTE

This is a rendering function that requires a 3D rendering context.
This means that it will only work in hooks with a 3D rendering context.

Arguments

Vector position

Position of the sphere.

Arguments

number radius

Radius of the sphere. Negative radius will make the sphere render inwards rather than outwards.

Arguments

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.

Arguments

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.

Arguments

table color=Color( 255, 255, 255 )

The color of the sphere. Uses the Color structure.

Examples

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 )


Personal tools
Navigation