Box2D Concave Polygons?
Posted: Fri Dec 27, 2013 3:53 am
My goal is to make physical concave polygons. As of now I'm just testing triangulation on a convex shape but as of now I am having trouble of how to use the results from the triangulation function.. Would I have to use the returned triangle table to make each individual triangle and then attach them all using Joints? And then having to draw each triangle in the physical world too? Or is there an easier way I hope ?!
Here is some code I have so far..
THANKS!!!
Here is some code I have so far..
Code: Select all
function love.load()
world = love.physics.newWorld(0, 9.81*64, true)
triangles = love.math.triangulate(50, 50, 100, 50, 120, 100, 80, 200)
myshape = love.physics.newPolygonShape( 50, 50, 100, 50, 120, 100, 80, 200)
mybody = love.physics.newBody( world, 50, 50, "dynamic")
myfixture = love.physics.newFixture( mybody, myshape, 1 )
end
function love.update(dt)
world:update(dt)
end
function love.draw()
love.graphics.polygon('fill', mybody:getWorldPoints(myshape:getPoints()))
end