You can draw a polygon using love.graphics.polygon("line", obj.b:getWorldPoints(obj.s:getPoints())).
But how does one go about mapping a texture to the world object?
Texture Mapping To Collision Detection Objects?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- jordan4ibanez
- Prole
- Posts: 24
- Joined: Sun Dec 30, 2012 7:22 pm
Texture Mapping To Collision Detection Objects?
Check out my Github: https://github.com/jordan4ibanez/
It's a dumpster
It's a dumpster
- jojomickymack
- Prole
- Posts: 45
- Joined: Tue Dec 26, 2017 4:52 pm
Re: Texture Mapping To Collision Detection Objects?
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.
then you've got to create a mesh using the same vertices. I created this function to load them in
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!
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)
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
Nonetheless, there's a mesh with texture updated by a physics shape!
- Attachments
-
- polygon001.love
- (149.05 KiB) Downloaded 136 times
Who is online
Users browsing this forum: No registered users and 194 guests