CGTalk > Software > Autodesk Maya > Maya Dynamics
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 03-26-2013, 07:26 PM   #1
ithilis
New Member
portfolio
Richard Mitchell
Ajax, Canada
 
Join Date: Feb 2010
Posts: 10
Multiple goals with per particle expression?

Hi guys,

I have been using Maya for a few years now, but have little experience with nParticles, which I am required to use for a scene I've been assigned. I think I know what I need to do, I'm just not sure exactly how to execute it.

I need particles to emit from their source, travel toward goal0, wait a few seconds, then travel toward goal1. The catch is that I need them to travel between goal0 and goal1 in one-by-one fashion, and not in a clump, which rules out simply keying the goal weights. I'm pretty sure I need to use some kind of per particle expression based on the lifespanPP of each particle that attracts them to goalWeight1PP, but I have no idea how to do that.

Any help would be appreciated!
Thanks!
 
Old 03-26-2013, 10:53 PM   #2
-heavy-
made of smoke
 
-heavy-'s Avatar
janko
free for hiring
Berlin, Germany
 
Join Date: Jul 2005
Posts: 258
Hey Richard, take a look in here, i think the solution by animatedFox will work for you too

http://forums.cgsociety.org/showthr...ght=animatedfox

but instead of a random number i think you can use lifespan to spread the particles
over different surfaces.

cheerz
deHeavy
 
Old 03-27-2013, 12:54 AM   #3
ithilis
New Member
portfolio
Richard Mitchell
Ajax, Canada
 
Join Date: Feb 2010
Posts: 10
Hi Heavy,

Thanks for steering me in the right direction, but I'm having a little trouble adapting animatedFox's expression. I tried two variations:

if (frame >= 1)
{
nParticleShape1.goalWeight0PP = 0.5;
nParticleShape1.goalWeight1PP = 0;
}

if (frame >= 350)
{
nParticleShape1.goalWeight0PP = 0;
nParticleShape1.goalWeight1PP = 0.5;
}

This was meant to attract the particles on a per particle basis to goal0 starting from frame 1, then once the timeline reached frame 350, the particles would become attracted to goal2 on a per particle basis. Didn't work, sadly.

The second was very similar, but using nParticleShape1.lifespan instead of 'frame'. That didn't work either. I feel like I'm overlooking something simple.

Thanks for you help! I'll keep at it!
 
Old 03-27-2013, 01:14 PM   #4
animatedfox
what the ?!?!
 
animatedfox's Avatar
portfolio
Benjamin Fox
Seat 43
USA
 
Join Date: Feb 2010
Posts: 895
Glad the previous post has might have been useful.
I think the issue with your current setup is that I think your if statements need to be a little more specific. Seeing as when the frame is >= 350 it is also >= 1 you could have some wonkiness.
Make sure this is in your Runtime Before Dynamics section of your particle expression and try changing your expression to something like this:

if (frame >= 350)
{
//set weights
}
else
{
// set weights
}

or

if(frame >= 1 && frame < 350)
{
}
if(frame >=350)
{
}

As for driving weights with how long a particle has been alive, you can definitely do that. I believe that the attribute you want is .age
This is a float value: 1 would be 1 second .5 would be half a second etc.
Your expression would be something like:

if(part.age<=3)
{
}
else
{
}

Hopefully that helps.
~Ben
 
Old 03-27-2013, 03:06 PM   #5
ithilis
New Member
portfolio
Richard Mitchell
Ajax, Canada
 
Join Date: Feb 2010
Posts: 10
Hi AnimatedFox! Thanks for popping in to help.

I think I'm on the right track now, but it's still not working the way I'd like it to. With your suggestions, here is what I have discovered ...

The following works to a degree:

if(nParticleShape1.age <=10)
{
nParticleShape1.goalWeight[0] = 0.5;
nParticleShape1.goalWeight[1] = 0;
}
else
{
nParticleShape1.goalWeight[0] = 0;
nParticleShape1.goalWeight[1] = 0.5;
}

