How to convert Particles to Objects?


#1

Hello,

I want to export a particle system with its animation. Therefore I want to convert the particle system to several animated objects, so every particle should be an object with animation. Is that possible? With Mesher it is not possible because Mesher generates a single object with elements in it as particles. Otherwise, I could think of constraining several objects to the particles and converting the constraint to keyframes.

Please help! Thanks. :slight_smile:


#2

i believe Bobo had a script @ www.scriptspot.com/bob that didnt something similar, but i’m not sure if it bakes anim.


#3

i think bobo’s done a particle snapshot for pflow, and a birth script that will convert scene objects as a pflow system. But im not sure if there’s anything to extract individual objects with animation. Anyone?


#4

so wait… why can’t you use mesher? just convert the mesher to an editable mesh, and then copy out the elements into new objects. if you have a LOT of particles this will be time consuming but if you just have a few…


#5

Thanks for your answers!

@ gavinb:
The link doesn’t work. I also didn’t find the script on scriptspot.com. Could you please tell me the name of the script or give me the correct link?

@ Largo39:
This method will not work properly, because the animation is lost when you convert mesher to an editable mesh or editable poly. Futhermore, the orientations of the particles are lost when you detach the elements.

Is there any other method? I can’t believe there is no way to do that…

I think there must be a way to constrain objects to particles… but how? All methods I know will generate one single object with elements as particles in it (Mesher, Blob Mesh, Shape Instance). Is there no way to get an object for each particle?


#6

I believe its in http://www.scriptspot.com/bobo/
under Scripting Custom Chunks - The Basics

basically what it does is…

  1. you create your prefractured chunks, or elements of objects (usually from pArray-mesher-editable mesh-detach elements)
  2. create a pflow with a birthscript (care of master bobo) where:
    • each particle gets aligned to an array of objects
    • particles uses those objects to get geometry data from
  3. now you can apply any pflow operator to those particles whose geometry information is from your prefractured objects.

i hope this helps! (or for the least, i hope i understood your problem correctly)
:slight_smile:


#7

I think that there must be a way to constrain objects to particles… but how?

isn’t that the opposite of what you are trying to do?
if I understand correctly you can let each object follow a particle like in a fracture or something with a bit of pflow scripting. but what kind of particle system is it?
and apparently gavin missed the other ‘o’ he’s bobo not bob… the link is:
http://www.scriptspot.com/bobo/


#8

i did indeed miss the o

but the tut on there i refer to is http://www.scriptspot.com/bobo/mxs5/pflow/pflow__snapshot_as_mesh.htm


#9

Thanks for your replies, but the script does not do the thing I need. I also don’t understand why Bobo says that Mesher does not create an Editable Mesh from the particle system. You can do so when you just convert Mesher to an Editable Mesh. Nothing else does the script from Bobo, or do I understand something wrong?

What I want:
I need a technique to align or constrain several objects to each particle of a particle system OR a technique to create several objects from particles. I don’t want to have a mesh or snapshot of the particle system with only one single object and without animation. I want to grab the positions and orientations (full animation) of all particles of a particle system (doesn’t matter which one) and convert them to several objects, so each particle will become an animated object.

I hope you did understand me now and I also hope there is a solution for this.


#10

you need his other script “particle motion transfer to scene objects”
but you need to change a bit in the code in this example he uses atmospheric gizmos
the link
http://www.scriptspot.com/bobo/mxs5/pflow/pflow__MovingObjects.htm


#11

Thank you very much. I’ll try it… :slight_smile:


#12

I also don’t understand why Bobo says that Mesher does not create an Editable Mesh from the particle system.

Bobo is refering to a particle ‘snapshot’ ie a single object at that particular time converted into a mesh object. Mesher is a compound object that collapses the mesh animation related to a particle system. If you delete the particle flow/system, the mesher shows the big doughnut.

Ive used this script in the past for doing things like laying out thousands of leaves on the pavements in a town. I use Pflow to genrate a random arrangment quickly, and then collapse to the mesh for speed (although i could have just left it)

I’ve also done it when i used Pflow to place bricks around a curved path. Once Pflow had postioned it, i “meshed” the object with bobo’s script.


#13

