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 ?
(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.