Go to: Synopsis. Return value. Related. Flags. Python examples.
gravity(
[objects]
, [attenuation=float], [directionX=float], [directionY=float], [directionZ=float], [magnitude=float], [maxDistance=linear], [name=string], [perVertex=boolean], [position=[linear, linear, linear]])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
gravity is undoable, queryable, and editable.
A gravity field simulates the Earth's gravitational force. It pulls
objects in a fixed direction (generally downward) entirely
independent of their position or mass.
The transform is the associated dependency node.
Use connectDynamic to cause the field to affect a dynamic object.
If fields are created, this command returns the names of each
of the fields. If a field was queried,
the results of the query are returned. If a field was edited, the field
name is returned.
If object names are provided or the active selection list is non-empty,
the command creates a field for every object in the list and calls
addDynamic to add it to the object. If the
list is empty, the command defaults to -pos 0 0 0.
Setting the -pos flag with objects named on the command line is an error.
The default for -dx -dy -dz is always the opposite of the current up
direction. For example, if the current up direction is (0,1,0)
(a standard Maya configuration), then the gravity default is
-dx 0 -dy -1 -dz 0. The default for -a is 9.8. 9.8 meters per second
squared happens to be standard Earth gravity, but in fact Maya interprets
this value as centimeters per second squared. If we were to use it as
meters per second squared then with default Maya units, your particles
would vanish almost in the wink of an eye. If you want a different value,
set it in the gravity option box.
In query mode, return type is based on queried flag.
addDynamic, connectDynamic, particle
attenuation, directionX, directionY, directionZ, magnitude, maxDistance, name, perVertex, position
Long name (short name) |
Argument types |
Properties |
position(pos)
|
[linear, linear, linear]
|
|
|
Position in space where you want to place a field.
The gravity then emanates from this position in space rather
than from an object. Note that you can both use -pos
(creating a field at a position) and also provide object names.
|
|
magnitude(m)
|
float
|
|
|
attenuation(att)
|
float
|
|
|
Attentuation rate of field
|
|
maxDistance(mxd)
|
linear
|
|
|
Maximum distance at which field is exerted.
-1 indicates that the field has no maximum distance.
|
|
name(n)
|
string
|
|
|
perVertex(pv)
|
boolean
|
|
|
Per-vertex application. If this flag is set true, then each
individual point (CV, particle, vertex,etc.) of the chosen object
exerts an identical copy of the force field. If this flag is set to
false, then the force is exerted only from the geometric center of
the set of points.
|
|
directionX(dx)
|
float
|
|
|
X-component of direction.
|
|
directionY(dy)
|
float
|
|
|
Y-component of direction.
|
|
directionZ(dz)
|
float
|
|
|
Flag can appear in Create mode of command
|
Flag can appear in Edit mode of command
|
Flag can appear in Query mode of command
|
Flag can have multiple arguments, passed either as a tuple or a list.
|
import maya.cmds as cmds
cmds.gravity( 'particle1' )
# Creates a gravity field and adds it to the list of fields
# owned by particle1.
cmds.gravity( pos=(-2, 0, 4) )
# Creates a gravity field at position (0,2,4) in world coordinates.
cmds.gravity( 'MyGravity', e=True, att=10.4 )
# Changes the gravitational acceleration of the field called
# "MyGravity" to 10.4.
cmds.gravity( dx=0, dy=1.0, dz=0.5 )
# Creates a gravity field pulling in direction (0,1,0.5) for every
# active selection. If there is no active selection, it creates this
# field at world position (0,0,0).