资源简介

bakeFragDetailsUV.otl可以实现将刚体解算的低模运动状态转换成高模的关键帧动画,并将碎块UV进行表面和内部的分离,以便导入maya使用,基于软件版本Houdini FX 15.0.244.16

资源截图

代码片段和文件信息

from time import *

#Bake RBDs simulation to “group“ subnetwork
#Packed RBDs simulation and get attributes as TransOrientPivot etc
#Transfer the Orient attribute to rotation
def bakeFragDetailsUV():
    tstart = time()
    hou_node = hou.pwd()
    hou_geo = hou_node.geometry()
    points = hou_geo.points()
    points_num = len(points)
#   print points_num

    point_loc = hou.node(‘/obj‘)
    group_node = point_loc.createNode(‘subnet‘‘group‘)
    rbd_node = hou_node.node(‘..‘)
    group_node.setPosition(rbd_node.position())
    group_node.move([0-1])
    group_node.setSelected(True)
    rbd_node.setSelected(False)

#   create copy pieceset the pivot
    for point in points:
        frags_node = group_node.createNode(‘geo‘‘due‘+str(point.number()))

        a_node = hou.node(‘/obj/group/due‘+str(point.number()))
        b_node = a_node.children()
        b_node[0].destroy()

        c_node = a_node.createNode(‘object_merge‘‘piece‘+str(point.number()))
        obj_path = c_node.parm(‘objpath1‘)
        obj_path.set(‘/obj/‘+rbd_node.name()+‘/pack2‘)
        group_piece = c_node.parm(‘group1‘)
        group_piece.set(‘@name=piece‘+str(point.number()))
        unpack_node = a_node.createNode(‘unpack‘‘unpack‘+str(point.number()))
        unpack_node.setPosition(c_node.position())
        unpack_node.move([0-1])
        unpack_node.setNextInput(c_node)
        unpack_node.setDisplayFlag(True)
        unpack_node.setRenderFlag(True)

        pivot_origin = point.attribValue(‘pivot‘)
#       print pivot_origin
        a_node.setParms({‘px‘:pivot_origin[0] ‘py‘:pivot_origin[1] ‘pz‘:pivot_origin[2]})
#       print a_node.evalParmTuple(‘p‘)

#   setKeyframe txtytzrxryrz
#   for x in range(int(hou.expandString(‘$FSTART‘)) int(hou.expandString(‘$FEND‘))+1 1):
    for x in range(int(hou_node.evalParm(‘f1‘)) int(hou_node.evalParm(‘f2‘))+1 1):
        hou.setframe(x)
        print str(x) + ‘ frame‘ + ‘please wait...‘
        for point in points:
            pos1 = point.position()
#           print “(%d) -> x=%f y=%f z=%f“ % (point.number() pos1[0] pos1[1] pos1[2])
            pos2 = point.attribValue(‘pivot‘)
#           print “(%d) -> x=%f y=%f z=%f“ % (point.number() pos2[0] pos2[1] pos2[2])
            pos3 = [000]
            if(x != 1):
                pos3[0] = pos1[0]-pos2[0]
                pos3[1] = pos1[1]-pos2[1]
                pos3[2] = pos1[2]-pos2[2]
#           print “(%d) -> x=%f y=%f z=%f“ % (point.number() pos3[0] pos3[1] pos3[2])
            orient_num = point.attribValue(‘orient‘)
#           print “(%d) -> x=%f y=%f z=%f n=%f“ % (point.number() orient_num[0] orient_num[1] orient_num[2] orient_num[3])

            frags_selet_node = hou.node(‘/obj/group/due‘+str(point.number()))
            orient_qua = hou.Quaternion(orient_num).normalized()

#           print type(orient_qua)
            matrix3 = orient_qua.extractRotationMatr

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     249872  2015-11-23 15:36  bakeFragDetailsUV\bakeFragDetailsUV.hip

     文件       6871  2015-11-23 13:59  bakeFragDetailsUV\bakeFragDetailsUV.otl

     文件       4371  2015-11-23 14:01  bakeFragDetailsUV\bakeFragDetailsUV.py

     文件       3513  2015-11-23 10:54  bakeFragDetailsUV\separateFragUV.otl

     目录          0  2015-11-23 15:36  bakeFragDetailsUV

----------- ---------  ---------- -----  ----

               264627                    5


评论

共有 条评论