FORUMS: list search recent posts

# Using MEL expressions to control particles, followed by joint rotation?

VIEW ALL
 Using MEL expressions to control particles, followed by joint rotation? on Jul 6, 2016 at 4:38:10 am

Hi All,

I've used an expression to emit particles on the death of a first particle object and it works really well. What I want to do now is use the second set of particles to drive joint rotation, again using expressions.
So, the sum total of what I have now is:
if (volumeAxis_nParticle1_nerveImpulseShape.age >= volumeAxis_nParticle1_nerveImpulseShape.lifespanPP)
//if particle age is >= lifespan
{
vector \$pos = volumeAxis_nParticle1_nerveImpulseShape.position;
//determines where the particles are when they die
float \$emitNum = 3;
//determines how many particles will be emitted upon particle death ie 3
for (\$i = 0; \$i < \$emitNum; \$i ++)
// for variable \$i, start at 0 and if \$i ;
//determines the direction of the emitted particles in x, y, z
emit -o emitOnDeath_nParticle1_acetylCholine //emit the second particle object
-position (\$pos.x) (\$pos.y) (\$pos.z) //where first particle object dies
-at velocity //now determine velocity
–vv (\$randVel.x) (\$randVel.y) (\$randVel.z); //vector values (vv) for random velocity x, y or z
};
};

The next set of expressions I have for controlling joint rotation is:

if (emitOnDeath_nParticle1_acetylCholineShape.age < emitOnDeath_nParticle1_acetylCholineShape.lifespanPP)
longMuscleController22.rotateY = 0;
else if (emitOnDeath_nParticle1_acetylCholineShape.age >= emitOnDeath_nParticle1_acetylCholineShape.lifespanPP)
longMuscleController22.rotateY = -0.1;

This second expression does rotate the joint, but for greater control, what I really need is another command to return the joint rotation to 0 again, ie relax quickly after a contraction. At the moment, the rotation only returns to 0 when the first nerveImpulse expression starts again. I was thinking maybe another else if line, something to the effect that when the particle count =0 (ie once all the particles have died off, when lifespanPP is exceeded), that rotate y = 0 again?

I tried this instead, using particle count:

int \$numPar = `particle -ct emitOnDeath_nParticle1_acetylCholineShape`;
if(\$numPar == 0)
longMuscleController22.rotateY = 0;
else if(\$numPar > 0)
longMuscleController22.rotateY = -0.1;

Maya says the syntax is correct, but it throws up all sorts of errors once it executes and doesn't move the joint. I'd really appreciate any advice please on how to use the second set of particles to control joint rotation, if you have any?

Maja

 Re: Using MEL expressions to control particles, followed by joint rotation?on Jul 10, 2016 at 8:27:00 am

Hello? Steve Sayer? Anyone?

 Re: Using MEL expressions to control particles, followed by joint rotation?on Jul 13, 2016 at 11:33:21 pm

I've used an expression to emit particles on the death of a first particle object and it works really well. What I want to do now is use this second set of particles (with defined lifespan.PP) to drive joint rotation, again using expressions ie while the particles are in existence, I don't want any joint rotation to occur, but once they die off, I want the joint to rotate and then quickly return to zero ie relax quickly after a contraction. So, what I have is:

if (nParticleShape.age < nParticleShape.lifespanPP)

muscleController.rotateY = 0;

else if (nParticleShape.age >= nParticleShape.lifespanPP)

muscleController.rotateY = -0.1;

This expression rotates the joint nicely, but for greater control, what I really need is another command line to quickly return the joint rotation to 0 again. At the moment, the rotation only returns to 0 when the particle emission begins again, and age is once again less than lifespan. I was thinking maybe another else if line, something to the effect that when the particle count = 0 (ie once all the particles have died off when lifespanPP is exceeded), that rotate y = 0 again? I tried this instead, using particle count:

int \$numPar = `particle -ct nParticleShape`;

if(\$numPar == 0)

muscleController.rotateY = 0;

else if(\$numPar > 0)

muscleController.rotateY = -0.1;

Maya says the syntax is correct, but it throws up all sorts of errors once it executes and doesn't rotate the joint. The error message is:

// Error: line 0: Cannot convert data of type string[] to type int. //
// Error: An execution error occurred in the runtime before dynamics expression for nParticle1Shape. //

So I took away the 'int' code and tried again and got this error message:

// Error: line 1: Cannot use data of type string[] in a scalar operation. //
// Error: An execution error occurred in the runtime before dynamics expression for nParticleShape. //

I'd really appreciate any advice on the correct particle MEL commands to use to rotate the joint and then quickly return it to 0? Apologies, but I'm really bad at this!