pymel.core.effects.collision

collision(*args, **kwargs)

The collision command causes particles to collide with geometry. It also allows you to specify values for the surface properties (friction and resilience) of the collision. These values are stored in the geoConnector node for the geometry object. Unlike earlier versions of Maya, there is no separate collision node.If a soft object is in the selection list, the collision command assumes that you want to make it a collider. In order to make the soft object collide with something use, use connectDynamic -c. The collision menu option sorts this out using the lead object rule and issues the necessary commands. On creation, this command returns a string arrayof the geometry names that were setup for particle collision.When the command is used to query information, there are several possible return types. These include: If the -resilience or -friction flag is passed on the command line and a single collision geometry is either selected or on the command line, then resilience or friction value for that collision geometry is returned as a single floatvalue.If the -resilience or -friction flag is passed on the command line and a single collision geometry and a single particle object are either selected or on the command line, then two results might occur. If the particle object is not set up to collide with the geometry, then an error is displayed stating that. If the objects are set up to collide with each other, then the resilience or friction value that the particle object is using for collisions with the geometry is returned as a single floatvalue. This can be different than the geometry’s resilience and friction, because the user may break the connection from the geometry’s geoConnector node’s resilience or friction to the particle, and set a different value in the particle’s collisionResilience, collisionFriction or collisionOffset attribute that is used for that geometry. This allows the user to make each particle respond to the same surface differently. If neither flag is pass on the command line and a single geometry and single particle object are either selected or on the command line, then a single integervalue of 1 is returned if the objects are set up to collide with each other, and 0 is returned if they are not. Lastly, if no flags are passed on the command line and a single particle object is either selected or on the command line, then a string arraywith the names of all geometries that the particle object will collide against and the multiIndex that the geometries are connected to is returned. The array is formatted as follows: pPlaneShape1:0 pPlaneShape2:2 nurbsSphereShape1:3 ...where the number following the :is the multiIndex.

Flags:
Long name (short name) Argument Types Properties
friction (f) float ../../../_images/query.gif ../../../_images/edit.gif
 

Friction of the surface. This is the amount of the colliding particle’s velocity parallel to the surface which is removed when the particle collides. A value of 0 will mean that no tangential velocity is lost, while a value of 1 will cause the particle to reflect straight along the normal of the surface. Flag can have multiple arguments, passed either as a tuple or a list.

name (n) unicode  
 

This flag is obsolete. In maya 2.0, there is no longer a separate collision node,thus there is nothing to name. See the collision documentation. This flag is included only to allow scripts written with older versions of Maya to run. It will give you a warning message but will not do anything.

offset (o) float  
   
resilience (r) float ../../../_images/query.gif ../../../_images/edit.gif
 

Resilience of the surface. This is the amount of the colliding particle’s velocity reflected along the normal of the surface. A value of 1 will give perfect reflection, while a value of 0 will have no reflection along the normal of the surface.

Derived from mel command maya.cmds.collision

Example:

import pymel.core as pm

pm.collision( 'nurbsSphere1', 'particle1', r=.75, f=.1 )
# Causes particles of particle1 to collide with nurbsSphere1,
# and sets a resilience value of 0.75 and a friction value of 0.1
# for the surface.

pm.collision( 'nurbsSphere1', q=True, f=1 )
# Returns the friction value stored in the geoConnector for nurbsSphere1.

pm.collision( 'particleShape1', 'nurbsSphere1', q=True, f=1 )
# Returns the friction value that particleShape1 is using for collisions
# against nurbsSphere1.  This may be the same as the friction stored in
# nurbsSphere1's geoConnector.  Or, if the user broke that connection,
# then it is whatever value is in the particleShape1's collisionFriction
# attribute that is used for collision with nurbsSphere1.

pm.collision( 'nurbsSphere1', 'particleShape1', q=True )
# Returns whether or not particleShape1 is checking for collisions
# against nurbsSphere1.

pm.collision( 'particleShape1', q=True )
# Returns all of the geometries that particleShape1 is colliding with.

Previous topic

pymel.core.effects.arrayMapper

Next topic

pymel.core.effects.colorAtPoint

Core

Core Modules

Other Modules

This Page