1. 提取abc面组(maya 导出面集)
nodel = list(hou.selectedNodes())
for node in nodel:
geo = node.geometry()
a = geo.primGroups()
nodePos = node.position()
x=-3
for group in a:
name=group.name()
x+=3
next_position = [ nodePos[0]+x,nodePos[1]-2]
blastNode = node.createOutputNode('blast')
blastNode.setPosition(next_position)
blastNode.parm('group').set(name)
blastNode.parm('negate').set(1)
2.fetch abc相机
selectNodes = hou.selectedNodes()
allNodes = []
allNodeName = []
for node in selectNodes:
type = node.type()
parent = node.parent()
for child in parent.children():
allNodes.append(child.name())
#print(child)
print(allNodes)
obj = hou.node("/obj/")
if 'transfer' not in allNodes:
Nullnode = obj.createNode('null', 'transfer')
selectNodes[0].setInput(0,Nullnode,0)
#Nullnode.setName('transfer')
for abc in selectNodes:
abcallnode = abc.allSubChildren()
posx =abc.position()[0]
posy = abc.position()[1]
abc.moveToGoodPosition()
for node in abcallnode:
cameraname = node.type().name()
if cameraname == "cam":
node.setDisplayFlag(0)
camera_path = node.path()
cameraAspectPath = node.parm('aspect').path()
cameraFocalPath = node.parm('focal').path()
cameraAperture = node.parm('aperture').path()
if 'fetch1' in allNodes:
hou.node('/obj/fetch1').destroy()
fetchNode = obj.createNode('fetch')
fetchNode.setDisplayFlag(0)
fetchNode.setPosition([posx-3,posy+1])
fetchNode.parm('fetchobjpath').set(camera_path)
fetchNode.parm('useinputoffetched').set(1)
if 'renderCam' in allNodes:
hou.node('/obj/renderCam').destroy()
cameraNode = fetchNode.createOutputNode('cam')
cameraNode.setName('renderCam')
cameraNode.parm('near').set('0.0001')
cameraNode.setParmExpressions({"aspect":'ch("%s")'% cameraAspectPath})
cameraNode.setParmExpressions({"focal":'ch("%s")'% cameraFocalPath})
cameraNode.setParmExpressions({"aperture":'ch("%s")'% cameraAperture})
3. 重置节点参数
import hou
selectnodes = hou.selectedNodes()
for node in selectnodes:
for c in node.parms():
a=c.name()
node.parm(a).deleteAllKeyframes()
node.parm(a).revertToDefaults()
4.选择要渲染的null节点
sel = hou.selectedNodes()
if len(sel)==1:
curPath = sel[0].parent()
objPath = sel[0].path()
namePath = sel[0].name()
pos = sel[0].position()
path = curPath
obj = hou.node("/obj")
geoNode = obj.createNode("geo",namePath)
geoNode.setColor(hou.Color(0.3,0.5,0.1))
geoNode.parm("geo_velocityblur").set(1)
nullNode = geoNode.createNode("null","Display")
mkMergeNode = geoNode.createNode("object_merge")
mkMergeNode.setPosition(pos)
mkMergeNode.setName(sel[0].name()+"_merge")
mkMergeNode.setColor(hou.Color(1,0.5,0.1))
mkMergeNode.parm("xformtype").set(1)
mkMergeNode.parm("objpath1").set(objPath)
nullNode.setDisplayFlag(1)
mkMergeNode.setRenderFlag(1)
版权说明
文章采用: 《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权。版权声明:未标注转载均为本站原创,转载时请以链接形式注明文章出处。如有侵权、不妥之处,请联系站长删除。敬请谅解!
@feWTkd6X:图床有问题,可以在C...