Constants for functional shape tables used with b2d.body.create_fixture
and returned from b2d.fixture.get_shape.
Version: alpha
| FUNCTIONS | |
|---|---|
| b2d.shape.get_shape() | Get a shape's geometry. |
| b2d.shape.set_shape() | Set a shape's geometry. |
| CONSTANTS | |
|---|---|
| b2d.shape.SHAPE_TYPE_BOX | Box shape type alias. |
| b2d.shape.SHAPE_TYPE_BOX | Box shape type alias. |
| b2d.shape.SHAPE_TYPE_CAPSULE | Capsule shape type. |
| b2d.shape.SHAPE_TYPE_CHAIN | Chain shape type. |
| b2d.shape.SHAPE_TYPE_CIRCLE | Circle shape type. |
| b2d.shape.SHAPE_TYPE_CIRCLE | Circle shape type. |
| b2d.shape.SHAPE_TYPE_EDGE | Edge shape type. |
| b2d.shape.SHAPE_TYPE_EDGE | Edge shape type. |
| b2d.shape.SHAPE_TYPE_GRID | Grid shape type. |
| b2d.shape.SHAPE_TYPE_POLYGON | Polygon shape type. |
| b2d.shape.SHAPE_TYPE_POLYGON | Polygon shape type. |
b2d.shape.get_shape(body,shape_index)
Get a shape's geometry.
PARAMETERS
body |
b2Body |
body |
shape_index |
number |
1-based shape index from b2d.body.get_shapes |
RETURNS
shape |
table |
shape table with numeric type from b2d.shape.SHAPE_TYPE_* |
b2d.shape.set_shape(body,shape_index,shape,update_mass)
This updates the shape geometry using the same table format as
b2d.body.create_shape and b2d.shape.get_shape. The body mass is not
updated unless update_mass is true.
PARAMETERS
body |
b2Body |
body |
shape_index |
number |
1-based shape index from b2d.body.get_shapes |
shape |
table |
shape table with numeric type from b2d.shape.SHAPE_TYPE_* |
update_mass |
boolean |
true to reset body mass from shapes |
EXAMPLES
local body = b2d.get_body("#collisionobject")
-- Move a circle shape relative to the body origin.
local circle = b2d.shape.get_shape(body, 1)
circle.center = vmath.vector3(24, 0, 0)
b2d.shape.set_shape(body, 1, circle, true)
-- Replace an edge shape's local endpoints.
b2d.shape.set_shape(body, 2, {
type = b2d.shape.SHAPE_TYPE_EDGE,
v1 = vmath.vector3(-32, 0, 0),
v2 = vmath.vector3( 32, 0, 0),
})
-- Update a box shape using the polygon box convenience format.
b2d.shape.set_shape(body, 3, {
type = b2d.shape.SHAPE_TYPE_BOX,
hx = 16,
hy = 8,
center = vmath.vector3(0, 20, 0),
angle = math.rad(30),
}, true)
Uses the polygon enum value, but indicates the hx/hy box convenience format.
Uses the polygon enum value, but indicates the hx/hy box convenience format.