i’m making a particle-generator for bubbles… it will generate a random start point (x, y, and z coords.) and then make an ipo for the bubble rising to the top, and make duplicate objects (spheres) to act as fluidsim obsticles.
here’s my technical test w/o using the blender api:
# Particle test script...
# Made to help me learn the math involved in
# making a particle emittor script.
# outline:
# import object (in this case make a cube)
# random x,y,z startinc coords
## math: get length of x dir. multiply by random (between 0 and 1)
## then add to lower coord of cube. =start x, same for y and z
# then animate z coord until it hits the top (highest z coord)
# stay for a set amt of time then go away
import random
# test for the function to make the ipo...
# this calculates changes in the z coordinate
def zIpo(z):
# these will be settings eventually
force = 1
a = 0
speed = 1
maxSpeed = 10
locz = [z]
## apperantly it starts at 0, locz[0] is the first number
while z < objHighZ:
a = a + 1
z = z + speed
if speed < maxSpeed:
speed = speed + force
locz.append(z)
locz[len(locz)-1] = objHighZ
return locz
print "ParticleMaker v0.01"
print "
By Jesse McMillan"
print "
Email me at xxx"
partNum = input("how many particles?")
# Get object here... for now just a cube at 0,0,0 (100x100x100)
objLowX = 0
objLowY = 0
objLowZ = 0
objHighX = 100
objHighY = 100
objHighZ = 100
# start loop
a = 1
while a < (partNum + 1):
xRand = random.randint(objLowX, objHighX)
yRand = random.randint(objLowY, objHighY)
zRand = random.randint(objLowZ, objHighZ)
locZIpo = zIpo(zRand)
print "particle # ", a, " x: ", xRand, "y: ", yRand
print "z: ", locZIpo
print "
"
#here we write to an ipo.
a = a + 1
output:
ParticleMaker v0.01
By Jesse McMillan
Email me at [email protected]
how many particles?4
particle # 1 x: 79 y: 79
z: [85, 86, 88, 91, 95, 100]
particle # 2 x: 83 y: 26
z: [32, 33, 35, 38, 42, 47, 53, 60, 68, 77, 87, 97, 100]
particle # 3 x: 31 y: 3
z: [71, 72, 74, 77, 81, 86, 92, 99, 100]
particle # 4 x: 35 y: 75
z: [97, 98, 100]
edit: does anyone know how to do this better or the real math?
edit # 2: i’m also going to change the scale later.