Garry's Mod Wiki

IMesh:Draw

  IMesh:Draw()

Description

Renders the mesh with the active matrix.

If this function is paired with VertexLitGeneric material, this function will reuse light parameters calculated on previously drawn model unless other are specified using render library (such as render.ResetModelLighting). If you experience lighting issues or you want engine to calculate light for you, draw a dummy (invisible) model in origin of mesh, then draw the mesh.

If utilized inside ENTITY:Draw, drawing entity's model (if it has one) should be enough.

Example

Properly renders the mesh using the SENT's model matrix.

self.Mesh in this case is the IMesh.

local myMaterial = Material( "models/wireframe" ) -- models/debug/debugwhite function ENT:Draw() -- Code containing self:DrawModel() if ( self.Mesh ) then render.SetMaterial( myMaterial ) cam.PushModelMatrix( self:GetWorldTransformMatrix() ) self.Mesh:Draw() cam.PopModelMatrix() end -- Probably other code end