sript test


#7

The proper expression is:

val = desiredHeight + desiredRandomnessMagnitude*pCont.rand55

Thanks,
Oleg B.


#8

Ah I see, thanks :slight_smile: and mental note to self “remember to use expressions” not just functions :smiley:

theValue = 100 + 100*pcont.rand55() :wink:


#9

Is there some reason you need to do this with a script test? Wouldn’t it be easier to just use a volume select and set the position object to selected faces / verts ?


#10

A volume select is not the fastest thing in the world, mildly put :smiley:


#11

Another way would be a deflector + collision-test.


#12

Neither is a script test. :wink: It depends on the geometry really. If you have a lowish poly geometry emitter I think the volume select would be faster and easier to control in this case. Feel free to speed test and prove me wrong though :slight_smile:


#13

Well this sparked my curiosity…simple scene, 200 frames, 10000 particles born and locked on a noise animated plane, whenever a z-axis of 10 is reached the particles pass to new event, some speed is introduced,spawn once, 5 five later age test to delete.

Script Test - 29.11

Group Selection and Split Group test - 13.609

Box#3 Z-pos Data Test - 13.25 (lol, almost always fastest, something I already had a good idea would be)

Box#3 Data Icon Distance test - 15.187

Collision Test w/ std Deflector - 29.235

I should mention all of the times are actually a bit faster, the script I wrote to test with has to actually move the timeslider, so there is some disparity there.


#14

Cool test dude :slight_smile: Box #3 always comes on top, I don’t know why people bother scripting any more heheh. You might send me the scene so I can evlaluate how fast TP is in that operation.


#15

With this animation collision test and volume select is not usable ))
http://b-design.com.ua/animation/wave.mp4

With this script for script test particles from event01 go to event02, but I need that particles on event01 always stay and generate new particles on event02.
I found parameter pCont.AddParticle() that add particles.

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

)

on Init pCont do
(

)

on Proceed pCont do
(
count = pCont.NumParticles()
for i in 1 to count do
(
pCont.particleIndex = i
if pCont.particlePosition.z > 20 then – all particles inside a sphere with radius 20 satisfy the test
(
pCont.AddParticle()
pCont.particleIndex = pCont.NumParticles() – last particle that was added
pCont.particleTestStatus = true
pCont.particleTestTime = pCont.particleTime
)
)
)

on Release pCont do
(

)

with this script particles generate on the PF icon. Is it possible generate that particles from position of particles on event01?

I want after script test particles generate all time on wave crest. Maybe I go to wrong way?


#16

Change the content of your if statement to this:

pos = pCont.ParticlePosition
pCont.AddParticle()
pCont.particleIndex = pCont.NumParticles()
pCont.ParticlePosition = pos
pCont.particleTestStatus = true
pCont.particleTestTime = pCont.particleTime

#17

thanks, now it working good )

but I have new problem, when wave crest go down particle generation end when it going via Z pos that stated in if statement.


#18

You can add a new Event. Send the particles to event 2 (with the z.position part of the script) and in this event you add another script test, where you spawn the particles (with the other part of the script).

With a third script test you can send the particles that reach z = 0 to a third event, where they stop spawning new particles.


#19

Can U show me? I dont understand how can I do this, because first script test on event01 send particles to event02 and It loose surface position


#20

Sorry, you’re right. that doesn’t work right.

But I found a solution that worked for me. I added an array to the script, where I store a boolean value for every particle. When a particle reaches z = 20, the corresponding value is set to true. At z = 0 it is set o false again. In an additional if statement, that value determines if a particle is spawned.

Here’s the Code:

on ChannelsUsed pCont do

(
 pCont.useTime = true	
 pCont.usePosition = true
)

on Init pCont do 
(
global SpawnArr = #()
)

on Proceed pCont do 
(
	
	count = pCont.NumParticles()
	for i in 1 to count do
	(
		pCont.particleIndex = i
		if pCont.particlePosition.z > 20 then 
		(
			SpawnArr[i] = true
		)

		if SpawnArr[i] == true then
		(
			pos = pCont.particlePosition
			pCont.AddParticle()
			pCont.ParticleIndex = pCont.NumParticles()
			pCont.particlePosition = pos
			pCont.particleTestStatus = true
			pCont.particleTestTime = pCont.particleTime
		)

		pCont.particleIndex = i
		if pCont.particlePosition.z = 0 then 
		(
			SpawnArr[i] = false
		)
	)
)
on Release pCont do 
()

#21

not working for me, particles stay in event01…


#22

Sorry. Maybe I wasn’t clear enough.

Forget the whole idea with sending the particles to event2. This is a script that spawns particles when the base particles reach z = 20 and continue spawning untill they reach z = 0.


#23

I paste this script to script test and it not working…
Maybe I have to change something in a PF structure?


#24

Strange. I just tested it and it really didn’t work. Then I rewrote the script and it did work…

I attached a sample scene and the script. I hope you can open it (Max 2008) and I hope it will work…

Edit: I think I know where messed up. I swaped two lines. Corrected the above code.


#25

yep, script from your scene is working ) thanks


#26

the result
http://www.b-design.com.ua/animation/wave_1.avi