Pass:drawPart
EditDraws 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
| Name | Type | Default | Description |
| model | Model | The Model to draw. | |
| mesh | number | The index of the mesh to draw. | |
| x | number | 0 | The x coordinate to draw at. |
| y | number | 0 | The y coordinate to draw at. |
| z | number | 0 | The z coordinate to draw at. |
| scale | number | 1 | The scale. |
| angle | number | 0 | The rotation around the rotation axis, in radians. |
| ax | number | 0 | The x component of the axis of rotation. |
| ay | number | 1 | The y component of the axis of rotation. |
| az | number | 0 | The z component of the axis of rotation. |
| instances | number | 1 | The number of instances to draw. |
Returns
Nothing
Draw all of the parts of a mesh.
Arguments
| Name | Type | Default | Description |
| model | Model | The Model to draw. | |
| mesh | number | The index of the mesh to draw. | |
| position | vector | The position to draw at. | |
| scale3 | vector | The scale, as a vector. | |
| orientation | quaternion | The orientation. | |
| instances | number | 1 | The number of instances to draw. |
Returns
Nothing
Draw all of the parts of a mesh.
Arguments
| Name | Type | Default | Description |
| model | Model | The Model to draw. | |
| mesh | number | The index of the mesh to draw. | |
| transform | Mat4 | The transform. | |
| instances | number | 1 | The number of instances to draw. |
Returns
Nothing
Draw a single part of a mesh.
Arguments
| Name | Type | Default | Description |
| model | Model | The Model to draw. | |
| mesh | number | The index of the mesh to draw. | |
| part | number | The index of one of the parts in the mesh to draw. | |
| x | number | 0 | The x coordinate to draw at. |
| y | number | 0 | The y coordinate to draw at. |
| z | number | 0 | The z coordinate to draw at. |
| scale | number | 1 | The scale. |
| angle | number | 0 | The rotation around the rotation axis, in radians. |
| ax | number | 0 | The x component of the axis of rotation. |
| ay | number | 1 | The y component of the axis of rotation. |
| az | number | 0 | The z component of the axis of rotation. |
| instances | number | 1 | The number of instances to draw. |
Returns
Nothing
Draw a single part of a mesh.
Arguments
| Name | Type | Default | Description |
| model | Model | The Model to draw. | |
| mesh | number | The index of the mesh to draw. | |
| part | number | The index of one of the parts in the mesh to draw. | |
| position | vector | The position to draw at. | |
| scale3 | vector | The scale, as a vector. | |
| orientation | quaternion | The orientation. | |
| instances | number | 1 | The number of instances to draw. |
Returns
Nothing
Draw a single part of a mesh.
Arguments
| Name | Type | Default | Description |
| model | Model | The Model to draw. | |
| mesh | number | The index of the mesh to draw. | |
| part | number | The index of one of the parts in the mesh to draw. | |
| transform | Mat4 | The transform. | |
| instances | number | 1 | 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