mesh.AdvanceVertex

From GMod Wiki

Jump to: navigation, search
Function
Syntax mesh.AdvanceVertex( )
Where is this used?
Description:
For each vertex that you define in your mesh, you must call this function to tell the mesh builder that you're dealing with a new vertex. It must also be called on the last vertex of your mesh.
Returns: nil
Part of Library: mesh
Realm: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Mesh.AdvanceVertex]Mesh.AdvanceVertex [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionDraws a single triangle with one vertex at the entity's origin
Used onNewerClient.png
Code
 
local mat_debugwhite = Material( "models/debug/debugwhite" );
function ENT:Draw()
	self:DrawModel();
 
	local mat = Matrix();
	mat:Translate( self:GetPos() );
	mat:Rotate( self:GetAngles() );
	mat:Scale( Vector( 1, 1, 1 ) * 64 );
 
	render.SetMaterial( mat_debugwhite );
 
	cam.PushModelMatrix( mat );
 
		mesh.Begin( MATERIAL_TRIANGLES, 1 );
		--mesh.Begin( MATERIAL_LINE_LOOP, 3 );
 
			mesh.Position( Vector( 0, 0, 0 ) );
			mesh.Normal( Vector( 0, 0, 1 ) );
			mesh.TexCoord( 0, 0, 0 );
			mesh.Color( 255, 0, 0, 255 );
			mesh.AdvanceVertex();
 
			mesh.Position( Vector( 0, 1, 0 ) );
			mesh.Normal( Vector( 0, 0, 1 ) );
			mesh.TexCoord( 0, 1, 0 );
			mesh.Color( 0, 255, 0, 255 );
			mesh.AdvanceVertex();
 
			mesh.Position( Vector( 0, 0, 1 ) );
			mesh.Normal( Vector( 0, 0, 1 ) );
			mesh.TexCoord( 0, 0, 1 );
			mesh.Color( 0, 0, 255, 255 );
			mesh.AdvanceVertex();
 
		mesh.End();
 
	cam.PopModelMatrix();
end
OutputA triangle that rotates with the entity it is being drawn on.


Additional Notes

CLIENT | 0000000000000000 | 00000000000000000 | MATERIAL_POINTS
CLIENT | 0000000000000001 | 00000000000000001 | MATERIAL_LINES
CLIENT | 0000000000000002 | 00000000000000010 | MATERIAL_TRIANGLES
CLIENT | 0000000000000003 | 00000000000000011 | MATERIAL_TRIANGLE_STRIP
CLIENT | 0000000000000004 | 00000000000000100 | MATERIAL_LINE_STRIP
CLIENT | 0000000000000005 | 00000000000000101 | MATERIAL_LINE_LOOP
CLIENT | 0000000000000006 | 00000000000000110 | MATERIAL_POLYGON
CLIENT | 0000000000000007 | 00000000000000111 | MATERIAL_QUADS
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox