render.AddBeam

From GMod Wiki

Jump to: navigation, search
Function
Syntax render.AddBeam( Vector point, Number width, Number texture coordinate, Color color )
Where is this used?
Description:
Adds a point to a multi segment beam.
Returns: nil
Part of Library: render
Realm: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Render.AddBeam]Render.AddBeam [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionDraws a multi segment beam.
Used onNewerClient.png
Code
 
// setup our variables
local start_pos = Vector();
local end_pos = VectorRand() * 1024;
local dir = ( end_pos - start_pos );
local increment = dir:Length() / 12;
dir:Normalize();
 
// set material
render.SetMaterial( laser );
 
// start the beam with 14 points
render.StartBeam( 14 );
 
// add start
render.AddBeam(
	start_pos,				// Start position
	32,					// Width
	CurTime(),				// Texture coordinate
	Color( 64, 255, 64, 255 )		// Color
);
 
//
local i;
for i = 1, 12 do
	// get point
	local point = ( start_pos + dir * ( i * increment ) ) + VectorRand() * math.random( 1, 16 );
 
	// texture coords
	local tcoord = CurTime() + ( 1 / 12 ) * i;
 
	// add point
	render.AddBeam(
		point,
		32,
		tcoord,
		Color( 64, 255, 64, 255 )
	);
 
end
 
// add the last point
render.AddBeam(
	end_pos,
	32,
	CurTime() + 1,
	Color( 64, 255, 64, 255 )
);
 
// finish up the beam
render.EndBeam();
 
 
 
Outputnone


See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox