Functions for Box2D v3 chains. A chain owns multiple connected segment
shapes, so it is represented by a separate b2Chain handle.
Version: alpha
| TYPES | |
|---|---|
| b2Chain | Box2D chain |
| FUNCTIONS | |
|---|---|
| b2d.chain.destroy() | Destroy a chain. |
| b2d.chain.from_shape() | Get the parent chain for a chain segment shape. |
| b2d.chain.get_friction() | Get chain friction. |
| b2d.chain.get_geometry() | Get the chain geometry. |
| b2d.chain.get_material() | Get chain material id. |
| b2d.chain.get_restitution() | Get chain restitution. |
| b2d.chain.get_segment_count() | Get the number of segment shapes in a chain. |
| b2d.chain.get_segments() | Get the segment shapes owned by a chain. |
| b2d.chain.get_world() | Get the world owning a chain. |
| b2d.chain.is_valid() | Validate a chain handle. |
| b2d.chain.set_friction() | Set chain friction. |
| b2d.chain.set_material() | Set chain material id. |
| b2d.chain.set_restitution() | Set chain restitution. |
b2Chain = userdata
An opaque handle to a chain of connected segment shapes attached to a
b2Body. Create one with b2d.body.create_chain, use the functions
in b2d.chain to inspect or configure it, and release it with
b2d.chain.destroy. Destroying its body also destroys the chain.
EXAMPLES
local body = b2d.get_body("#collisionobject")
local chain = b2d.body.create_chain(body, {
vertices = {
vmath.vector3(-64, 0, 0),
vmath.vector3(0, 16, 0),
vmath.vector3(64, 0, 0),
},
})
print(b2d.chain.get_segment_count(chain))
b2d.chain.destroy(chain:b2Chain)
Destroying a chain removes all segment shapes owned by the chain. Destroying
any segment shape through b2d.body.destroy_shape also destroys its parent chain.
PARAMETERS
chain |
b2Chain |
chain |
b2d.chain.from_shape(shape_id:b2Shape)→chain:b2Chain|nil
Returns nil if the shape is not a chain segment.
PARAMETERS
shape_id |
b2Shape |
shape handle from a shape info table, or pass body, shape_index
|
RETURNS
chain |
b2Chainnil |
parent chain, or nil if the shape is not a chain segment
|
b2d.chain.get_friction(chain:b2Chain)→friction:number
Get chain friction.
PARAMETERS
chain |
b2Chain |
chain |
RETURNS
friction |
number |
chain friction |
b2d.chain.get_geometry(chain:b2Chain)→geometry:b2d.chain_geometry
Get the chain geometry.
PARAMETERS
chain |
b2Chain |
chain |
RETURNS
geometry |
b2d.chain_geometry |
chain geometry |
b2d.chain.get_material(chain:b2Chain)→material:integer
Get chain material id.
PARAMETERS
chain |
b2Chain |
chain |
RETURNS
material |
integer |
chain material id |
b2d.chain.get_restitution(chain:b2Chain)→restitution:number
Get chain restitution.
PARAMETERS
chain |
b2Chain |
chain |
RETURNS
restitution |
number |
chain restitution |
b2d.chain.get_segment_count(chain:b2Chain)→count:integer
Get the number of segment shapes in a chain.
PARAMETERS
chain |
b2Chain |
chain |
RETURNS
count |
integer |
segment count |
b2d.chain.get_segments(chain:b2Chain)→segments:b2d.shape_info[]
Get the segment shapes owned by a chain.
PARAMETERS
chain |
b2Chain |
chain |
RETURNS
segments |
b2d.shape_info[] |
chain segment shapes |
b2d.chain.get_world(chain:b2Chain)→world:b2World
Get the world owning a chain.
PARAMETERS
chain |
b2Chain |
chain |
RETURNS
world |
b2World |
owning world |
b2d.chain.is_valid(chain:b2Chain)→valid:boolean
Validate a chain handle.
PARAMETERS
chain |
b2Chain |
chain |
RETURNS
valid |
boolean |
true if the chain handle still refers to a live Box2D chain |
b2d.chain.set_friction(chain:b2Chain, friction:number)
Set chain friction.
PARAMETERS
chain |
b2Chain |
chain |
friction |
number |
chain friction |
b2d.chain.set_material(chain:b2Chain, material:integer)
Set chain material id.
PARAMETERS
chain |
b2Chain |
chain |
material |
integer |
chain material id |
b2d.chain.set_restitution(chain:b2Chain, restitution:number)
Set chain restitution.
PARAMETERS
chain |
b2Chain |
chain |
restitution |
number |
chain restitution |