PDA

View Full Version : getting neighbor particles?


Masquerade
03-29-2010, 09:30 PM
Hi everyone,

I am trying to find a way to test the neighbor particles of a particle. I guess the easiest way is script test operator, but couldnt find the way how to do it.

I am spawning random particles from an event. with a %0.1 spawnable ratio. But instead of the single particles from the large particle cloud, I want to collect neighboring particles also. For example, in addition to the particles which just spawned, I want to send every particle within the 2 units radius of the spawned particle to the next event.

I will be glad if someone at least point me the right direction.

Thanks in advance.

noouch
03-30-2010, 02:47 PM
Pretty sure you'll need either a script test or pf tools box 3 for this.

AFAIK getting neighbors of a particle will be pretty slow for large particle counts unless you start structuring the data so that you can easily omit particles that are not likely to be within a given radius. There is an entire branch of computer science dedicated to stuff like this, and maybe someone here can provide a quick and simple method.

If you choose to go the brute force route, what you have to do is test each particle against all the others, testing for age, and distance by way of length(particle1.pos - particle2.pos).

OlegB
03-30-2010, 03:24 PM
unless you start structuring the data
Box#3 does that for you with no sweat :)

Thanks,
Oleg B.

JohnnyRandom
03-30-2010, 04:07 PM
Well I considering I have had this question running around in the back of my mind since you posted it, I can't think of an efficient way to do it via script (not to say by any means that it can't be done, I am sure someone more proficient than myself could come up with a solid solution)

Box#3 is the only thing that comes to mind, in fact the Particles sub-op already has this specific function built in ;)

Masquerade
03-31-2010, 07:59 AM
noouch;

actually I have written something like that after posting the question, but since the reasons you have already mentioned, it is TOO slow. Here is the code. if someone is interested.

--********************************************************************


on ChannelsUsed pCont do
(
--pCont.useTime = true
pCont.usePosition = true
pCont.useAge = true

)

on Init pCont do
(
global spwArray = #()
global flag = 0
global randomNum
)

on Proceed pCont do
(
randomNum = random 1.0 3.0
count = pCont.NumParticles()
for j in 1 to count do
(
pCont.particleIndex = j
if pCont.particleAge < 1 then
(append spwArray pCont.particlePosition)
)
for i in 1 to count do
(
pCont.particleIndex = i

for x = 1 to spwArray.count do
(
if (distance pCont.particlePosition spwArray[x]) < randomNum then
(
pCont.particleTestStatus = true
)
)

)
)

on Release pCont do
(

)

Actually, I am not a coder, and I am pretty sure that it can be improved somehow.

OlegB,

I do not own Box#3, but in my previous company I had chance to play with it a little. From my point of view, it looks like its harder than writing the scripted nodes :). Maybe I didnt tried hard enough but I couldnt get the general working principle. Anyway, I dont own the plug-in right now, but the words "no sweat" makes me think maybe I should have tried harder. :)

Masquerade
03-31-2010, 08:04 AM
JohnnyRandom,

Box#3 is the only thing that comes to mind, in fact the Particles sub-op already has this specific function built in ;)

Somehow I didnt see your post earlier, thanks for pointing that out

SoLiTuDe
04-01-2010, 12:59 AM
I do not own Box#3, but in my previous company I had chance to play with it a little. From my point of view, it looks like its harder than writing the scripted nodes :). Maybe I didnt tried hard enough but I couldnt get the general working principle. Anyway, I dont own the plug-in right now, but the words "no sweat" makes me think maybe I should have tried harder. :)

It's actually not that bad at all... way easier / faster than scripting. :) You just have to do a few things with it, and then it gets easier and easier

OlegB
04-01-2010, 04:15 PM
Somewhat relevant results - http://www.orbaz.com/forum/viewtopic.php?t=2778

Thanks,
Oleg B.

CGTalk Moderation
04-01-2010, 04:15 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.