PDA

View Full Version : Randomising the goalweight


jcarruthers
01-19-2007, 04:55 PM
I want to randomise my particles so that they don't all react their goal at the same time...

Creation

float $startgoal = 1;
float $endgoal = 2;

float $startgoalmax = 0.5;
float $endgoalmax = 0.2;

float $startgoaloffset = rand($startgoalmax*-1, $startgoalmax);
float $endgoaloffset = rand($endgoalmax*-1, $endgoalmax);

sourceParticleShape.startgoal = ($startgoal + $startgoaloffset);
sourceParticleShape.endgoal = ($endgoal + $endgoaloffset) - $endgoaloffset;




Runtime

if(sourceParticleShape.startgoal<time)
{
sourceParticleShape.goalWeight0PP = linstep(sourceParticleShape.startgoal, sourceParticleShape.endgoal, time);
}



It seems to half work - but half my particles disappear when the goalweight starts to kick in... :(

Sanctuary
01-19-2007, 11:51 PM
if this is what you wanted then read below, if not tell me to edit my post > link to demo (http://rapidshare.com/files/12479497/playblast_goalPP.avi)





1. startgoalPP, endgoalPP - needs to be PP attributes for this to work

2. use goalWeightPP only if you have multiple goals and only if you want to control the influence of a specific goal object, if is not the case use goalPP instead

3. on creation set goalPP to 0 to avoid you particle to snap to the goal object on the first runframe

4. on the last line of you creation code you add and then substract the same value :eek:, what`s the point

here`s a working code;

creation

float $startgoal = 1;
float $endgoal =4;

float $startgoalmax = 0.2;
float $endgoalmax = 0.5;

float $startgoaloffset = rand( $startgoalmax * -1, $startgoalmax );
float $endgoaloffset = rand( $endgoalmax * -1, $endgoalmax );


startgoalPP = ($startgoal + $startgoaloffset);
endgoalPP = ($endgoal + $endgoaloffset);

goalPP = 0;


runtime

if(startgoalPP<time)
{
goalPP = linstep(startgoalPP, endgoalPP, time);
}



P.S.
make sure to add startgoalPP and endgoalPP to your particle shape

jcarruthers
01-20-2007, 01:01 PM
Awesome! I cannot thank you enough.

Not sure what was going on with the maths on the last line of the creation code - it always gets messy when I'm trying to make something work.

Many thanks again! - James

Sanctuary
01-20-2007, 01:07 PM
you` re welcome

jcarruthers
01-20-2007, 02:13 PM
Another related question...

Can I adjust each particles dynamic weight on a per particle basis?

When I am adding turbulance - or a vortex - I would like them to be a bit more random.

Sanctuary
01-20-2007, 02:19 PM
yes, play with the mass of the particle

jcarruthers
01-20-2007, 03:58 PM
Ok - I came up with this:


//mass vars
float $startmass = 0;
float $endmass = 1;
float $startmassmax = 0.1;
float $endmassmax = 0.25;
sourceParticleShape.minMassPP = 0.1;
//sourceParticleShape.maxMassPP = 1.0;

//mass code
float $startmassoffset = rand(0, $startmassmax);
float $endmassoffset = rand($endmassmax*-1, $endmassmax);
sourceParticleShape.startMassPP = ($startmass + $startmassoffset);
sourceParticleShape.endMassPP = ($endmass + $endmassoffset);
sourceParticleShape.mass = sourceParticleShape.minMassPP;




if(time>sourceParticleShape.startMassPP)
{
sourceParticleShape.mass = smoothstep(sourceParticleShape.startMassPP, sourceParticleShape.endMassPP, time) + sourceParticleShape.minMassPP;
}


Trouble is - it doesn't do anything - dynamic weight is set on 0... and none of the particles react to any of the dynamics.

Sanctuary
01-20-2007, 04:18 PM
i don`t see the point of all this code that you are putting in the creation part


1. this creation code is more then enough to add a random mass to every born particle

mass = rand(minVal, maxVal);

P.S.
your creation code is all useless since all you particle born with the same mass (0.1)


2. if dynamic weight is set on 0 then particle system will NOT be affected by any external force (eg. fields)

3. your runtime code will gradually rise the mass of every particle (they will be less and less affected by external forces) ... it`s that what you want ?!?

jcarruthers
01-20-2007, 04:34 PM
I wanted to make the mass of the particles rise from frame 0 to frame 25.

I don't quite understand the relationship with dynamic weight and mass.

I think I understand more now - I should add keyframes to make the dynamic weight go from 0 to 1 over time.

jcarruthers
01-20-2007, 04:55 PM
The code works great :)

I was thinking backwards how mass effects dynamics - of course - 0 mass means they are effected a lot, more mass means they are effected less.

I have a few issues with Maya screwing up my particles - sometimes it forgets parts of the code. Like the goalPP code - I have to go back to a previously saved version of the file to get it to work again.

Sanctuary
01-20-2007, 06:22 PM
... I have to go back to a previously saved version of the file to get it to work again.

weird indeed



describe me the behaviour you want your particles to have and i`ll try to direct you

jcarruthers
01-21-2007, 01:04 PM
I've actually got them spot on now - the only thing left that I want to do is get the opacity to transition (source and destination particles pick up the colour of their surface emmiters)

I've got the RGB working - but not the opacity for some reason.

Sanctuary
01-21-2007, 02:28 PM
I've actually got them spot on now - the only thing left that I want to do is get the opacity to transition (source and destination particles pick up the colour of their surface emmiters)

I've got the RGB working - but not the opacity for some reason.


you want the particles to fade out as they get older ?

jcarruthers
01-22-2007, 09:50 AM
I'm using this:


sourceParticleShape.rgbPP = hermite(sourceParticleShape.birthrgb,destParticleShape.rgbPP,<<0,0,0>>,<<0,0,0>>,smoothstep(0,2,time));


Which works well - but for some reason I couldn't get it to work with opacity.

My other problem is that I need to use blobby surface particles - and I need them to pick up the rgbPP colour.

jcarruthers
01-22-2007, 10:41 AM
Sorted out the rgbPP & blobby problem...

http://help.thecentre.centennialcollege.ca/manuals/maya/UserGuide/Dynamics/RenderParticles6.html

CGTalk Moderation
01-22-2007, 10:41 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.