PDA

View Full Version : Scattering groups evenly over a buckyball


Saschi0815
04-10-2011, 10:27 PM
Hi,

i want to scatter a group consisting several animated parts over a buckyball. The groups should be placed evenly in the middle of each polygon. MR Proxies don't work, any Scatter plugs don't work ...:argh: I think the only way to do this is using PFlow...
My first problem is that only a few parts(?) of the group are instanced over the ball, and my second how can i place the instances precisely perpendicular in the middle of each poly? Btw i used the position object with my shape instance, the speed by surface operator and a rotation op(speed space follow)...
So this seems to be a simple task, but nothing works the way i want:shrug:

Help is really appreciated, thank you:)

JohnnyRandom
04-12-2011, 03:14 AM
You can use a Birth Script and find the the center of each face using the polyOps getFaceCenter method.

You may have to break the groups so the script can properly iterate through a few different arrays (one for each animated shape).

I would then align the particles up-axis to the faces normal either inside the same script op or box#3 op.

There are already a couple of threads on this that may have some more in-depth information.

Saschi0815
04-12-2011, 09:09 AM
Thanks a lot Johnny, for your reply and advice. Sadly I'm not a scripter, but the hints you gave me are a good starting point learning some skript magic:beer: I will try my luck then...

Nevertheless what i don't understand is that the speed by surface op didn't work properly. On a simple geosphere with instancing a cylinder (pivot at the bottom) it didn't work like i think it should - pls look at att. pica...what's going wrong? I saw a tutorial from cgacademy concerning this and with max6 it works like a charm... Are there any issues with newer max versions? Btw i use max 2011 design...



http://www.malo24.de/test/cyls.jpg

http://www.malo24.de/test/pf.jpg

JohnnyRandom
04-12-2011, 06:22 PM
I suspect that you need to either use the current Rotation Op and adjust the y-axis +90 or adjust the objects pivot so the y-axis is the up-axis. That should fix what you are seeing.

I do not know if something in those regards has changed since max6, it is possible.

If you would like some really good tuts on scripting and pflow, Bobo has a couple of sets of extremely useful tutorials on CG-Academy (downloadable) (https://www.cg-academy.net/es_catalog/product_info.php?products_id=74&osCsid=g99fsrj4153vcjs6m6m76o7mp7k4heuh) at a very reasonable price. All of the examples (which have included scene files) have very practical applications that can span a pretty wide scope of uses.

Saschi0815
04-13-2011, 07:57 AM
Thanks again:wavey: Yes, it was the rotation of x and z, solved it with a xform mod - ok, now it's time to learn pflow - never thought it's easy, but i have to change my thinking about these particle things. :scream:

Thanks a lot, JohnnyRandom, for your advices and help, have a good time:beer:

Saschi0815
04-13-2011, 01:35 PM
Hi JohnnyRandom,

i found a script, funnily from you;) and i tried to adapt it for me and my little needs:

on ChannelsUsed pCont do
(
pCont.usePosition = true
pCont.useSpeed = true
)
on Init pCont do
(
)
on Proceed pCont do
(
for i in 1 to (polyop.getnumfaces $GeoSphere001) do
(
pCont.AddParticle()
pCont.particleIndex = pCont.NumParticles()
pCont.particleAge = 0
pCont.particlePosition = (polyop.getfacecenter $GeoSphere001 i)
)
)
on Release pCont do
(
)

Sadly, it doesen't work in the way i expect. It generates the instances, but not in the middle...Any hints?

Pls accept my apologies for copying most of it, but times are short and i have to deliver some results:hmm:
Learning maxscript in one day is too much for my little head:wip:

JohnnyRandom
04-13-2011, 06:09 PM
np, that is why it is there :)

The only caveat is your birth object needs to be an Editable Poly since the script is calling a polyOp method. If it were calling meshOp method your birth object would need to be an Editable Mesh.

Since there is no Time condition in that snippet it will add new particles every integration step, you can easily tell the operator when to born particles by adding a if/then statement.

A little bit cleaner way to write it would be something like this. There is only one instance of the node $Geosphere01 and it is now in a global variable, if you change the birth object you only have to replace a single instance of code:


on ChannelsUsed pCont do
(
pCont.usePosition = true
)
on Init pCont do
(
global theBirthObj = $GeoSphere01 --your birth object it needs to be editable poly
)
on Proceed pCont do
(
t1 = pCont.getTimeStart() as float
if t1 < 0 then --born particles at less frame 0
(
for i in 1 to (polyop.getnumfaces theBirthObj) do--add a particle for every face
(
pCont.AddParticle()--add a new particle
pCont.particleIndex = pCont.NumParticles()--set the index to the count
pCont.particleAge = 0--set the age to 0
pCont.particlePosition = (polyop.getfacecenter theBirthObj i)--match to the poly of the same id
)
)
)
on Release pCont do()



You can do rotations too but it is a bit more difficult, you need to create and build a matrix and grab the matching face normal and the current particles rotation do some magic(or voodoo) and plug it into the rotationPart. Then use the particleTM channel to assign it. It is a PITA to script, I always use a Box#3 operator.

That is a Bobo job for sure, he understands rotations/TMs/quats and scripting exponentially better than I do. :)

Saschi0815
04-14-2011, 02:54 PM
Thank you :)

The geosphere is a ePoly. I tried it with other shapes like a normal sphere, a cube
etc. - always the same. The cyls will be scattered over the object, but not in the center of each poly:cry:

What's going on?

http://www.malo24.de/test/pf2.jpg

JohnnyRandom
04-14-2011, 08:16 PM
You don't have any operators that influence position at birth in the birth event do you? ie a Position Icon/Object operator.

You won't need any since you are controlling position in the script operator.

Saschi0815
04-15-2011, 02:54 PM
That's really logical and i ... i forgot disabling it ,ahh, call me amateur:wip:
Thanks a lot, Johnny, you really helped me:applause:

have a good time, cu:beer:

JohnnyRandom
04-15-2011, 05:39 PM
np Sascha

i ... i forgot disabling it
we have all do/done that :)

CGTalk Moderation
04-15-2011, 05:39 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.