Inside out shape

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
kae
Prole
Posts: 2
Joined: Thu Oct 13, 2011 2:43 pm

Inside out shape

Post by kae » Thu Oct 13, 2011 2:48 pm

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.

User avatar
adrix89
Party member
Posts: 135
Joined: Fri Oct 15, 2010 10:58 am

Re: Inside out shape

Post by adrix89 » Thu Oct 13, 2011 3:35 pm

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.
I use Workflowy but you can check out Dynalist as its the better offer.

User avatar
slime
Solid Snayke
Posts: 2887
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Inside out shape

Post by slime » Thu Oct 13, 2011 3:44 pm

You generally make concave shapes by using multiple convex ones attached to the same body.

User avatar
ivan
Party member
Posts: 1561
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Inside out shape

Post by ivan » Thu Oct 13, 2011 5:12 pm

Small balls inside one big one (like a lottery ball). Circle shape is obviously not working
Are you aware that a body can have multiple 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?
By default, Box2D only supports (counter-clockwise) convex shapes.
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.
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".

User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Inside out shape

Post by TechnoCat » Thu Oct 13, 2011 5:35 pm

ivan 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".
https://github.com/vrld/HardonCollider/ ... n.lua#L300
vrld's Hardon Collider does concave shapes. (by splitting them into convex shapes with triangulation)

User avatar
The Burrito
Party member
Posts: 153
Joined: Mon Sep 21, 2009 12:14 am
Contact:

Re: Inside out shape

Post by The Burrito » Thu Oct 13, 2011 5:57 pm

kae wrote:Small balls inside one big one (like a lottery ball).
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.

User avatar
bmelts
Party member
Posts: 380
Joined: Fri Jan 30, 2009 3:16 am
Location: Wiscönsin
Contact:

Re: Inside out shape

Post by bmelts » Thu Oct 13, 2011 11:33 pm

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.

kae
Prole
Posts: 2
Joined: Thu Oct 13, 2011 2:43 pm

Re: Inside out shape

Post by kae » Fri Oct 14, 2011 8:36 am

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 :)

Post Reply

Who is online

Users browsing this forum: DoctorEnder and 17 guests