【Maya开发基础随手记】Transform节点中offsetParentMatrix失效时的替代办法

前言

水文档来了,不过作为初学者,真的学啥忘啥,俺也很难受啊TAT
什么是offsetParentMatrix,可查看之前的文档的最后三行。

  • 一般会设置一个locator(loc)来记录介于parent与self之间的变换行为,对于例如骨骼那种层级关系很强的对象非常实用。现在分两种情况讨论

未失效时

            if cmds.objExists(对象+'.offsetParentMatrix'):
                connectAttr(loc, 'matrix', 对象, 'offsetParentMatrix')

失效时

我们会设置一个空对象,取名为对象+'_OFF_GRP',OFF是offset缩写,事实上这个空对象是在对象的父级上,所以才有off后缀。换句话说,就是从原来的对象的parent-对象的层级关系变为对象的原parent-OFF_GRP-对象,中间多了个变换过程。

                dcm = cmds.createNode('decomposeMatrix', name=loc+'_DCM')
                connectAttr(loc, 'matrix', dcm, 'inputMatrix')# relative to parent
                for attr in ['translate', 'rotate', 'scale']:
                    connectAttr(dcm,'output'+attr.title(), 对象+'_OFF_GRP', attr)

后记

挖一个小坑:
关于怎么用脚本创建空对象,以后想起来再补充吧,这个只是紧急笔记。
——20230407留

猜你喜欢

转载自blog.csdn.net/qq_43544518/article/details/130014670
今日推荐