b2ConcaveArcShape & b2ConvexArcShape Primitives
Originally this was just a small demo, but now I've produced a version of box2dFlash 1.4.3 which includes two new primitives - b2ConcaveArcShape & b2ConvexArcShape. They are not fully implemented but should work well in static objects. Between these and polygons, it is possible to represent any combination of intersections and unions of polygons and circles.
See a demo here:
http://boristhebrave.com/permajunk08/ConcaveArc.html
USAGE
Diagrams to come...
b2ConcaveArcShape
This shape can represent any polygon with a circle subtracted from it. It works exactly the same as b2PolyShape, except the edge from vertex 0 to vertex 1 is a concave arc, with radius given by the radius property. The diameter should be longer than the distance between the vertices, and the rest of the polygonal shape should be large enough to enclose the resulting curve (this is not checked).
b2ConvexArcShape
This shape is intended to represent any circle intersected with a half plane. The circle is as it would be for a b2CircleShape, i.e. centered at localPosition and of radius radius. The half plane is represented by norm, giving the outward normal, and offset, which is the offset of the halfplane's edge from the center of the circle. A zero offset means a semi-circle, with a positive offset being larger than that and a negative one smaller. Note: At the moment, only non-positive offsets are supported. localRotation can be used instead of norm.
Note that not all collisions are supported, specifically the arc shapes cannot collide with each other. This means you will have to structure your worlds such that this never needs to happen, probably by ensuring they are all static.
Future work & bugs:
Latest source available here:
Originally this was just a small demo, but now I've produced a version of box2dFlash 1.4.3 which includes two new primitives - b2ConcaveArcShape & b2ConvexArcShape. They are not fully implemented but should work well in static objects. Between these and polygons, it is possible to represent any combination of intersections and unions of polygons and circles.
See a demo here:
http://boristhebrave.com/permajunk08/ConcaveArc.html
USAGE
Diagrams to come...
b2ConcaveArcShape
This shape can represent any polygon with a circle subtracted from it. It works exactly the same as b2PolyShape, except the edge from vertex 0 to vertex 1 is a concave arc, with radius given by the radius property. The diameter should be longer than the distance between the vertices, and the rest of the polygonal shape should be large enough to enclose the resulting curve (this is not checked).
b2ConvexArcShape
This shape is intended to represent any circle intersected with a half plane. The circle is as it would be for a b2CircleShape, i.e. centered at localPosition and of radius radius. The half plane is represented by norm, giving the outward normal, and offset, which is the offset of the halfplane's edge from the center of the circle. A zero offset means a semi-circle, with a positive offset being larger than that and a negative one smaller. Note: At the moment, only non-positive offsets are supported. localRotation can be used instead of norm.
Note that not all collisions are supported, specifically the arc shapes cannot collide with each other. This means you will have to structure your worlds such that this never needs to happen, probably by ensuring they are all static.
Future work & bugs:
- Check that warm starting is working properly for both shapes.
- Support a positive offset for b2ConvexArcDef
- Implement collisions between convex arcs and another arc.
- Possible port to C++? I have vaguely planned the extra code required for the upgrade to 2.0, but I would be keen on getting some help on board for the rest of the port. My C++ probably isn't up to scratch for making some of the design choices.
Latest source available here: