Distance Foam Script

Share your scripts with other members
User avatar
brandony
Posts: 231
Joined: Sat Oct 21, 2006 7:38 am

Distance Foam Script

Postby brandony » Tue Sep 02, 2008 5:45 pm

heres an updated version of the script.

Code: Select all

# Name: Distance Foam
# Description: Creates foam particles based on the length of 2 objects. Good for waterfall foam.
# Author    : Brandon Young
# Date       :August 30th 2008
# Version   : 1.5
#---------------------------------------


def onSimulationStep():
   import random
   velMult = .5 # this adjusts the inherited velocity of the particles  example  .1 = 10% 1 = 100%
   randval = 10.0  # this is sort of  like a falloff parameter the bigger the futher out side the nulls the particles will be bron.
   liquid = scene.getEmitter("Circle01")
   foam = scene.getEmitter("Square01")
   object_a = Null02.getParameter("Position X") #change Position X to Position Y,or Position Z for the other axis.
   object_b = Null01.getParameter("Position X") #change Position X to Position Y,or Position Z for the other axis.
   length = object_b - object_a
   p = liquid.getFirstParticle()
   while p:
      nextp = p.getNextParticle()
      if (p.getPosition().getX()- object_a)/(length+0.0001) > random.uniform(0.0,randval): #change .getX to getY,or getZ for the other axis.
         pos = p.getPosition()
         vel = p.getVelocity()
         velx = vel.x * velMult
         vely = vel.y * velMult
         velz = vel.z * velMult
         newvel = Vector.new(velx,vely,velz)
         foam.addParticle(pos, newvel)
         liquid.removeParticle(p.getId())   
      p = nextp
#--------------------------------------------------
# Function: onSimulationFrame
#--------------------------------------------------

def onSimulationFrame():
   pass

#--------------------------------------------------
# Function: onSimulationBegin
#--------------------------------------------------

def onSimulationBegin():
   pass


#--------------------------------------------------
# Function: onSimulationEnd
#--------------------------------------------------

def onSimulationEnd():
   pass




#--------------------------------------------------
# Function: onChangeToFrame
#--------------------------------------------------

def onChangeToFrame():
   pass
Brandon Young
www.byvfx.com
FX Artist | TD



Return to “User Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest