Garry's Mod Wiki

Mesh

IMesh Mesh( IMaterial mat = nil )

Description

Returns a new mesh object.

Arguments

1 IMaterial mat = nil
The material the mesh is intended to be rendered with. It's merely a hint that tells that mesh what vertex format it should use.

Returns

1 IMesh
The created object.

Example

Draws a triangle near Vector( 0, 0, 0 ) in the map.

local mat = Material( "editor/wireframe" ) -- The material (a wireframe) local obj = Mesh() -- Create the IMesh object local verts = { -- A table of 3 vertices that form a triangle { pos = Vector( 0, 0, 0 ), u = 0, v = 0 }, -- Vertex 1 { pos = Vector( 10, 0, 0 ), u = 1, v = 0 }, -- Vertex 2 { pos = Vector( 10, 10, 0 ), u = 1, v = 1 }, -- Vertex 3 } obj:BuildFromTriangles( verts ) -- Load the vertices into the IMesh object hook.Add( "PostDrawOpaqueRenderables", "IMeshTest", function() render.SetMaterial( mat ) -- Apply the material obj:Draw() -- Draw the mesh end )

Page Links


Special Pages


Wikis

?

Render Time: 36ms

DB GetPage 4
Generate Html 8
SaveChanges (1) 9
Render Body 0
Render Sidebar 12