Hi.
I'm trying to make a shape which are solid on the inside. Small balls inside one big one (like a lottery ball). Circle shape is obviously not working. And the polygon shape can only have 8 vertices ? Besides, that wouldn't work either or would it? I've searched around and se people talk about edge shape, but that isnt available to love2d yet or?
Thanks,
kae.
Inside out shape
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Inside out shape
That is because all physics libs choke on concave surfaces.
The only way I see to get it work is to have an array of rectangles in the shape of a circle but I'm not sure if it would stick together properly.
The only way I see to get it work is to have an array of rectangles in the shape of a circle but I'm not sure if it would stick together properly.
- slime
- Solid Snayke
- Posts: 3170
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Inside out shape
You generally make concave shapes by using multiple convex ones attached to the same body.
Re: Inside out shape
Are you aware that a body can have multiple shapes?Small balls inside one big one (like a lottery ball). Circle shape is obviously not working
By default, Box2D only supports (counter-clockwise) convex shapes.kae wrote:And the polygon shape can only have 8 vertices ? Besides, that wouldn't work either or would it? I've searched around and se people talk about edge shape, but that isnt available to love2d yet or?
Hmm, what do you mean by "all physics libs"?adrix89 wrote:That is because all physics libs choke on concave surfaces.
The only way I see to get it work is to have an array of rectangles in the shape of a circle but I'm not sure if it would stick together properly.
As people have mentioned, the way to simulate concave shapes is to decompose them into triangles and attach them to the same body.
This can be done algorithmically using "triangulation".
- TechnoCat
- Inner party member
- Posts: 1612
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: Inside out shape
https://github.com/vrld/HardonCollider/ ... n.lua#L300ivan wrote:Hmm, what do you mean by "all physics libs"?
As people have mentioned, the way to simulate concave shapes is to decompose them into triangles and attach them to the same body.
This can be done algorithmically using "triangulation".
vrld's Hardon Collider does concave shapes. (by splitting them into convex shapes with triangulation)
- The Burrito
- Party member
- Posts: 153
- Joined: Mon Sep 21, 2009 12:14 am
- Contact:
Re: Inside out shape
Like others said the best method is to make a ring of simple shapes with a single body (probably at the center). Then if you want to move the ball in any way you can just apply forces to the body and you can "open" it by deleting or turning off collision on one of the segments. It's not perfect but in most cases 16 or 32 segments should be smooth enough. Just depends on what else you want to do with it.kae wrote:Small balls inside one big one (like a lottery ball).
Re: Inside out shape
In LÖVE 0.8.0, you'll have access to Box2D 2.2.1, which adds ChainShape, which might well be what you're looking for - a series of EdgeShapes. Create a looped ChainShape in a circle (or something approximating it), then have smaller CircleShapes inside. ChainShapes handle collision on both sides, so this should work to keep the smaller shapes trapped inside the larger.
Re: Inside out shape
Thanks for all the input. Seems like triangles is the way to go. Won't be too hard to setup either.
Looking forward to Love 0.8.0. Have been playing with Love2D, and Lua, for only two days now and find it very intuitive and fun to work with. Coming from a C/Obj-C world I've been looking at Lua from distance for a while. Glad I finally took the step
Looking forward to Love 0.8.0. Have been playing with Love2D, and Lua, for only two days now and find it very intuitive and fun to work with. Coming from a C/Obj-C world I've been looking at Lua from distance for a while. Glad I finally took the step
Who is online
Users browsing this forum: Bing [Bot] and 6 guests