[SOLVED] Repeat texture in circle mesh (uv calculation)
Posted: Thu Nov 17, 2022 1:10 pm
Hello lovers !
I need help on how to repeat a texture in a circle mesh.
I already have a function that fills a circular mesh with a texture, here it is:
It gives me something like this:
But I would rather have something like this:
How can I do ?
I am attaching a demo with all the resources you need if you want to try it.
I need help on how to repeat a texture in a circle mesh.
I already have a function that fills a circular mesh with a texture, here it is:
Code: Select all
local createCricleMesh = function(image, r)
local cos, sin, pi = math.cos, math.sin, math.pi
local d = 2*r
local segments = math.round(pi/math.acos(1-.33/r))
local vertices = {{0, 0, 0.5, 0.5}}
for i=0, segments do
local angle = (i / segments) * pi * 2
local x = cos(angle) * r
local y = sin(angle) * r
local u = 0.5 + x / d
local v = 0.5 + y / d
vertices[#vertices+1] = {x, y, u, v}
end
local mesh = love.graphics.newMesh(vertices, "fan")
mesh:setTexture(image)
return mesh
end
But I would rather have something like this:
How can I do ?
I am attaching a demo with all the resources you need if you want to try it.