However, as you can probably tell, it's no better than setting key frames to the goals themselves. After 10 seconds, all of the particles just travel from the first goal to the second goal, all in one huge clump. As I said in a previous post, I need them to travel one-by-one, or in a stream. However, when I try to use per particle weighting, the particles aren't attracted to either goal:

if(nParticleShape1.age <=10)
{
nParticleShape1.goalWeight0PP = 0.5;
nParticleShape1.goalWeight1PP = 0;
}
else
{
nParticleShape1.goalWeight0PP = 0;
nParticleShape1.goalWeight1PP = 0.5;
}

Thanks again for the help. I feel like I'm on the verge of a breakthrough.
 
Old 03-27-2013, 04:03 PM   #6
animatedfox
what the ?!?!
 
animatedfox's Avatar
portfolio
Benjamin Fox
Seat 43
USA
 
Join Date: Feb 2010
Posts: 895
This sounds like there is an issue in your actual goal setup.
Did you click the "Create Goal Weight 0 PP" button under the goal tab?
I have only ever created my PP goal weights attributes this way...and haven't really had any problems driving them like I explained.

Did you just add the GoalWeight0PP attribute? If so this might be the issue.
Try creating a test scene with a basic setup just to see if you have get things working in a clean setup. Sometimes when trying a bunch of things to get something working you make things harder.

Hopefully this helps.
I know it isn't much.
But the behavior you are looking for is totally possible and I have done it just as explained.
Worrisome.
~Ben
 
Old 03-27-2013, 10:09 PM   #7
-heavy-
made of smoke
 
-heavy-'s Avatar
janko
free for hiring
Berlin, Germany
 
Join Date: Jul 2005
Posts: 258
hey Richard,

i tested this frame base script and this worked for me:

and you have to put it in a runtimeExpression so it gets evaluated every
Frame
if(frame > 0 && frame < 50 )
{
nParticleShape1.goalWeight0PP = 0.2;
nParticleShape1.goalWeight1PP = 0.8;
}
if(frame > 50 && frame < 100 )
{
nParticleShape1.goalWeight0PP = 0.8;
nParticleShape1.goalWeight1PP = 0.2;
}

the problem with the goalWeight is when you use goalWeight without any goalU and V value
expressions or offset or further scripting - the particles will immediately stick to the goal when you set goal weight to 1 or zero. thats why i used 0.2 and 0.8 so the particles travel but also as a clump.

is it really necessary that you use Goals ?
maybe you can use a newton field which attracts the particles ? in this case you can use field Magnitude perParticle and set the magnitude of the fields individually based on lifespan or time...

cheerz
deHeavy

ohh and Ben, yes your rand(Switcher) worked great for my setup with that multiPolyUVRampMotion thing

EDIT:

ohh and i would not use ".age" i would use "ageNormalized" instead - but you have to manually add it to the particle system as a float perParticle.

it gives you a value between 0 and 1 - so you can use random Values in particle Lifespan and change lifespan whenever you which without changing the expression.

Edit:
or you try this one in creationExpression:
nParticleShape1.goalPP = 1;
nParticleShape1.goalU = rand(0,1);
nParticleShape1.goalV = rand(0,1);
and in runtime

if(frame > 0 && frame < 50 )
{
nParticleShape1.goalWeight0PP = 0.5 + nParticleShape1.ageNormalized;
nParticleShape1.goalWeight1PP = 0.5 - nParticleShape1.ageNormalized;
}
if(frame > 50 && frame < 100 )
{
nParticleShape1.goalWeight0PP = 1 - nParticleShape1.ageNormalized;
nParticleShape1.goalWeight1PP = 0 + nParticleShape1.ageNormalized;
}

cuz ageNormalized is between 0 and 1 you can add and substract it to the weight also.

Last edited by -heavy- : 03-27-2013 at 10:21 PM.
 
Old 03-27-2013, 10:09 PM   #8
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 10:26 AM.


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