A newer version of Max is available. Click here to access the latest version of the Max documentation

jit.phys.multiple

Uses matrices to simulate multiple rigid bodies

Description

The jit.phys.multiple object uses several jit.matrix objects to simulate rigid bodies in a physics world. The two outlets connect to the position and rotate matrix inputs of a jit.gl.multiple object allowing for easy visualization of the rigid body shapes.

Examples

Uses matrices to simulate multiple rigid bodies

Discussion

Settable parameters include position, rotation, rotatexyz, scale, mass, friction, restitution, damping, force, torque, and mesh. All parameters take float32 matrices. Parameter matrices can be of differing dim sizes, and will wrap to the dimensions of the matrix specified by the dimparam attribute (except for mesh).

Attributes

constraint [symbol]

Specifies a constraint type to be used for the internal constraint matrix (default=none). When set, constraints are automatically created halfway between each rigid body and its nearest neighbor, along each dimension of the position matrix.

Possible values:

'point2point'
'hinge'
'barslide'
'conetwist'
'6dof'

constraint_matrix [int]

Enable reporting of constraint positions as a jit_matrix (default = 0)

constraintoutname [symbol]

Constraint output matrix name

damping [2 floats]

Set the linear and angular damping applied to a body in the range 0. to 1. (default 0.2 0.2). Damping can be used to simulate air resistance.

enable [int]

Enable bodies in the physics simulation (default = 1).

enable_sleep [int]

Enable sleeping on all bodies, causing deactivation when linear and angular velocity are 0 (default = 0).

filterclass [symbol]

Set the name of this object's collision filter-class (default = default). Other objects must specify the filterclass name in their filters list to enable collisions with this object. Maximum allowed unique names is 10.

filters [10 symbols]

Specify a list of filterclass names to enable collisions with (default = all). Possible values include all , worldbox , and default . Additional values include any user-specified filterclass names (maximum allowed = 10).

force [3 floats]

Apply a force to the rigid bodies using a 3D worldspace vector (default = 0 0 0). If forces_relative is enabled, the vector is converted to object space.

forces_relative [int]

Forces relative flag will cause all forces to be converted to object space before applying (default = 0).

friction [float]

The friction amount (opposite force) (default = 0.5). Applied when the body is in contact with another body that has friction.

kinematic [int]

Kinematic flag (default = 1). Use this mode to disable dynamics on the bodies, enable collisions, and animate using position and rotate matrices.

local_scaling [int]

Local scaling flag (default = 0). When enabled, the scale attribute will apply a local scaling transform to the collision shape. When disabled, the rigid-body is removed and re-added to the physics world for every scale modification.

mass [float]

Body mass (default = 1.). When set to 0. body dynamics are disabled, however collisions remain active.

name [symbol]

Specifies the name of the instance (default = UID).

physparams [11 symbols]

The list of physics body attributes corresponding to object inlets that are modifiable by passing in a matrix. Valid attributes are position, rotation, rotatexyz, scale, mass, friction, restitution, damping, force, torque, and mesh.

posoutname [symbol]

g/s(get)

Position output matrix name

reduce_hull [int]

Enable automatic vertex reduction when body shape attribute is set to convexhull (default = 1).

restitution [float]

Restitution value, or bounciness (default = 0.1). The proportion of kinetic energy preserved on impact with other rigid bodies.

rolling_friction [float]

The rolling friction amount (opposite force for a rolling object) (default = 0.0). Applied when the body is in contact with another body that has friction.

rotoutname [symbol]

g/s(get)

Rotate output matrix name

shape [symbol]

Collision shape type (default = sphere).

Possible values:

'sphere'
'cube'
'capsule'
'cone'
'cylinder'
'convexhull' ( A convex hull is generated that encloses the vertices specified by the mesh matrix. )
'concave' ( A concave shape is generated allowing for hollows in the shape, from the vertices specified by the mesh matrix. )
'dynamicmesh'

shareshape [int]

Enable collision shape sharing among body instances (default = 0). When enabled, all rigid body instances will have uniform shape scaling, ignoring the scale matrix if present.

torque [3 floats]

Apply a torque (angular force) to the rigid bodies using a 3D worldspace vector (default = 0 0 0).

worldname [symbol]

The name of a jit.phys.world context the rigid bodies are bound to.

Common Box Attributes

annotation [symbol]

Sets the text that will be displayed in the Clue window when the user moves the mouse over the object.

background [int] (default: 0)

Adds or removes the object from the patcher's background layer. background 1 adds the object to the background layer, background 0 removes it. Objects in the background layer are shown behind all objects in the default foreground layer.

color [4 floats]

Sets the color for the object box outline.

fontface [int]

Sets the type style used by the object. The options are:

plain
bold
italic
bold italic

Possible values:

0 = 'regular'
1 = 'bold'
2 = 'italic'
3 = 'bold italic'

fontname [symbol]

Sets the object's font.

fontsize [float]

Sets the object's font size (in points).

Possible values:

