View Full Version : Call up frame a particle was created on?

05 May 2007, 03:47 AM
How can I make an array or something like that that says what frame each particle was born on?

05 May 2007, 11:20 PM
How can I make an array or something like that that says what frame each particle was born on?

Super easy.

Create a custom per particle attribute on the particle object, say birthFramePP ... then make a creation expression that looks like this.

particleShape1.birthFramePP = frame;

Set the particle type to numeric and put birthFramePP in the attributeName field and press play


05 May 2007, 12:24 AM
Ok, this must be the part I'm getting hung up on, because it keeps telling me that I Can not cast data of type float to float[] when I try to tell it something like float $blah[] = particle.blahPP. And even then, if I try it just float $blah = particle.blahPP, that will work, but if I try printing the results it tells me $blah has no assigned value.

So I think my issue is in making the attribute? I'm trying both just the userScalar1PP, and making a custom attribute, naming it and seeing it to per particle array, but I still don't see where to set the particle type necisarily or where to put in the attribute name, unless you're talking about the add attribute window still. Do you mean the particle render type, or am I just in the wrong place?

I think this is the biggest part I'm stuck on. Something where I need to define an attibute or a float as per a particle, but the thing I'm inputting in is saying it isn't a per a particle attribute, and thus I can have float[] =float.

Is this an attribute I need to add onto Flow_particle rather than Flow_particleShape?

05 May 2007, 01:05 AM
I guess the problem here lies in what you're actually trying to do. Why it needs to be assigned to an array variable is unclear? It's a per particle attribute, ...

The question is... What is it you're actually trying to do with this data?


05 May 2007, 08:46 AM
Ok, I think this is going to be a fairly long explination for something that seems like is should be pretty simple.

So I've mad a curve flow, and I want to control the speed of it. (I may want a lifespan to be shorter or longer than the travel distance of the curve in the end.)
Best I can figure, a curve flow is made by placing locators across a curve.
The translate values of each locator are plugged into the rgb values of a ramp.
The ramp is plugged into an array mapper, and the array mapper is run by the normalized age of the particles, and via that spits out which goal or locator to be attacted to as it goes down the ramp.

The problem is lifespan also = the length of the curve.

if you have a lifespan of 2(sec), on frame 15, you're 50% across the curve.
if you animate the lifespan up to 10 though, on frame 60 you're now only at 20% of the curve, and all the particles backtrack up the curve to be there, rather than just slow down.

This is all if you have lifespan mode to lifespanPP only over constant. The issue with constant is you don't get them back tracking, but once they're emited, they can never change their speed and speed is only changed at the birth of the particles (as far as I can tell anyway).

So, the plan was to reroute the age Normalized from the particle flow to the array mapper.
Rather than use just the age normalized I plan to figure out how many steps it takes to get across the ramp for that lifespan and constantly add that onto my own age normalized value.

In theory my test worked on a single sphere as far as controling the speed. I've been having trouble getting it to work in a per a particle method though. I'm pretty familiar with rigging but when it comes to things like arrays I'm on a bit of a learning curve for Dynamics.

So anyway, long explination aside, here's as far as I've gotten with the method, but I can't seem to make variables to suit an array and that's all the array mapper will seem to take. What I'm trying is I have to start off by deleting arrayMapper2 (asuming we're just going with default naming conventions) The only reason I'm doing that is because something about the way it's initialy built, even if I disconect the inputs to the array mapper, they're still running through the array mapper some how. Make a new array mapper node and rename it arrayMapper2 like the one you deleted. Then we'll reconnect all the attributes, save the ageNormalized input.

connectAttr -f Flow_position.message arrayMapper2.computeNode;

connectAttr -f Flow_position.outColor arrayMapper2.computeNodeColor;

connectAttr -f arrayMapper2.outColorPP Flow_particleShape.rampValues;

After that, on the flow_particleShape I'll add an attribute like you said. (for now I'm skipping dealing with the birthFramePP issue and just using 0 for now. I tried it with an inital state on the particles and it didn't make a difference like I expected it to. The only reason I had it was in my test with the sphere when using
if (frame == the frame we started on)
was the only way I could find to get the sphere to go back to where it started when I rewind the time slider.)

Anyway, like how you said to I'll make a per a particle attribute called currentAgePP

Then I'll add an expression to that attribute.

Under the creation tab I'll add this:

Flow_particleShape.currentAgePP= Flow_particleShape.ageNormalized;
//the theory originaly was to get the initial lifespan left on the particles if I have an initial state

Then, under the runtime before dynamics I've added something like this. locator1.slider is just a locator with an attribute I made to simulate the lifespan that was easier to work with in testing, Theoreticaly, it's the same as the lifespan:

float $timeStep = 1 / (locator1.slider * 30);
//takes the current lifespan, multiplies that into the number of frames for that lifespan

//then divides that number by 1 to figure out the amount of one step every frame.

float $reroutedAge[];

if (frame == 0)
$reroutedAge[] = Flow_particleShape.currentAgePP;

//if the current frame doesn't = 0, then rerouted age = the current age attriubte
$reroutedAge[] += $timeStep;

//otherwise rerouted age = rerouted age + the time step I've calculated

arrayMapper2.vCoordPP = $reroutedAge[];

So does any of this make sense? Basicaly the short version is I need a different formula for age normalized to run across that ramp to speed up and slow down the particles along my curve flow so they don't backtrack or overshoot where they are, but just simply change their speed. I have no idea if what I'm trying to do even works yet cause I can't get past the whole array issue yet of solving for each particle.

Anyway, let me know if you have any ideas there.

05 May 2007, 09:44 AM
Is there a way to do this all with nodes maybe? I was trying to run another array through the array for the curve flow. I was trying to use a ramp or a remap value node through the compute note using the age of the particles. But either I was just making the equivilant of age normalized on my own, or I couldn't get array values into the needed attributes.
It still seems like I need something that would take the current age normalized value and add onto it the current lifepan * the frame rate devided by 1 . As in:

(1/(lifespanPP*30))+previous frame age normalized.
And then something that can handle that formula in an array or per a particle format.

05 May 2007, 05:11 PM
Seems like you're going through a lot more work than you need perhaps... Its definitely not the 100% best solution as there is a money cost involved but you might want to look into the kickass FX plugin called Stroika.

Its got use of Curve Fields for many different purposes, 1 of which is a flow type effect that is more open ended than the Curve Flow. While curve flow is pretty nice you're kind of locked in to it based on the complexity of the expressions, so unless you know what you're doing this is going to begin to get pretty difficult.


05 May 2007, 10:23 PM
I've got the demo installed. Any advice on what all I should try off hand?

05 May 2007, 11:09 PM
I should take a step back and explain what it is I'm trying to make if I'm looking into software.
I need a tentical made up of bubbles is the effect I'm trying to go for. And idealy not just still bubbles, but bubbles that can slowly flow down the length of the tapper tentical, pop randomly around and float off randomly, and hopefully interact with each other in some way either via slow moving blobies or interparticle colisions. For the most part they should move slow but if a large part of the tentical pops, I want it to be able to fill back in quickly or depending on the creatures mood, bubbles would speed up or slow down.

I figure how ever I do it it has to be a layered effect.

I'm looking through these scene files now and looking to see how this would be helpful or not. But if I'm going back to square one as far as method, figured I'd explain what the final goal is.

CGTalk Moderation
05 May 2007, 11:09 PM
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.