Mesh
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
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 )