PDA

View Full Version : Every Target 1 time SCRIPT


CapitanRed
05-14-2007, 01:02 AM
I'm trying now for about 3 days. No chance!! Perhaps I'm on the wrong way.

there are 100 targets, and one particle has to go their positions, but for each inly one time.

I created an array, which should be filled with the value of the current target, when the particle arrives there. but for some reason, it deletes allways the old values.

this way tought, i could compare the allready been targetsArray(oldTargetArray) with the AllTargetsArry(NextTargetArray).

I hope somebody has desire to help me out.

here the file:

www.megalomania.ch/capitanred/MaxFiles/ParticleSetup02.max (http://www.megalomania.ch/capitanred/MaxFiles/ParticleSetup02.max)

EDIT__________________

after some trying I found out that the second find target operator is deleting the values i the array
the hell!! why?

Bobo
05-14-2007, 04:01 AM
Having trouble downloading the file.

Here is how I would do it:

*Add ONE Find Target.
*Load all 100 targets in it, set mode to Mesh Objects
*Set Object: list to By Script Integer
*Add a Script Operator BEFORE the Find Target with the following code:

on ChannelsUsed pCont do
(
pCont.useInteger = true
)

on Init pCont do ( )

on Proceed pCont do
(
count = pCont.NumParticles()
for i in 1 to count do
(
pCont.particleIndex = i
pCont.particleInteger = pCont.particleID
)
)

on Release pCont do ( )

CapitanRed
05-14-2007, 09:28 AM
thanks bobo

the host was down for some reason. now you can download again.

I'll try your script.

CapitanRed
05-14-2007, 02:02 PM
I tried to understand your idea..but i don't :shrug:

there is only 1 particle, so the Id would be 1. But there are 100 targets.
Or do I not see something you have in mind?

I did it like this:
the NextTargetArray gets allways deleted at the end, so it allways looks for the targets which have same x or y to not go diagonally, before the particle starts to move. (I didn't know another way to do this than with allways recreate the array)

then it should allways after arryving append the particlePosition into the array of the targets where the particle allready was. and in the loop it compares one array with the other.

but as i wrote in the first post, somehow it does allways overwrite the values in the oldTargetArray.

OlegB
05-14-2007, 03:53 PM
Three events with two scripts:

First script:

on ChannelsUsed pCont do
(
pCont.useInteger = true
)

on Init pCont do ( )

on Proceed pCont do
(
count = pCont.NumParticles()
for i in 1 to count do
(
pCont.particleIndex = i
pCont.particleInteger = 0
)
)
on Release pCont do ( )


The first script should be used in the first event, where the particle
is born. The last operator in the first event should be Send Out. The
second event should have Find Target operator, with the options as Bobo
mentioned above. The Find Target operator (or test, to be exact) should
be wired to the third event, with a single Script Operator with the
following script:


on ChannelsUsed pCont do
(
pCont.useInteger = true
)

on Init pCont do ( )

on Proceed pCont do
(
count = pCont.NumParticles()
for i in 1 to count do
(
pCont.particleIndex = i
pCont.particleInteger = particleInteger + 1
)
)
on Release pCont do ( )

The third event should also has Send Out operator underneath the
Script Operator, and wired to the second event.

This way the scripting ensures that at first a particle finds the first
object in the list, and after each find it switches to the next target
in the list.

Thanks,
Oleg B.

Bobo
05-14-2007, 05:44 PM
My bad, I misunderstood your post.
I read it like "there are 100 targets and one particle has to go to a target" meaning 100 particles going to 100 targets, not one visiting them all.
Next time I will read more carefully...

Good thing we have Oleg around :thumbsup:

CapitanRed
05-14-2007, 07:03 PM
yea, you say it ;)

well, there was a little mistake in the second script. particleInterger ---> pCont.particleInteger

thank you very much guys. I think now I'll find a way to convert it into my file.

CGTalk Moderation
05-14-2007, 07:04 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.