'8'
'9'
'10'
'11'
'12'
'13'
'14'
'16'
'18'
'20'
'24'
'30'
'36'
'48'
'64'
'72'

hidden [int] (default: 0)

Toggles whether an object is hidden when the patcher is locked.

hint [symbol]

Sets the text that will be displayed in as a pop-up hint when the user moves the mouse over the object in a locked patcher.

ignoreclick [int] (default: 0)

Toggles whether an object ignores mouse clicks in a locked patcher.

patching_rect [4 floats] (default: 0. 0. 100. 0.)

Sets the position and size of the object in the patcher window.

position [2 floats]

g/s(set)

Sets the object's x and y position in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its size unchanged.

presentation [int] (default: 0)

Sets whether an object belongs to the patcher's presentation.

presentation_rect [4 floats] (default: 0. 0. 0. 0.)

Sets the x and y position and width and height of the object in the patcher's presentation, leaving its patching position unchanged.

rect [4 floats]

g/s(set)

Sets the x and y position and width and height of the object in both patching and presentation modes (if the object belongs to its patcher's presentation).

size [2 floats]

g/s(set)

Sets the object's width and height in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its position unchanged.

textcolor [float]

Sets the color for the object's text in RGBA format.

textjustification [int]

Text Justification

Possible values:

0 = 'left'
1 = 'center'
2 = 'right'

varname [symbol]

Sets the patcher's scripting name, which can be used to address the object by name in pattr, scripting messages to thispatcher, and the js object.

Messages

bang

Update bodies and output matrices

damping_matrix

Arguments

matrix name [symbol]
A named matrix to use for the damping parameter if it's in the physparams list. Must be a 2-plane float32 matrix.

getconstraint_dict

Send a dictionary description of the modified constraint attributes out the dumpout.

force_matrix

Arguments

matrix name [symbol]
A named matrix to use for the force parameter if it's in the physparams list. Must be a 3-plane float32 matrix.

friction_matrix

Arguments

matrix name [symbol]
A named matrix to use for the friction parameter if it's in the physparams list. Must be a 1-plane float32 matrix.

impulse

Arguments

x [float]
y [float]
z [float]
relative-x [float]
relative-y [float]
relative-z [float]
Apply an impulse (instantaneous force) to the rigid bodies using a worldspace vector described by x , y , z . Optional args relative-x , relative-y , relative-z describe a relative position on the body where the force is applied, otherwise it's a central force.

mass_matrix

Arguments

matrix name [symbol]
A named matrix to use for the mass parameter if it's in the physparams list. Must be a 1-plane float32 matrix.

mesh_matrix

Arguments

matrix name [symbol]
A named matrix to use for the mesh parameter if it's in the physparams list. Specifies a matrix of vertex values for determining the rigid-body convex hull or concave mesh. Must be a 3-plane float32 matrix.

position_matrix

Arguments

matrix name [symbol]
A named matrix to use for the position parameter if it's in the physparams list. Must be a 3-plane float32 matrix.

reset

Reset all instance body properties position, and quat, and zero all forces.

sendbody

Arguments

body-name (optional) [symbol]
body-index (optional) [list]
message [symbol]
values [list]
Send a body instance a message. If the first arg is a symbol, it's treated as the body instance name. If it's an integer, a list is expected whose length is equal to the number of dimensions of the position-matrix. Possible messages include all values for the physparams attribute (except mesh ), as well as the impulse and torque_impulse messages.

sendbody_reset

Arguments

body-name (optional) [symbol]
body-index (optional) [list]
message [symbol]
values [list]
Send a body instance a message with a reset message. See the sendbody message for more info.

restitution_matrix

Arguments

matrix name [symbol]
A named matrix to use for the restitution parameter if it's in the physparams list. Must be a 1-plane float32 matrix.

rotate_matrix

Arguments

matrix name [symbol]
A named matrix to use for the rotate parameter if it's in the physparams list. Must be a 4-plane float32 matrix.

rotatexyz_matrix

Arguments

matrix name [symbol]
A named matrix to use for the rotatexyz parameter if it's in the physparams list. Must be a 3-plane float32 matrix.

torque_impulse

Arguments

x [float]
y [float]
z [float]
Apply a torque impulse (instantaneous angular force) to the rigid bodies using a worldspace vector described by x , y , z .

scale_matrix

Arguments

matrix name [symbol]
A named matrix to use for the scale parameter if it's in the physparams list. Must be a 3-plane float32 matrix.

torque_matrix

Arguments

matrix name [symbol]
A named matrix to use for the torque parameter if it's in the physparams list. Must be a 3-plane float32 matrix.

sendconstraint

Send the internal constraints a message

See Also

Name Description
Working with OpenGL Working with OpenGL
jit.phys.world Collision detection and rigid body dynamics
jit.phys.body A rigid body and collision shape
jit.phys.ghost A collision sensor and forcefield
jit.phys.picker Constraint picking in a physics world
jit.gl.physdraw A physics opengl debug drawer
jit.gl.multiple Create multiple object instances
jit.gl.gridshape Generate simple geometric shapes as a grid