I have searched the forums (and read the wiki) and applied origin offset to drawing images matching physics polygon shapes as such:
Code: Select all
-- base_fixture is my fixture to draw
local x, y = objects.getCentroid({base_fixture:getBody():getWorldPoints(base_fixture:getShape():getPoints())})
local offset_x = base_fixture:getUserData().image[1]:getWidth() / 2
local offset_y = base_fixture:getUserData().image[1]:getHeight() / 2
local scale = 0.05
love.graphics.setColor(love.math.colorFromBytes(255, 255, 255))
love.graphics.draw(base_fixture:getUserData().image[1], x, y, base_fixture:getBody():getAngle(), scale, scale, offset_x, offset_y)
See the attached image - polygon shaped is filled with red color, image is drawn over it and positions do not match. If I change the scale, the mismatch also seem to change.