nParticles/ Instances - issue in expression

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  01 January 2011
nParticles/ Instances - issue in expression

By this expression, I want to kill particles based on their y position (if lower than my locator "killZone" set lifespanPP to 0).


vector $locPos = <<killZone.translateX, killZone.translateY, killZone.translateZ>>; vector $ptclPos = nParticleShape1.position;
  	if($ptclPos.y < $locPos.y)
 	{
 		print("WTF??");
 		nParticleShape1.lifespanPP = 0;
 	}


Although the condition is fulfilled (some WTF?'s in the script editor window tell me so), the particles seem not to be killed at all (at least, the instanced geometry is still existing although being lower than the locator's position)

The expression above has done a fine job for me in several std particles jobs- so why isn't it working in this case? Am I missing something?

Thank you for any answers!
__________________
"I love deadlines. I like the whooshing sound they make as they fly by" - Douglas Adams -
 
  01 January 2011
Not sure how that has ever worked. position is local space IIRC. And I believe in this way it will be the center of all particles combined, although you shouldn't quote me on that.

I extended your print statement to give more feedback, and once the first particle goes below the locator in world space, this is what the print statement says:

WTF??
FIRST PARTICLE POS: .889105
LOCATOR Y POS: 0.911179414.
SHAPE.POS Y: -11.7591055
LIFESPANPP: 0


So lifespanPP doesn't seem to do anything here, and the nParticleShape1.position is giving a completely different position, as I guessed before, it must be local space, as -11 would be far below the locator, while this is not the case.


EDIT: My bad, forgot to set lifespan to lifespanPP only. So lifespanPP does work, but as the position variable isn't giving you a correct variable, it doesn't work as intended. I suggest you change the $ptclpos to something else, depending on the effect you want to create.

To get an accurate world space reading, I just took the position array of a single particle.

float $test[] = `getParticleAttr -at worldPosition nParticleShape1.pt[0]`;

so then $test[1] would be the translateY.

Last edited by dizzyone : 01 January 2011 at 03:40 PM.
 
  01 January 2011
dank u well!

I forgot to set lifespanPP only, too.

Even though the results of the position value might not be accurate, somehow this works pretty well.
__________________
"I love deadlines. I like the whooshing sound they make as they fly by" - Douglas Adams -
 
  01 January 2011
this is how i do it and it works every time

expression
// creation and runtime
float $pos = worldPosition;
lifespanPP = 1000; (whatever number really)
//runtime
if ($pos.y <= loc.ty)
lifespanPP = 0;

name of your locator is loc and it is positioned where you want it to kill the particles
 
  01 January 2011
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:27 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.