Particle Flow Discussion


#581

Originally posted by The_Magician
[B]mmmm, nice Bobo.

How do you get particles to read an animation curve?

Like, for a basic example, lets say that there’s a trail of particles being left behind a moving particle, and we want those that are spawned to have a life of… 30 frames, variation 15.

How can you get these spawned particles to read the curve of the shape they are being instanced off? Also, seeing as these particles may have a longer or shorter lifespan then the total animation time fo the instanced shape (due to the 15 variations), is it possable to have the animation time scale itself to fit the life of the particle?

I know you can just tick “Animated Shape” in the shape instance operator, that just reads the curve of the initial shape. [/B]

This is easy (but you have to assign the mesh instance “by hand” in a script):

*Create a Cylinder01 with height 10 and radius 1, Height Segs 16, Sides 6.
*Add a Bend modifier and animate the Angle on frame 29 to 360 degrees (this gives you a donut on frame 29!)
*Create a default Particle Flow, delete the Rotation operator
*Add a Delete operator after the Speed Operator. Set to “By Particle Age” and Life Span 20, Variation 10
*AFTER the Delete Operator, add a Script Operator

Enter the following script:

on ChannelsUsed pCont do
(
pCont.useAge = true
pCont.useLifeSpan = true
pCont.useShape = true
)

on Init pCont do ()

on Proceed pCont do
(
count = pCont.NumParticles()
for i in 1 to count do
(
pCont.particleIndex = i
at time (30.0*pCont.particleAge.frame/pCont.ParticleLifespan.frame) pCont.particleShape = $Cylinder01.mesh
)
)

on Release pCont do ()

This code takes the age, the expected life span and calculates a normalized time (0.0-1.0). Multiplied by the length of the shape animation (30.0 frames) gives you the source time to extract the mesh from the cylinder.

Now if you play the animation, you will see that any particle that reaches the “donut” state (frame 29 of the cylinder) will be automatically dead within the next frame! (Similarities to the movie “The Ring” are completely intentional :))

This proves that the particles, no matter how long they live, always acquire the right shape from the 30 frames cylinder animation!

Even better - since the result of the time calculation is a floating - point number, we are actually subsampling the cylinder’s animation. To prove this, slide the key from frame 29 to frame 1.
Now you have a Bend between frames 0 and 1 only.

Open the script and change the “30.0” to “2.0”:

at time (2.0*pCont.particleAge.frame/pCont.ParticleLifespan.frame) pCont.particleShape = $Cylinder01.mesh

Play back the animation - you will notice that eventhough the cylinder is animated on two frames only, the particles will grab as many sub-samples as necessary to give you 20, 30 or whatever frames of shape animation!

Cool, eh? :cool:

Cheers,
Bobo


#582

All right! Kick ass script there Bobo!

Now, for the next step… Getting the instanced shape to be from a list of multiple shapes.

So, I’ve got like… 10 different shapes. Is there a way to have PF randomly pick one of those 6, and use it for a particular particle, then it would randomly pick another one and use it for its particle, and so on and so forth. This way you would only need 1 position object operator and only one flow, instead of x amount of spawns going to different things for the shape variations.

(If your wondering, I’m trying to grow a garden here, and the shpare I’m trying to have fun with arte the plants and flowers.)


#583

Actually on CD #3 with max 6 theres a perfect example for that garden thing your wanting to do. The directory is :\Version6Features\Scenes\Particle Flow\Spawning Flowers. Although I don’t think they use any scripting.


#584

treed: Yeah, I took a look at that one. But if you lok at it, each flower is exactly the same, just given a random rotation. Its fine for that one, because the flower heads are all facing directly up. My ones cant do that, because mine flower heads are facing more forwards, and I need them all to be facing the same direction.
If I use the same flower all the time, then the stems are all exactly the same, and it doesn’t look all that good.


#585

-----------> The_Magician

it is possible just use a shaper instance.

  1. group your objects.

  2. assign a shape instance opereater to your pflow

3.pick your group as the particle geometry object.

  1. under Seperater particles for pick group members and set it to pick (multi-shape random order)

and there u go;)

here is a very very basic scene


#586

Allan, great mov! I like how the particles keep falling after impact, like the object is ‘crumbling’. Is that script going to break up a mesh in shatters proceduraly? That would be very usefull even without your PFlow crash system (which is very impressive). I know a lot of people who have a hard time cutting mesh up for dynamics solutions. Doing it by running a script would be very cool!

