转载请注明:http://blog.sina.com.cn/s/blog_9736e6a20101if7e.html
下面是一段Python代码,相信大家都看的懂,对这就是在realflow中实现大脑袋的案列,当然这段代码不包括模型的变化,就是简简单单的吸水,掉水。前不久想拿H来实现这个效果,说实话真心的一句话老子不会,问了很多人别人也没啥想法,两个朋友给我说一个叫我拿flip pop去实现,另一个好朋友说普通粒子就可以。结果用的普通粒子来搞的!当然和flip pop也实现了。
1、realflow中python代码,看了看还是很好理解的,这里就不一一阐述了。效果如下
#--------------------------------------------------
# Function: onSimulationStep
#--------------------------------------------------
def onSimulationStep():
import math
import random
em_a = scene.getEmitter("A")
em_b = scene.getEmitter("B")
em_c = scene.getEmitter("C")
em_d = scene.getEmitter("D")
n = scene.getObject("Null01")
npos = n.getParameter("Position")
nz = abs(npos.z)
ff = scene.getCurrentFrame()
par_a = em_a.getFirstParticle()
while par_a:
apos = par_a.getPosition()
apx = apos.x
apz = apos.z
adis = math.sqrt(apx**2+apz**2)
if adis
apid = par_a.id
avel = par_a.getVelocity()
em_a.removeParticle(apid)
em_b.addParticle(apos, avel)
par_a = par_a.getNextParticle()
par_b = em_b.getFirstParticle()
while par_b:
bage = par_b.getAge()
bpos = par_b.getPosition()
bpy = bpos.y
bid = par_b.id
bvel = par_b.getVelocity()
if bage>1.6:
em_b.removeParticle(bid)
em_c.addParticle(bpos, bvel)
if ff>52 and bpy<0.5 and bid%4!=0:
em_b.removeParticle(bid)
em_d.addParticle(bpos, bvel)
par_b = par_b.getNextParticle()
par_c = em_c.getFirstParticle()
while par_c:
cage = par_c.getAge()
cpos = par_c.getPosition()
cpy = cpos.y
cid = par_c.id
if cpy<0.6 and cage>0.45 and cid%2==0 and ff<120:
cvel = par_c.getVelocity()
em_c.removeParticle(cid)
em_d.addParticle(cpos, cvel)
par_c = par_c.getNextParticle()
pass