An empty container based on a shape

Hello there,

I just got started with box2D.
I want to know if it's possible to create a sphere container, in which I can put other objects that will reacts to the bounds of this container (like the walls in the examples).

I don't really know where to look at, any example would be awesome!

Thank you 🙂
You can make a circular container out of a bunch of polygons (rectangles or triangles). You can use a for loop to do the correct position and angles so you don't have to make each thing by hand.
All right that's what I thought ... do you know if somehow it's possible to do it only with one shape ?
Dermiste wrote:All right that's what I thought ... do you know if somehow it's possible to do it only with one shape ?

In the current release state of Box2D AS3 2.1a, unfortunately not, and the hidden-and-non-working way does not technically create one shape either. Here's a post about it with one of the developers of the AS3 port: viewtopic.php?f=8&t=4651

There are b2EdgeShapes (which are infinitely thin lines that stuff can collide with), but they can only be static. You only have to specify the ends as vertices, so you don't have to worry about angles and sizes of polygons. I'm not sure if b2EdgeShapes work in 2.1a because I've never used them.

In the old Box2D version (2.0.x), you can use b2EdgeChainDef to make a bunch of b2EdgeShapes, but it can only be static (cannot move). The b2EdgeChainDef does not work with 2.1a simply because it's old code that's carried over from 2.0.x and Box2D 2.1 does not use shape definitions.
(I don't know about the Flash port, but in C++....)
Although edge shapes don't collide with each other, there is no reason that edge shapes can't be put on a dynamic body. With only edge shapes the body will have no density and therefore will not rotate naturally, but that can be fixed by adding a non-edge shape (circle or polygon) dummy fixture to get the mass data calculated correctly. You could make the dummy fixture a sensor so it doesn't interfere with anything, or if you really don't want any dummy fixtures you could set the mass data explicitly yourself. Probably the easiest way to do that is first add fixture(s) to get the mass and inertia how you want it, copy the mass data, then remove the fixtures and set the mass data that you copied. Adding or removing fixtures after this will mess up your custom mass data, so if you want to change it later on you'll have to reset the mass data again.

Original thread: https://box2d.org/forum/viewtopic.php?t=8626