jit.phys.ghost
A collision sensor and forcefield
Description
The jit.phys.ghost object represents a sensor area defined by a basic collision shape in a physics world. The collision shape is either one of several simple shapes. Additionally a force field can be enabled to act on colliding objects. The direction vector of the force field can be either in world coordinates, or relative to the jit.phys.ghost object.
Attributes
central_exp[float]
Adjust the exponent of the central force scaling curve if central_mode is decrease or increase . The default of 1 gives a linear curve, greater than one exponential, and less than one logarithmic.
central_force[float]
Apply a central force
central_mode[symbol]
Specifies how rigid body distance from center affects the central force when enabled by central_force (default = decrease).
Possible values:
'constant'
(
Distance has no effect on central force
)
'decrease'
(
Central force decreases with distance
)
'increase'
(
Central force increases with distance
)
collision_mode[symbol]
Specifies the format of the collisions dictionary (default = simple)
Possible values:
'simple'
(
Report contact point positions and normals average
)
'complete'
(
All contact point position and normals reported
)
collisions[int]
Enables and disables collision dictionary reporting out the first outlet.
enable[int]
Enable this ghost object in the physics simulation (default = 1).
filters[10 symbols]
The list of names that determine colliding objects for this ghost object; Valid attributes are all and default . Additional valid attributes are defined by the colliding objects' filterclass attribute.
force[3 floats]
Apply a force to the colliding rigid bodies using the vector from the ghost object center to the rigid body center, scaled by amount . If amount is positive, bodies shoot away from the ghost center, if negative they are pulled into the ghost center.
name[symbol]
Specifies the name of the instance (default = UID).
position[3 floats]
Ghost object in worldspace in the form x y z (default = 0. 0. 0.).
quat[4 floats]
Ghost object orientation as a quaternion in the form x y z w (default = 0. 0. 0. 1.).
rotate[4 floats]
Ghost object orientation as angle-axis in the form angle(in degrees) x y z (default = 0. 0. 0. 1.).
rotate_order[symbol]
Sets the order of rotations that are applied to the rotatexyz attribute for all child gl objects (default = auto). E.G. if set to xyz , the object is first rotated around its X axis, then Y, and finally Z. The default value, 'auto', implements yzx ordering.
Possible values:
'auto'
'xyz'
'xzy'
'yxz'
'yzx'
'zxy'
'zyx'
rotatexyz[3 floats]
Ghost object orientation as Euler angles (in degrees) in the form x y z (default = 0. 0. 0.).
scale[3 floats]
The Ghost object scaling factor in the form x y z (default = 1. 1. 1.). Cannot be applied to
shapes.
shape[symbol]
Collision shape type (default = sphere).
Possible values:
'sphere'
'cube'
'capsule'
'cone'
'cylinder'
'convexhull'
'concave'
'dynamicmesh'
torque[3 floats]
Apply a torque (angular force) to the colliding bodies using a 3D worldspace vector (default = 0 0 0).
worldname[symbol]
The name of a jit.phys.world context this ghost object is 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]: 0
Adds or removes the object from the patcher's background layer.
adds the object to the background layer, 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'
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]: 0
Toggles whether an object ignores mouse clicks in a locked patcher.
jspainterfile[symbol]
JS Painter File
patching_rect[4 floats]: 0. 0. 100. 0.
Sets the position and size of the object in the patcher window.
position[2 floats]
write-only
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]: 0
Sets whether an object belongs to the patcher's presentation.
presentation_rect[4 floats]: 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]
write-only
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]
write-only
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[4 floats]
Sets the color for the object's text in RGBA format.
textjustification[int]
Sets the justification for the object's text.
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 ghost forces and output collision dict
central_impulse
Apply an impulse (instantaneous force) to the colliding rigid bodies using the vector from the ghost object center to the rigid body center, scaled by amount . If amount is positive, bodies shoot away from the ghost center, if negative they are pulled into the ghost center. Impulse strength is inversely proportional to the distance between objects.
- amount
[float]
impulse
Apply an impulse (instantaneous force) to the colliding 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.
- x
[float]
- y
[float]
- z
[float]
- relative-x
[float]
- relative-y
[float]
- relative-z
[float]
reset
Clear all forces
torque_impulse
Apply a torque impulse (instantaneous angular force) to the colliding rigid bodies using a worldspace vector described by x , y , z .
- x
[float]
- y
[float]
- z
[float]
See Also
Name | Description |
---|---|
jit.phys.world | Collision detection and rigid body dynamics |
jit.phys.body | A rigid body and collision shape |
jit.phys.multiple | Uses matrices to simulate multiple rigid bodies |
jit.phys.picker | Constraint picking in a physics world |
jit.gl.physdraw | A physics opengl debug drawer |