PDA

View Full Version : "bubble chamber" particle system


casinowilhelm
05-30-2008, 03:46 PM
Hi,

I'm a relative beginner to scripting particles, and I've been trying to recreate a kind of particle collision bubble chamber effect. (in an attempt to recreate this:
http://www.complexification.net/gallery/machines/bubblechamber/index.php
which generously comes with the processing code too)

By hacking one of the scripts that comes with max (scripted randomwalk) I've got to a certain point but at the moment the particles are kind of hardwired to come out in one direction and only deviate from that direction. I would like them to fire out at random directions and make the spiral shapes in their own plane. I guess I need to translate them with some kind of matrix? I've tried a few things but with no joy.

here's a screen of what happens at the moment
http://img79.imageshack.us/img79/3772/bubblechamber2ry8.th.jpg (http://img79.imageshack.us/my.php?image=bubblechamber2ry8.jpg)


here's the script (sorry about the superfluous lines that probably don't do anything, I'm very much feeling around at the moment). Important bit is in yellow.

on ChannelsUsed pCont do
(
pCont.useTime = true
pCont.useEventTime = true
pCont.useSpeed = true -- we will modify the speed
pCont.usePosition = true
pCont.useInteger = true
pCont.useFloat = true -- the length of the next force-apply is kept in this channel
pCont.useVector = true -- the force being applied in the next push
pCont.useMatrix = true -- we are going to use just a single float out of this matrix value to keep track of particles that were modified
)


on Init pCont do
(

global RND_walk_maxspeed = 300.0
global RND_walk_force = 0.01
global mtx = (matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0]) -- variable to make data exchange with particle matrix channel
)

on Proceed pCont do
(
count = pCont.NumParticles() -- the count of the particles in this container
tTPS = 4800.0 / FrameRate -- the current number of ticks per frame
tStart = (pCont.getTimeStart() as float) -- the starting tick# in this time-interval
tEnd = (pCont.getTimeEnd() as float) -- the end tick# of this time-interval
tDif = (tEnd - tStart) / tTPS -- the current iteration length in frames
-- when this value is 1.0, it means we are iterating once per frame, if it's 0.5 we have two iterations per frame, etc.
-- we need this value to be used as a force multiplier, to avoid different results for viewport/rendering
-- as by the default settings, we have 1 iteration per frame for the viewports, but 2 for the rendering.
local force_multiplier = tDif * RND_walk_force / tTPS
local maxspeed = RND_walk_maxspeed / tTPS / frameRate
--local mtx = (matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0])

for i in 1 to count do -- we have to go through all the particles in this container
(
pCont.particleIndex = i
local pInt = pCont.particleInteger
local pFloat = pCont.particleFloat

local pVec = pCont.particleVector
if (pCont.particleNew) then ( -- if the particle just entered the event, we have to give an initial value to the next-push time variables
pFloat = random -0.01 0.01
pCont.particleFloat = pFloat
mtx[4]= pCont.particleSpeed
pCont.particleMatrix = mtx
pVec = pCont.particleSpeed
pCont.particleVector = pVec
)
local curr_speed = (length pCont.particleSpeed)
local pETime = (pCont.particleEventTime as float) / tTPS -- current event-time of the particle

mtx = pCont.particleMatrix
if (pFloat > 2000 or pFloat < -2000) then (
pFloat /= pFloat/15
pVec.x = -curr_speed*sin(pFloat)
pVec.y = -curr_speed*cos(pFloat)
)
else (
pFloat += pFloat/15
pVec.x = curr_speed*sin(pFloat)
pVec.y = curr_speed*cos(pFloat)
)
pCont.particleFloat = pFloat
pCont.particleVector = pVec
pCont.particlePosition += mtx[4]
pCont.particleSpeed = pCont.particleVector

)
)





any help at all is much appreciated

Mike

DreamWriter
05-31-2008, 03:22 AM
Nice effect, but I've try to run your script and got this error:
http://img48.imageshack.us/img48/5534/bubblescriptzi9.jpg

davestewart
05-31-2008, 10:32 AM
Yup - Jared Tarbell does some wicked stuff.

I added your script as an operator in an an event below the birth event, and the particles just move downwards and siedways - no spiraling in way shape or form.

Care to explain your setup?

casinowilhelm
06-02-2008, 12:13 AM
I'm sorry that wasn't enough, I realised I should've included the max file rather than just the script. here it is - hope it clarifies things a bit...(it's for max 2008).

CGTalk Moderation
06-02-2008, 12:13 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.