'I Have to Plant a Hell of a Lot of XYZ'

We all know that there is the scatter tool...But how about using PFlow and enjoying the luxury of fast interaction (exchanging shapes, materials, etc.)? This tutorial deals with Particle Flow in 3D Studio MAX in connection with a little MAX Scripting.

You will need 3D Studio Max ( Version 5.1 upwards) and a MaxScript.

44.000 stadium chairs with 4 different materials

44.000 stadium chairs with 4 different materials

First of all create a Particle System in ParticleView (Graph Editor > Particle >View, or Shortcut "6").

From the "Depot" in the lower third of the window just drag a Standard Flow in the window.

(Just in case your Depot isn't showing click "Display" and check "Depot")



Definitely not the funkiest Flow but very efficient!

So what does it do in brief?

A BirthScript plants one particle per vertex at a polygonal object. Then we tell particle flow how it should look like by defining the shape, the scale and the shader. In most cases you may want that the planted objects look into a certain direction so I added a kinda look at constrain workaround.

Before we start to build the entire flow we need to draw splines representing guides where you want to plant objects on. Keep in mind to turn the interpolation steps of each spline to 0 otherwise you'll end up with a damn lot of vertices! ;)

Now add a Normalize Spline modifier from the Modifier List.

Right Click all of your splines and check Vertex Ticks in the Display Properties. Now you can see every vertex on the spline. The spacing between every vertex is set by the Segment Length of the Normalize Spline modifier, that's why we need it!

Now convert your spline into an edit poly by right clicking it and using the Convert To operation. NOW you if you didn't set the interpolation steps to 0 you will have a lot of vertecies. We don't want that! The interpolation steps insert the amount of steps into each space...

Let's get back to the flow... ;)

At first we need to add a birth script node to replace the birth node already existing. Copy / Paste this script:

on ChannelsUsed pCont do
(
pCont.useposition = true
)
on Init pCont do
(
global pflowguide = $guide
)
on Proceed pCont do
(
if pflowguide != undefined do
(
t = pCont.getTimeStart() as float
NumVerts = getNumVerts pflowguide
if t < 0 do
(
for i = 1 to NumVerts do
(
pCont.AddParticle()
pCont.particleIndex = pCont.NumParticles()
pCont.particleposition = polyop.getVert pflowguide i
)
)
)
)
on Release pCont do ()

Replace the "§guide" with the name of your guides leaving the leading §-sign.

Short explanation: The script cycles through the vertecies of the mesh (§guide) and plants a particle at every vertex.

Replace the Shape node with a Shape Instance and pick the object you want to plant onto the guides we just created. In my case stadium chairs.

I added a Scale node as well to have full control about the scaling within particle flow. Maybe you want a more random scaling then you should increase the scale variation e.g.

TIP: Set the Display operator to "BoundingBox" so that you can see the actual direction without the need of calculating the entire geometry instances
 



If we want the shape instances to have different materials in a certain manner we should add a Material static node. If you don't add this node all particles will have the material assigned to the shape picked in the shape instance.

In my case I only wanted every fourth chair to have the same material so I picked a Multi/Sub Material with four submaterials in the material static node. I checked Assign Material ID and Show in Viewport to have visual response in the viewport. Because I wanted to the materials to cycle I selected cycle and entered 4 in the sub-materials type in. You should position the node UNDER the shape instance node other wise an applied material to the shape instance master will override your material static!

Just in case you want the particles to look into a certain direction you should add a find target node under the birth script. In my case I modelled a proxy all particles have to look at.

Use the settings I used. The very low speed is important here! Because we don't want the particles to move around. I checked Mesh Object and picked my proxy then.

Now every particle want's to fly to the proxy but is to damn slow ;-p

Fig.

Fig.

Drag a rotation node under the find target and set it to Speed Space Follow. That makes our LookAt workaround happen! Because the particles have a dramatic low speed they ONLY turn into the proxies direction without moving.

NOTE! The particle shape instances will only turn towards the find target from frame 1 on because they need to be "triggered". In frame 0 they will all look into the initial direction.

Final Trick: If you're happy with the result move the particle flow icon to 0,0,0 to the grid centre (that would't have any effect on your particles!). Now use a Mesh Compound Object (as well located at 0,0,0 grid centre) and pick your particle system. That converts the particles into editable polygons which can be modified just like other mesh objects. WARNING! Maybe that step might kill your max if you haven't enough RAM and will take some time to calculate!!

Now you can collapse the Mesh Compound Object into an editable poly and work with it as usual.

You can download the script as well as an assembly file from my website:

http://core2core.de/spielwiese/research/particle_per_vertex.ms < the max script
http://core2core.de/spielwiese/research/Stadion_bestuhlung_R&D;_eng.max < the max file

Fetching comments...

Post a comment