I tried Bobo’s script and rewrote it so that it also works with standard objects. In max it works well, but I still cannot export the animation data. When I export the objects with FBX (which normally converts almost everything), the animation is lost after importing the file again. When I collapse the trajectory of the objects and delete the particle system, there is also no animation any more. I also tried to create another object and linked it to one of the particle objects (with position and orientation constraint) and then I collapsed it, no change.
So it doesn’t help me unfortunately. Perhaps someone has a trick?


#14

I havent tried this yet, but i recall that realflow3 also has this exporter that can export objects with animations… you myt want to give it a try. they hav a free evaulation version on thier site. hope this helps!:slight_smile:


#15

umm… I can’t remember how, but I got the trajectories of particles once, its really interesting because you can experiment and begin building interesting spline shapes which can then be converted to have thickness. Maybe that’s a starting point. I wish I knew how I did it, possibly mesher or snapshot had something to do with it.


#16

this is a brain teaser.
if you right click on the newly animated objects > properties > Show Trajectories
nothing is there so I have no idea how to bake this animation…


#17

This is rather easy and does not even require a scripted operator.
Basically you write a short for loop (actually two) very similar to the trick I used for the Atmospheric Gizmos, but the outer loop goes through the frames.
Then, on every frame (or every nth frame if you want), you go through all your particles currently in the system, read their Transformation and With Animate On () assign to the corresponding scene object, creating an animation key for it.

This BAKES all particle animations into the scene objects. The examples on my page were mostly about DRIVING objects. In those examples, removing the PFlow would kill the animation. You just need explicit keyframes for position, rotation ans scale.

We used this on Scooby Doo 2 to get particles emited from particles - we exploded the Tar Monster into approx. 300 chunks, animated with collisions etc. using PFlow, then baked to keyframes (so we could also tweak the result by hand if needed), and assigned all the chunks as emitters again, emitting small debris while moving away from each-other…

See the upper left screenshot here:

Hope this helps.


#18

Thank you very much for you reply, Bobo, and the others, too.

I am a noob to MaxScript so I don’t know where I have to insert the line “Animate On ()”… It was easy to modify your script so it works with standard objects. I only had to change the name “AtmosphericGizmo” to the name of the standard object and I just removed the line which causes the scaling of the gizmos.

So my question is:

Is it possible for me (MaxScript-noob) to modify your script so I get a baked animation or do I have to learn a little bit about MaxScript first? Or would it be enough reading your explanation for your script?

Otherwise, is there a chance that you would edit the script for me? I would be very thankful.


#19
I didn't know you could do that. you mean with a script from outside pflow or in max listener?
do I access the particles or the driven object? I don't know how to access particles from outside...
I"M TOO OLD FOR THIS.

I tried manually setting a keyframe at diferent frames on one object then deleting the pfsourse but that didn’t work. (but without autokey I’ll try it w/autokey since you mentioned animate on()

Edit: now thats weird! just by pressing auto key and playing the animation once it worked thus putting a key at each frame!!

another edit: No not really you have to advance manually throught the frames one by one which justifies the need for a script like bobo said unless the animation is 30 frames for example.


#20

*Create a simple default PFlow (add a Cache if you want to speed things up)
*Create a Box primitive
*Clone the Box 100 times
*Main Menu > MAXScript > New Script

Paste the following code into the new script editor:

theSystem = $PF_Source_01 --this is the default PFlow source
theArray = $Box* as array --this is the array of boxes you created
for t = animationRange.start to animationRange.end do --loop through animation segment
(
	sliderTime = t --set the slider time to the time value
	theCount = theSystem.numParticles() --get the number of particles in the whole flow
	for p = 1 to theCount do --loop through all the particles
	(
		theSystem.particleIndex = p --set the p-th particle as active
    	if p <= theArray.count do  --if the particle index is less than the number of boxes,
    		with animate on theArray[p].transform = theSystem.particleTM --set the transformation of the p-th box to the matrix of the p-th particle
	)--end p loop
)--end t loop

*Press Ctrl+E and watch the boxes following the particles.
Then you can delete the PFlow and the boxes will still be animated and exportable.

There is a small caveat - the initial position of the boxes will also get animated to their first particle-defined position. As new particles are born, new boxes will move to the location the particle is born.

If the animation is created with a constant number of particles born on frame 0, this would not be an issue. Otherwise, the script would require the visibility of the boxes to also be animated to hide this additional motion…

But I hope you get the idea…