View Full Version : Setting particle attrs
Aikiman 08-04-2007, 10:25 PM dudes,
pretty basic question regarding procedures and set particle attrs. Below is a global proc that appears to be called to an expression node from within Maya. The last line(s) in orange are mine and don't work. How do I change a particles attribute lifespan to zero in this case?
global proc ssColEvent( string $partName, int $partId, string $objName )
{
float $index[] = `getParticleAttr -at "collisionGeometryIndex" ($partName + ".pt[" + $partId + "]" )`;
if( $index[0] == 0 )
setAttr ($partName + ".lifespanPP") 0;
or
setParticleAttr -at lifespan -fv 0;
either line gives me an error
|
|
BadG3r
08-05-2007, 02:19 PM
the first one is the way to go, but without the PP behind lifespan.
darktding
08-05-2007, 03:27 PM
you want to use the same way it is used as in getParticleAttr...
something along the lines of...
setParticleAttr -at "lifespanPP" -fv 0 ($partName + ".pt[" + $partId + "]");
don't forget to set the life mode in the particleshape to lifespanPP.
Aikiman
08-05-2007, 08:13 PM
thanks for your replies guys,
firstly I want it to be on a per particle level as I want each particle to die when it collides with a certain piece of geo. However looking at darktding's line of code would suggest for this to work but it seems to work on a scalar level and even then only once.
I have set my lifespan mode to lifespanPP yet when I made a creation expression for lifespanPP my script editor told me that the code within the proc couldnt connect to lifespanPP because it already had a connection, so I deleted the expression but got the same results as above.
Im not very good with procedures, I think that is where my problem is.
darktding
08-05-2007, 08:30 PM
you are confusing between per particle expressions vs regular expression.
This is continuining from the events thread (http://forums.cgsociety.org/showthread.php?f=86&t=522778) on the dynamics section.
To be blunt - I HATE MAYA EVENTS - it sucks, it is a huge sham the alias team has made to justify for a feature, when all it is there is to bruise my forehead from all that banging on my head.:banghead:
Events use regular expression which is really buggy, and doesn't work and sometimes even crashes maya.
To be efficient about getting the result, you are on the right path - using per particle expressions.
Paste the following lines into the runtime before dynamics and you are set
int $index = collisionGeometryIndex;
if( $index == 0 )
{
print "we hit a \n";
lifespanPP = 0; // killing particles
}
if( $index == 1 )
{
print "we hit b \n";
}
You will notice I don't use the get/setParticleAttr, and it works more reliably than running regular event expression which sucks...
Aikiman
08-06-2007, 01:01 AM
hey thanks man, that makes a lot more sense now. So in terms of particle expressions, there is no real need to call athe procedure? If it is a normal expression you do call them?
I empathise with the head banging, I have a sore forehead myself :)
CGTalk Moderation
08-06-2007, 01:01 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.