I was able to do this by using a mesh, and updating the mesh vertices by calling getPoints on the shape as an argument to Body:getWorldPoints(). Unfortunately, how the vertices are expected to be set on a mesh doesn't match up with how the points are returned, so I sort of hacked out a solution.
You can attach a polygon shape to a physics world body - there is limit to only 8 vertices and you're expected to attach multiple polygons together to create more interesting shapes.
Code: Select all
objects.triangle.shape = love.physics.newPolygonShape(vertices)
then you've got to create a mesh using the same vertices. I created this function to load them in
Code: Select all
function formatVertices(myVertices)
return {
{myVertices[1], myVertices[2], 0, 0, 255, 255, 255, 255},
{myVertices[3], myVertices[4], 0, 1, 255, 255, 255, 255},
{myVertices[5], myVertices[6], 1, 0, 255, 255, 255, 255}
}
end
given that there's a limit of 8, that's probably not horrible, but I think if you wanted to make a star shape or something it would be a unique challenge.
Nonetheless, there's a mesh with texture updated by a physics shape!
- texture.gif (376.14 KiB) Viewed 2231 times