ENTITY/Draw

From Garry's Mod
Jump to: navigation, search
 ENTITY:Draw( )

Contents

Description

Called if and when the entity should be drawn opaquely, based on the Entity:GetRenderGroup of the entity.

See ENT structure and RENDERGROUP_ Enums for more information.

See also ENTITY:DrawTranslucent.

Arguments

number flags

The bit flags from STUDIO_ Enums

Examples

Example

Draws the model and makes a rotating text over the entity

function ENT:Draw()
	// Draw the model
	self:DrawModel()

	// The text to display
	local text = "Example Text"

	// The position. We use model bounds to make the text appear just above the model. Customize this to your liking.
	local mins, maxs = self:GetModelBounds()
	local pos = self:GetPos() + Vector( 0, 0, maxs.z + 2 )

	// The angle
	local ang = Angle( 0, SysTime() * 100 % 360, 90 )

	// Draw front
	cam.Start3D2D( pos, ang, 0.2 )
		// Actually draw the text. Customize this to your liking.
		draw.DrawText( text, "Default", 0, 0, Color( 0, 255, 0, 255 ), TEXT_ALIGN_CENTER )
	cam.End3D2D()

	// Flip the angle 180 degress around the UP axis
	ang:RotateAroundAxis( Vector( 0, 0, 1 ), 180 )

	// Draw back
	cam.Start3D2D( pos, ang, 0.2 )
		// Actually draw the text. Customize this to your liking.
		draw.DrawText( text, "Default", 0, 0, Color( 0, 255, 0, 255 ), TEXT_ALIGN_CENTER )
	cam.End3D2D()
end


Personal tools
Navigation