render.DrawQuadEasy

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

Contents

Description

Draws a quad.

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

Origin of the sprite.

Arguments

Vector normal

The face direction of the quad.

Arguments

number width

The width of the quad.

Arguments

number height

The height of the quad.

Arguments

table color

The color of the quad. Uses the Color structure.

Arguments

number rotation=0

The rotation of the quad counter-clockwise in degrees around the normal axis. In other words, the quad will always face the same way but this will rotate its corners.

Examples

Example

Example usage of this function.

local mat = Material( "sprites/sent_ball" )
local mat2 = Material( "models/wireframe" )
hook.Add("PostDrawTranslucentRenderables", "DrawQuadEasyExample", function()

	-- Draw a rotating circle under local player
	render.SetMaterial( mat )
	local pos = LocalPlayer():GetPos()
	render.DrawQuadEasy( pos + Vector( 0, 0, 1 ), Vector( 0, 0, 1 ), 64, 64, Color( 255, 255, 255, 200 ), ( CurTime() * 50 ) % 360 )

	-- Draw 3 rotating wireframe quads where local player is looking at
	render.SetMaterial( mat2 )
	local tr = LocalPlayer():GetEyeTrace()
	render.DrawQuadEasy( tr.HitPos + tr.HitNormal, tr.HitNormal, 64, 64, Color( 255, 255, 255 ), ( CurTime() * 50 ) % 360 )

	local dir = tr.HitNormal:Angle()
	dir:RotateAroundAxis( tr.HitNormal, ( CurTime() * 50 ) % 360 )
	dir = dir:Up()

	-- We need to call this function twice, once for each side
	render.DrawQuadEasy( tr.HitPos + tr.HitNormal * 32, dir, 64, 64, Color( 255, 255, 255 ), 0 )
	render.DrawQuadEasy( tr.HitPos + tr.HitNormal * 32, -dir, 64, 64, Color( 255, 255, 255 ), 0 )
end )


Personal tools
Navigation