PDA

View Full Version : one particle per vertex


cani
10-11-2008, 05:06 PM
Hi to you Pflow addicts!
Here's a little question which has been bugging me for a while:

How can I assign only ONE particle to each vertex of my distribution object?

I'm not sure the answer is in the position operator as I've tried a lot of things without success. The main problem I have when I set the position operator to position my meshes at the selected vertices is that I do not have particles generated everywhere.

Why that?

The number of particles generated in the birth event is set to the same number as the vertex of my distribution object. But I end up with a lot of vertex with no assigned particles!
If I boost the number of particles generated, I can get at least one particle per vertex but I end up having problems because many vertex have multiple particles assigned to them. It then creates mesh collision problems and would look nasty in the rendering...

How can I achieve this effect?

I know there's other way of placing meshes at an other object's vertex (like compound scatter or object placer script) but these way do not let me use multiple meshes to be scatteredlike Pflow does...

Please help me with that!
I've posted an other thread in the autodesk 3ds max forum where I explained exactly what I wanted to achieve but as I get no answer, I'm desparatly trying here..

Bercon
10-11-2008, 06:41 PM
There was Position Object+ object which Oleg made avaiable for free, it was to solve exactly this problem.

Its pretty simple to script this with Script Operator.

for i in 1 to pCont.count() do (
pCont.particleIndex = i
if pCont.particleNew then
pCont.particlePosition = getVert $'objectName' i
)

Or something like that, I don't have max here so I don't remember the exact syntax.

JonathanFreisler
10-12-2008, 03:06 AM
Lets say you have a distribution object with 500 verts, so you generate 500 particles and assign them to verts. All 500 particles are being born, but basically there overlapping each other to give the appearance of less. Thats whats happening anyway.

You can try to fudge it by putting a keep apart to try and separate them from birth. Or as bercon said, that script works a treat.

cani
10-12-2008, 11:55 PM
Thanks Bercon you put me on the track and I've found two scripts that might do the job on orbaz forum:
the first one to asign a particle to every vertex of an object:
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 ()

and this one to assign a particle to every selected vertices:

on ChannelsUsed pCont do
(
pCont.usePosition = true
)

on Init pCont do
(
global obj=$'Sphere01' --object with selected verts
)

on Proceed pCont do
(
t1 = pCont.getTimeStart() as float

if (t1<0 and classOf obj==Editable_Poly or classOf obj==Editable_Mesh) then (

for i in obj.selectedVerts do
(
pCont.AddParticle()
pCont.particleIndex = pCont.NumParticles() -- last particle that was added
pCont.particlePosition = i.pos
)
)
)

on Release pCont do
(
)

but i'm not used to scripting so I do not understand very well the script. When I try to make it work, no particles are emitted at all!
I've copied and pasted the first script in the operator and after that I do not know what to do...
I'm pretty sure it is something with $guide but I have no idea what to write (probably the distribution object's name) and how to write it...

In the second script, I thought it would be easier but I didn't have more success.. I created a sphere with the exact same name to see if it would work but again, no particles are created...

Can you give me some advices?
I have no scripting knowledge at all....

Wicked
10-13-2008, 01:07 PM
I tested it here and it works fine. Did you paste the code in your Birth Script? That should do the trick.

on ChannelsUsed pCont do
(
pCont.usePosition = true
)

on Init pCont do
(
global obj=$'Sphere01' --object with selected verts
)

on Proceed pCont do
(
t1 = pCont.getTimeStart() as float

if (t1<0 and classOf obj==Editable_Poly or classOf obj==Editable_Mesh) then (

for i in obj.selectedVerts do
(
pCont.AddParticle()
pCont.particleIndex = pCont.NumParticles() -- last particle that was added
pCont.particlePosition = i.pos
)
)
)

on Release pCont do
(
)

Make sure you have the names right:

Sphere01 was the object I was using for testing purposes, should be name of the object you are wanting to use.

http://www.orbaz.com/forum/viewtopic.php?p=8266#8266

cani
10-13-2008, 05:31 PM
Okay guys I've found out why it would not work.............
I forgot to convert my test base object to editable poly :rolleyes:
but now it works fine!
Altought, if you don't mind, I have some more questions! (yeah I always have some of those...)
In the operator stack, I put shape instance and I instance a few objects. But they are all distributed in the same patern.

by example:
I use a sphere as test distribution object and I scatter a cylinder, an other sphere and a cone on it. you can then notice that this patern is popping out : a cone, a sphere, a cylinder, a cone, a sphere, a cylinder, etc..

Is there a way to easily create some randomness in there?

Is it in the script?

or may be could it be in the shape instance or an other operator?
I know that position object randomly assign particle but it is pretty clear that I can't use it in this sutation.

And finaly, Is max script a hard to learn language for someone who does not have a lot of programming knowledge except some visual basic, html and css base?

again thank you for the precious help you give to me!

JonathanFreisler
10-13-2008, 11:20 PM
in shape instance, 'multi-shape random order' will do it.

cani
10-13-2008, 11:42 PM
woa nice guys! thank you a lot for your help!
you've saved me hours of lost time!

CGTalk Moderation
10-13-2008, 11:42 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.