Skip to content

Instantly share code, notes, and snippets.

@TannerRogalsky
Created June 23, 2016 19:48
Show Gist options
  • Save TannerRogalsky/48e3fc0d4804bbb5842fe80aa1c1f8ca to your computer and use it in GitHub Desktop.
Save TannerRogalsky/48e3fc0d4804bbb5842fe80aa1c1f8ca to your computer and use it in GitHub Desktop.
Generate a circular mesh.
local function genMesh(num_verts, radius)
local verts = {}
local interval = math.pi * 2 / num_verts
for i=1,num_verts do
local phi = i * interval
local x = radius * math.cos(phi)
local y = radius * math.sin(phi)
local u = (x + radius) / (radius * 2)
local v = (y + radius) / (radius * 2)
table.insert(verts, {x, y, u, v})
end
return love.graphics.newMesh(verts)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment