【Houdini】Houdini实现Realflow大脑袋案例

转载请注明: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




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值