Pass:drawPart

Edit

Draws a single mesh or part of a mesh in a Model.

Meshes in models can be split into multiple "parts", where each part has its own draw mode and material. This function can draw a single one of these parts, or all of the parts in a single mesh.

Drawing individual meshes or parts is useful because it allows for materials, graphics states, and shader uniforms to be changed in between each draw.







Draw all of the parts of a mesh.

Arguments

NameTypeDefaultDescription
modelModel The Model to draw.
meshnumber The index of the mesh to draw.
xnumber0 The x coordinate to draw at.
ynumber0 The y coordinate to draw at.
znumber0 The z coordinate to draw at.
scalenumber1 The scale.
anglenumber0 The rotation around the rotation axis, in radians.
axnumber0 The x component of the axis of rotation.
aynumber1 The y component of the axis of rotation.
aznumber0 The z component of the axis of rotation.
instancesnumber1 The number of instances to draw.

Returns

Nothing

Draw all of the parts of a mesh.

Arguments

NameTypeDefaultDescription
modelModel The Model to draw.
meshnumber The index of the mesh to draw.
positionvector The position to draw at.
scale3vector The scale, as a vector.
orientationquaternion The orientation.
instancesnumber1 The number of instances to draw.

Returns

Nothing

Draw all of the parts of a mesh.

Arguments

NameTypeDefaultDescription
modelModel The Model to draw.
meshnumber The index of the mesh to draw.
transformMat4 The transform.
instancesnumber1 The number of instances to draw.

Returns

Nothing

Draw a single part of a mesh.

Arguments

NameTypeDefaultDescription
modelModel The Model to draw.
meshnumber The index of the mesh to draw.
partnumber The index of one of the parts in the mesh to draw.
xnumber0 The x coordinate to draw at.
ynumber0 The y coordinate to draw at.
znumber0 The z coordinate to draw at.
scalenumber1 The scale.
anglenumber0 The rotation around the rotation axis, in radians.
axnumber0 The x component of the axis of rotation.
aynumber1 The y component of the axis of rotation.
aznumber0 The z component of the axis of rotation.
instancesnumber1 The number of instances to draw.

Returns

Nothing

Draw a single part of a mesh.

Arguments

NameTypeDefaultDescription
modelModel The Model to draw.
meshnumber The index of the mesh to draw.
partnumber The index of one of the parts in the mesh to draw.
positionvector The position to draw at.
scale3vector The scale, as a vector.
orientationquaternion The orientation.
instancesnumber1 The number of instances to draw.

Returns

Nothing

Draw a single part of a mesh.

Arguments

NameTypeDefaultDescription
modelModel The Model to draw.
meshnumber The index of the mesh to draw.
partnumber The index of one of the parts in the mesh to draw.
transformMat4 The transform.
instancesnumber1 The number of instances to draw.

Returns

Nothing

Example

function lovr.draw(pass)
  for node, mesh in model:meshes() do
    local x, y, z, scale, _, _, angle, ax, ay, az = model:getNodeTransform(node)

    for part = 1, model:getMeshPartCount(mesh) do
      pass:drawPart(model, mesh, part, x, y, z, scale, angle, ax, ay, az)
    end
  end
end

See also