Go to: Synopsis. Return value. Related. Flags. MEL examples.
emit [-attribute string] [-floatValue float] [-object string] [-position float float float] [-vectorValue float float float]
emit is undoable, NOT queryable, and NOT editable.
The emit action allows users to add particles to an existing particle
object without the use of an emitter. At the same time, it allows them to
set any per-particle attribute for the particles that are created with the
action.
The particles created do not become a part of the initial state
for the particle object, and will disappear when the scene is rewound unless
they are saved into the initial state by the user explicitly. In addition,
a particle object will accept particles from an emit action ONLY at frames
greater than or equal to its start frame. For example, if you want to use the
emit action to create particles at frame -5, you must set startFrame for that
particle shape to -5 or less.
Unlike many commands or actions, the emit action uses the order of its flags
as important information as to how it works. The -object and -position
flags can appear anywhere in the argument list. The -attribute and the
value flags are interpreted based on their order. Any value flags after an
-attribute flag and before the next -attribute flag will set the values for
the attribute specified by the closest -attribute flag before them in the
argument list. See the Examples section below for more detail on
how these flags work.
Currently, no creation expression is executed for the new particles
unless they are created from within a particle expression defined with
the dynExpression command or the Expression Editor. If you
want any particular values put into the particles at the time they are
created, then those values should be set using the -attribute,
-vectorValue, and -floatValue flags.
int[] | Integer array containing the list of the particleId attribute values
for the created particles in the same order that the position flags
were passed. |
particle
attribute, floatValue, object, position, vectorValue
Long name (short name) |
Argument types |
Properties |
-object(-o)
|
string
|
|
|
This flag takes the name of a particleShape or the transform
directly above it in the DAG as its parent. It specifies
which object to add the particles to. This flag must
be passed, as the selection list is ignored for this action.
|
|
-position(-pos)
|
float float float
|
|
|
Specifies the positions in the particle object's space
(usually world space) where the particles are to be created.
One particle is created for each occurence of this flag.
|
|
-attribute(-at)
|
string
|
|
|
Specifies the attribute on the particle object that any
value flags following it and before the next -attribute flag
will be associated with. The same attribute can be specified
later in the command to pick up where the first one left off.
The attributes used must be per-particle attributes. This
will accept both long and short names for the attributes.
Note the per-particle attribute must already exist on the
particle object prior to being specified via this command flag.
|
|
-vectorValue(-vv)
|
float float float
|
|
|
Sets the vector value to be used for the "current" attribute of
the "current" particle. By current attribute, it is meant the
attribute specified by the most recent -attribute flag. By
current particle, it is meant the particle in the list of -position
flags that corresponds to the number of values that have
been set for the "current" attribute. If the current attribute
is a float-per-particle attribute, then the length of the
vector described by this flag will be used. The length is
described as SQR( xVal2 + yVal2 + zVal2 ).
|
|
-floatValue(-fv)
|
float
|
|
|
Sets the float value to be used for the "current" attribute of
the "current" particle. By current attribute, it is meant the
attribute specified by the most recent -attribute flag. By
current particle, it is meant the particle in the list of -position
flags that corresponds to the number of values that have
been set for the "current" attribute. If the current attribute
is a vector-per-particle attribute, then the float value
specified will be used for all three components of the vector.
|
|
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 be used more than once in a command.
|
particle;
emit -object particle1 -position 1 1 1;
// This will create one particle at position <<1,1,1>> in the
// already-existing particle object <i>particle1</i>.
//
particle;
emit -object particle1
-position 1 1 1
-position 2 2 2
-attribute velocity
-vectorValue 1 2 3
-vectorValue 2 3 4
-attribute rgbPP
-vectorValue .5 1 0
-floatValue .1;
// This will create two particles at positions <<1,1,1>> and <<2,2,2>> in
// the already-existing particle object <i>particle1</i>. Then the velocity
// attribute of those particles is set to <<1,2,3>> and <<2,3,4>>,
// respectively. Also, the rgbPP values are set to <<.5,1,0>> and
// <<.1,.1,.1>>, respectively. Notice that the rgbPP value for the
// second particle was set with the -floatValue flag, even though rgbPP
// is a vector attribute. The single value was converted into a vector.
particle;
emit -object particle1
-position 1 1 1
-position 2 2 2
-position 3 3 3
-position 4 4 4
-position 5 5 5
-attribute velocity
-vectorValue 1 2 3
-vectorValue 2 3 4
-attribute mass
-floatValue .5
-vectorValue .1 .2 .3
-attribute velocity
-vectorValue 3 4 5;
// This will create five particles in <i>particle1</i>. The values
// for their attributes are:
//
// Attribute Particle1 Particle2 Particle3 Particle4 Particle5
// ----------+-----------+-----------+-----------+-----------+---------
// position <<<<1,1,1>>>> <<<<2,2,2>>>> <<<<3,3,3>>>> <<<<4,4,4>>>> <<<<5,5,5>>>>
// velocity <<<<1,2,3>>>> <<<<2,3,4>>>> <<<<3,4,5>>>> <b><<<<3,4,5>>>> <<<<3,4,5>>>></b>
// mass .5 .3742 <b>.3742 .3742 .3742</b>
//
// Notice that the second value for mass was seet with the -vectorValue
// flag, even though mass is a float attribute. The vector was
// converted into a float by taking its length. Also, notice the <b>bold</b>
// values in the table. The values for those attribute values were not
// explicitly set in the command. If there are fewer values given for
// an attribute than there are position flags, the remaining unset
// values are set to the last value set for that attribute. This
// allows the user to set many of the values to be the same without
// having to use multiple value flags. One last note. Notice that the
// attribute flag was passed twice for the attribute velocity. The value
// flags for repeated attributes pick up where the previous ones left
// off.
float $x = rand(1);
float $y = rand(1);
float $z = rand(1);
vector $p = sphrand(5);
emit -object particle1
-pos $x $y $z
-pos ($p.x) ($p.y) ($p.z);
// This is a piece of MEL code that could be put in a script or
// even in an expression. It adds two new particles to the
// already-existing particle object <i>particle1</i>. It adds them
// at random positions, however. These random values can be computed
// and stored in MEL variables. Then those variables can be used in
// the emit action. Notice that the float variables can be used
// directly, but the components of the vector must be enclosed in
// parentheses. This is also true if they are used to with the
// <b>-vectorValue</b> flag.
int $i;
int $emitCount = rand(10,15);
string $objectName = "object1";
string $emitCmd = ("emit -object " + $objectName + "\n");
for( $i = 0; $i < $emitCount; $i ++ ) {
vector $pos = sphrand(10);
$emitCmd += " -pos "+$pos+"\n"; }
$emitCmd += " -at velocity\n";
for( $i = 0; $i < $emitCount; $i ++ ) {
vector $vel = sphrand(5);
$emitCmd += " -vv "+$vel+"\n"; }
eval( $emitCmd );
// This is a piece of MEL code that could be put in a script or
// even in an expression. It adds a random number of particles
// to the already-existing particle object <i>particle1</i>. Since
// the number of particles as well as the positions and velocities
// of the particles are random, it would be impossible to just have
// the emit action itself in the expression or script. It must be
// built as a string and then sent to the command processor with the
// <b>eval</b> or <b>evalEcho</b> commands. Notice that when appending
// the vector variables to the string, it is not necessary to append
// each component of the vectors separately. When they are converted
// from a vector to a string, the three components get separated with
// a space automatically, thus formatting them in the desired way.
// An example of a possible result from this "script" could be:
emit -object particle1
-pos 1.899864198 -6.721569708 0.585203937
-pos 8.103957656 -4.042442985 2.047724209
-pos -1.392914569 -0.109724376 8.62265813
-pos 1.960103537 -3.203145195 -7.6892516
-pos 2.564072614 -6.049536895 1.334818295
-pos -5.603376821 4.33595058 6.952385447
-pos -2.478591746 6.286855715 6.851659059
-pos 2.424670276 -4.083412217 6.320538621
-pos 6.440800453 3.405519296 5.462135819
-pos 2.445192551 1.397203422 3.443755853
-at velocity
-vv -2.348796409 4.022130218 0.5316172944
-vv 4.149667117 -1.023146404 1.97965556
-vv -0.08429132578 -0.5518495233 1.591812495
-vv 2.597930963 1.033536331 -1.398351383
-vv -3.102859272 3.423569856 0.7895603241
-vv -2.519331228 -2.5684916 -1.530779154
-vv -2.645169119 -0.3186551381 0.9164776099
-vv -0.6183816487 -1.060784068 -0.8748223942
-vv -0.2460372256 3.567980747 -2.007567372
-vv 1.735044809 -3.660099445 -1.765401859;
// The spacing in the string is just for formatting reasons and does
// not affect how the action executes or compiles.