PDA

View Full Version : sript test


tamagochy
01-22-2009, 04:08 PM
I want make a particles on the wave crest. But generation of particles mast begin when wave will reach some Z position. If it possible make this with script test?

JohnnyRandom
01-22-2009, 05:02 PM
Particles higher than 100 units will be passed on to the next event.

on ChannelsUsed pCont do
(
pCont.useTime = true
pCont.usePosition = 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 > 100 then -- all particles above 100 units will pass on
(
pCont.particleTestStatus = true
pCont.particleTestTime = pCont.particleTime
)
)
)

on Release pCont do
(

)

JohnnyRandom
01-22-2009, 05:07 PM
better yet randomize the value a little bit

on Proceed pCont do
(

count = pCont.NumParticles()
for i in 1 to count do
(
theValue = random 50 100 -- the random z value
pCont.particleIndex = i
if pCont.particlePosition.z > theValue then -- all particles higher than theValue will pass on
(
pCont.particleTestStatus = true
pCont.particleTestTime = pCont.particleTime
)
)
)

tamagochy
01-22-2009, 05:44 PM
Thanks, I wright the same script but I didnt use parameter pCont.useTime = true

now its working

OlegB
01-22-2009, 06:02 PM
theValue = random

Not good. You have to use a random generator from pCont (it has functions for that), otherwise you'll get some unneeeded surprises along the way.

Thanks,
Oleg B.

JohnnyRandom
01-22-2009, 06:42 PM
Thanks, I wright the same script but I didnt use parameter pCont.useTime = true

now its working
It should work regardless if that channel is initiated or not, AFAIK. You are only seeing the channel and not altering it.

Not good. You have to use a random generator from pCont (it has functions for that), otherwise you'll get some unneeeded surprises along the way.

Thanks,
Oleg B.

is it the fact that the Init needs a seed value? or something else?

Forgive my niaveness, I saw the pcont.randXX functions but was unable to figure out how to set a lower limit. None of the functions seem to be able to set a range other than 0 - ....

IE theValue = pcont.rand01() ? i was hoping it would be simple like [50, 100] or 50 100 but it just generates some random #

and

theValue = pcont.rand0X 100 --you can set the upper but how can you set the lower limit?

OlegB
01-22-2009, 06:50 PM
The proper expression is:

val = desiredHeight + desiredRandomnessMagnitude*pCont.rand55

Thanks,
Oleg B.

JohnnyRandom
01-22-2009, 06:56 PM
Ah I see, thanks :) and mental note to self "remember to use expressions" not just functions :D

theValue = 100 + 100*pcont.rand55() ;)

Gravey
01-22-2009, 10:54 PM
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 ?

Glacierise
01-22-2009, 11:44 PM
A volume select is not the fastest thing in the world, mildly put :D

Piflik
01-23-2009, 12:12 AM
Another way would be a deflector + collision-test.

Gravey
01-23-2009, 02:58 AM
A volume select is not the fastest thing in the world, mildly put :DNeither is a script test. ;) 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 :)

JohnnyRandom
01-23-2009, 06:52 AM
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.

Glacierise
01-23-2009, 07:58 AM
Cool test dude :) 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.

tamagochy
01-23-2009, 09:54 AM
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?

Piflik
01-23-2009, 10:20 AM
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

tamagochy
01-23-2009, 11:46 AM
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.

Piflik
01-23-2009, 12:32 PM
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.

tamagochy
01-23-2009, 01:18 PM
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

Piflik
01-23-2009, 02:39 PM
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
()

tamagochy
01-23-2009, 02:55 PM
not working for me, particles stay in event01...

Piflik
01-23-2009, 02:58 PM
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.

tamagochy
01-23-2009, 03:15 PM
I paste this script to script test and it not working...
Maybe I have to change something in a PF structure?

Piflik
01-23-2009, 05:33 PM
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.

tamagochy
01-23-2009, 06:20 PM
yep, script from your scene is working ) thanks

tamagochy
01-25-2009, 10:46 AM
the result
http://www.b-design.com.ua/animation/wave_1.avi

CGTalk Moderation
01-25-2009, 10:46 AM
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.