Garry's Mod Wiki

Garry's Mod Wiki

  IMesh:DrawSkinned( table bones, boolean multiply = false )

Recently Added

This was recently added in version (2026.02.25). It might only be available on the Dev Branch right now.

Description

Renders the mesh with the active matrix and given bone matrices.

Arguments

1 sequential table<VMatrix> bones
A list of matrices to use as bones. Up to 52 of them.
2 boolean multiply = false
If set, multiplies given matrices with currently active model matrix (cam.GetModelMatrix). This incurs a performance hit.

Example

Example usage. Draws a dancing cube using skeletal animation at maps 0, 0, 0 position. (gm_construct's spawn)

local mat = Material( "models/debug/debugwhite" ) local ZMin, ZMax = -10, 10 local pos = Vector( 0, 0, 0 ) local function SetPosZ( i ) pos[3] = math.Remap( math.sin( ( CurTime() * 7 ) + ( i / 2 ) ), -1, 1, ZMin, ZMax ) return pos end local s = 50 local v = { Vector( -s, -s, -s ), Vector( s, -s, -s ), Vector( s, s, -s ), Vector( -s, s, -s ), Vector( -s, -s, s ), Vector( s, -s, s ), Vector( s, s, s ), Vector( -s, s, s ), } local tris = { {1, 2, 3}, {1, 3, 4}, {5, 8, 7}, {5, 7, 6}, {1, 5, 6}, {1, 6, 2}, {2, 6, 7}, {2, 7, 3}, {3, 7, 8}, {3, 8, 4}, {4, 8, 5}, {4, 5, 1} } local normals = { Vector( 0, 0,-1 ), Vector( 0, 0,-1 ), Vector( 0, 0, 1 ), Vector( 0, 0, 1 ), Vector( 0,-1, 0 ), Vector( 0,-1, 0 ), Vector( 1, 0, 0 ), Vector( 1, 0, 0 ), Vector( 0, 1, 0 ), Vector( 0, 1, 0 ), Vector( -1, 0, 0 ), Vector( -1, 0, 0 ) } local imesh = Mesh( mat, 2 ) mesh.Begin( imesh, MATERIAL_TRIANGLES, 12 ) for ti, t in ipairs( tris ) do local n = normals[ti] for _, i in ipairs( t ) do mesh.Position( v[i] ) mesh.BoneData( 0, i, 1 ) mesh.BoneData( 1, i, 0 ) mesh.Normal( n ) mesh.Color( 255, 255, 255, 255 ) mesh.AdvanceVertex() end end mesh.End() local boneCount = 8 local boneTable = {} for i = 1, boneCount do boneTable[i] = Matrix() end hook.Add("PostDrawOpaqueRenderables", "Cube", function() -- Update bone matrices for i = 1, boneCount do boneTable[i]:Identity() boneTable[i]:Translate( SetPosZ( i ) ) end -- Setup model lighting render.ResetModelLighting( 0.5, 0.5, 0.5 ) render.SetModelLighting( BOX_FRONT, 1, 1, 1 ) render.SetModelLighting( BOX_LEFT, 1, 0, 0 ) render.SetModelLighting( BOX_RIGHT, 0, 1, 0 ) render.SetModelLighting( BOX_TOP, 0, 0, 1 ) -- Set the render material render.SetMaterial( mat ) -- Draw the mesh with the bone table imesh:DrawSkinned( boneTable ) end)

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...