Created
June 23, 2016 19:48
-
-
Save TannerRogalsky/48e3fc0d4804bbb5842fe80aa1c1f8ca to your computer and use it in GitHub Desktop.
Generate a circular mesh.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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