Returns the draw mode, material, and vertex range of a mesh in the model.
Arguments
Name
Type
Description
node
number
The index of the node.
index
number
The index of the draw.
Returns
Name
Type
Description
mode
MeshMode
Whether the vertices are points, lines, or triangles.
material
Material
The Material used by the draw.
start
number
The offset of the first vertex in the draw.
count
number
The number of vertices in the draw.
base
number
The base vertex of the draw (added to each instance value), or nil if the draw does not use an index buffer.
Arguments
Name
Type
Description
name
string
The name of the node.
index
number
The index of the draw.
Returns
Name
Type
Description
mode
MeshMode
Whether the vertices are points, lines, or triangles.
material
Material
The Material used by the draw.
start
number
The offset of the first vertex in the draw.
count
number
The number of vertices in the draw.
base
number
The base vertex of the draw (added to each instance value), or nil if the draw does not use an index buffer.
Example
function lovr.load()
local m = lovr.graphics.newModel('enraged-gorilla.gltf')
model = {
object = m,
data = m:getData(),
vertices = m:getVertexBuffer(),
indices = m:getIndexBuffer()
}
end
local function drawNode(model, pass, i)
for j = 1, model.object:getNodeDrawCount(i) do
local mode, material, start, count, base = model.object:getNodeDraw(i, j)
local transform = mat4(model.object:getNodeTransform(i))
pass:setMeshMode(mode)
pass:setMaterial(material)
if base then
pass:mesh(model.vertices, model.indices, transform, start, count, 1, base)
else
pass:mesh(model.vertices, transform, start, count)
end
end
for _, index in ipairs(model.data:getNodeChildren(i)) do
drawNode(model, pass, index)
end
end
function lovr.draw(pass)
drawNode(model, pass, model.data:getRootNode())
end