Bobo, very cool steam! I was wondering if it would be possible to link volumetric helpers to particles ever since I saw that one guy do it with lights. Seeing Afterburn and ParticleCombustion I knew it would have to be possible, I just didn’'t have time to dive into scripting just yet. Your stuff is very inspirational, so I hope to make that big leap soon. This stuff is great for steam, rocket smoke, moving clouds, etc. Makes you wonder why we can only instance mesh and not other objects like lights, cameras, dummies and volumetric helpers.

The_Magician, I think you can have the Instance Shape operator spawn mesh and it’s childeren in random order. So you’d have to link the other possible meshes to the mesh that’s instanced and amend the parameters in the operator.


#587

So, I’ve got like… 10 different shapes. Is there a way to have PF randomly pick one of those 6, and use it for a particular particle, then it would randomly pick another one and use it for its particle, and so on and so forth.This way you would only need 1 position object operator and only one flow, instead of x amount of spawns going to different things for the shape variations.

Let me try this one :wink:


on Proceed pCont do 
(
	count = pCont.NumParticles()
	for i in 1 to count do
	(
		objarr = #($Box01,$Cylinder01,$Torus01,$Teapot01,$Sphere01,$Cone01) -- Here goes all your objects
		a = pCont.particleID
		while a > objarr.count do (a /= 2)
		pCont.particleIndex = i
		at time (30.0*pCont.particleAge.frame/pCont.ParticleLifespan.frame) pCont.particleShape = objarr[a].mesh
	)
)

(If all your objects have the same name, you could use objarr = $YourObjName* as array)

This might not be the best way to do this, but it works :thumbsup: This is Bobos script, just some minor changes.


#588

Originally posted by The_Magician
[B]All right! Kick ass script there Bobo!

Now, for the next step… Getting the instanced shape to be from a list of multiple shapes.

So, I’ve got like… 10 different shapes. Is there a way to have PF randomly pick one of those 6, and use it for a particular particle, then it would randomly pick another one and use it for its particle, and so on and so forth. This way you would only need 1 position object operator and only one flow, instead of x amount of spawns going to different things for the shape variations.

(If your wondering, I’m trying to grow a garden here, and the shpare I’m trying to have fun with arte the plants and flowers.) [/B]

This is rather trivial. The only thing you need is a random seed (to always get the same random distribution and no flowers jumping from particle to particle), and an array of source meshes.

I will put a tutorial together based on the previous script and will add the random shape code to it so you can try it with your garden…

Cheers,
Bobo


#589

Originally posted by Bobo
[B]This is rather trivial. The only thing you need is a random seed (to always get the same random distribution and no flowers jumping from particle to particle), and an array of source meshes.

I will put a tutorial together based on the previous script and will add the random shape code to it so you can try it with your garden…

Cheers,
Bobo [/B]

Here are some spring gardening tests with a slightly improved script:

*I created a Box, a Cone and a Pyramid primitive.

*Animated using various simple modifiers like Bend, Wave and Squeeze to have some basic geometry to test with. All animations were 30 frames long

*The script allows the user to define an arbitrary number of source “flowers” and specify the amount of each in relative units plus the actual growth animation length in frames

*Then the script creates particles that have a random growing time (independent of the source animation, in this case between 5 and 40 frames). Also, each particle is assigned at birth time an integer pointing at the corresponding source mesh. The distribution of the “flowers” is based on the values mentioned in the beginning - the current test had 10% boxes, 20% Cones and 70% Pyramids. These values can be adjusted for different amounts and looks. The sum of the values must not necessarily be 100, but it is easier to understand when it is.

*I used the FLoat and Integer channels to store some data - the Float channel contains the desired growth time length of each particle, the integer channel stores the selected mesh index. This way, I am processing particles only at birth (Age=0) and never after that which makes the script much faster. (In my initial tests I had to assign the values on the fly all the time using a unique seed and it was much slower).

*After the script, I placed Scale and Rotation operators to get some more random look.

*To get the Spring Feeling inside, I set the Position Object operator to Selected Faces/Animated shape and used a VolumeSelect to define a growing selection that emits particles gradually along the surface. The map control can be used to get things like circular animated growth etc. I used a Gradient Ramp and just switched the mode:

Here is a MAX 5.1 file to play with:

http://www.scriptspot.com/bobo/mxs5/pflow/PF_GardenGrowing_ByMap04.max

Cheers,

Bobo


#590

Originally posted by Bobo
Here are some spring gardening tests …

And here a Summer test - a Ball interacting with grass in the brutal way (I am sure someone somewhere asked for this already)…


(QuickTime, 15MB)

Enjoy!

Cheers,
Bobo


#591

