Namespace: b2d.chain
Language: Lua
Type: Defold Lua
File: script_box2d_chain_v3.cpp
Source: engine/gamesys/src/gamesys/scripts/box2d/v3/script_box2d_chain_v3.cpp
Functions for Box2D v3 chains. A chain owns multiple connected segment
shapes, so it is represented by a separate b2Chain handle.
Type: TYPEDEF 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.
Parameters
value (userdata) - Box2D chain handleExamples
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))
Type: FUNCTION 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) - chainType: FUNCTION 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_indexReturns
chain (b2Chain |
nil) - parent chain, or nil if the shape is not a chain segment |
Type: FUNCTION Get chain friction.
Parameters
chain (b2Chain) - chainReturns
friction (number) - chain frictionType: FUNCTION Get the chain geometry.
Parameters
chain (b2Chain) - chainReturns
geometry (b2d.chain_geometry) - chain geometryType: FUNCTION Get chain material id.
Parameters
chain (b2Chain) - chainReturns
material (integer) - chain material idType: FUNCTION Get chain restitution.
Parameters
chain (b2Chain) - chainReturns
restitution (number) - chain restitutionType: FUNCTION Get the number of segment shapes in a chain.
Parameters
chain (b2Chain) - chainReturns
count (integer) - segment countType: FUNCTION Get the segment shapes owned by a chain.
Parameters
chain (b2Chain) - chainReturns
segments (b2d.shape_info[]) - chain segment shapesType: FUNCTION Get the world owning a chain.
Parameters
chain (b2Chain) - chainReturns
world (b2World) - owning worldType: FUNCTION Validate a chain handle.
Parameters
chain (b2Chain) - chainReturns
valid (boolean) - true if the chain handle still refers to a live Box2D chainType: FUNCTION Set chain friction.
Parameters
chain (b2Chain) - chainfriction (number) - chain frictionType: FUNCTION Set chain material id.
Parameters
chain (b2Chain) - chainmaterial (integer) - chain material idType: FUNCTION Set chain restitution.
Parameters
chain (b2Chain) - chainrestitution (number) - chain restitution