CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 05-30-2008, 02:46 PM   #1
casinowilhelm
New Member
 
Join Date: Apr 2004
Posts: 3
"bubble chamber" particle system

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/gal...amber/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



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
 
Old 05-31-2008, 02:22 AM   #2
DreamWriter
Frequenter
Hammer Chen
Taiwan
 
Join Date: Jan 2008
Posts: 170
Nice effect, but I've try to run your script and got this error:
__________________
CG Taiwaner
 
Old 05-31-2008, 09:32 AM   #3
davestewart
Repeat-customer
 
davestewart's Avatar
Dave Stewart
Animator / scripter
United Kingdom
 
Join Date: Sep 2004
Posts: 488
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?
__________________
Portfolio | Keyframes and Code
 
Old 06-01-2008, 11:13 PM   #4
casinowilhelm
New Member
 
Join Date: Apr 2004
Posts: 3
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).
Attached Files
File Type: zip bubble chamber.zip (25.1 KB, 13 views)
 
Old 06-01-2008, 11:13 PM   #5
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:02 PM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.