Now that was majorly cool Bobo! I’ve always wanted to get time to get my grass that dynamic :slight_smile: Maybe one day I will. Now Im stuck with Java programming sigh :slight_smile:


#592

I ran across a site and immediately thought of this thread. It’s various video footage (high speed) of…well, all kinds of things. A firecracker blowing up a marshmallow, cigarette smoke, an ice cube shattered by a hammer, etc…

http://www.engr.colostate.edu/~dga/high_speed_video/

Apologies if this has been posted before. If it has, just let me know and I will delete this post.

Jeff


#593

Wow, thats incredible stuff. Thanks a lot for think Jeff. :slight_smile:


#594

Originally posted by Bobo
[B]http://www.scriptspot.com/bobo/mxs5/pflow/PF_SphereGrassInteraction_02.mov
(QuickTime, 15MB)

Enjoy!

Cheers,
Bobo [/B]

sweet!, any chance of havin a look at the .max file?
again great work!!

|jason


#595

The example :\Version6Features\Scenes\Particle Flow\Spawning Flowers was done by myself. Its actually meant to show how you can use a texture to decide whether a flower will grow from a seed or not, in this case the ground was meant to maybe be broken up concrete and earth.

A number of interesting techniques can be derived from that example. All its doing is scattering the flowers and when they come to rest they are passed to a new event that derives their speed based on the surface they are on. That surface is textured and they use this texture to controll the magnitude of that speed.

Then a test is used, particle on white areas get a tiny amount of speed and go on to grow flowers (and their speed is set to zero).

Seeds with no speed go on to a new event where they do nothing (and their speed is set to zero).

Well… using this technique and scripting you could do much more complex things i.e. test for various levels of speed. like this…

speed < .001 = dead seeds
speed >.001 but < .01 = daisies
speed >.01 but < .05 = Tulips
speed> .05 but < 1.0 = SunFlowers

or even have each section have a ratio i.e.

speed < .001 = dead seeds
speed >.001 but < .01 = 75% daisies, 25% Tulips
speed >.01 but < .05 = 75% Tulips, 25% daises
speed> .05 but < 1.0 = 75% SunFlowers, 25% Tulips

So that your areas of flowers are nicely broken up. This way you could paint a nice control map for your scene with shades of grey controlling the relative densities of flower types.

Damn Pflow is cool eh! :slight_smile:


#596

Can anyone help me out there…I’m trying to achieve a fairly realistic exhaust from a jet engine with all the fire and smoke, but I don’t really come up with any good results…so how can I achieve this…I’m sure you all are capable of doing that and can help me
thanks


#597

How much do u pay for this?

8D


#598

…bobo?

I had a try on the instanced animation using the at time aproach.
I wanted to know if you think we could use it to sample animated material properties like the flags of a gradient or other parts.

if it is possible then we could make much more non linear effects for dust, fire and sparks which will look unique no metter what.

using the builtin aproach of an animated clip striped since the birth of the particle is not as elegent…

worth a try.


#599

Brainmeester, yeah two scripts, one fragments it and assigns the pieces to a particle each, the second will shatter it.
All of that is relatively easy to set up with operators, although wanted to go about this 100% with code. Haven’t had time to use pflow much as I’m doing a lot of non particle related stuff right now, and when I do use particles a majority is TP stuff.

I just spent a chunk of my weekend writing my own GUI outside of TP though so I can work with TP without necessarily “working with it” :slight_smile: Which is speeding up my workflow to an extent.

There’s so much stuff happening on the forums but no time to really read any of it right now :\ going to have to archive it all and play catch up one night this week - bobo’s doing a nice job with all this scripting stuff, go bobo!

Was meant to finalize my DVD stuff down at NAB, although last minute plans changed so anyway sooner I get that signed over the sooner I can start telling people it’s ready to be shipped :slight_smile:
Will buy a pc soon and start churning out some more vid tuts, maybe some on TP too as I’m starting to get pretty heavy into it now.

Cheers,

Allan


#600

Sorry, I didn’t read the whole 40 like pages; maybe someone already answered this one:

>So, I’ve got like… 10 different shapes. Is there a way to have PF randomly pick one of those 6, and use it for a particular particle, then it would randomly pick another one and use it for its particle, and so on and so forth.This way you would only need 1 position object operator and only one flow, instead of x amount of spawns going to different things for the shape variations.<

I don’t see a reason to use scripts for this situation. Shape Instance operator is able to use group members as particles. You can create a new group with all your 10 different shapes, turn On Group Members check box, and turn On Multi-Shape Random Order check box. And that’s it! Not scripts whatsoever.

Thanks,
Oleg B.

The Particle Caregiver