Untitled

mail@pastecode.io avatar
unknown
plain_text
8 months ago
1.7 kB
0
Indexable
Never
def follicleCreationOnMesh(meshName , closestPointLoc , replaceWith , scaleNode):
        #meshName    = "mesh_m_low_sackPatch_001"
        locatorName     = closestPointLoc

        cpointNode    = mc.createNode("closestPointOnMesh" , n = "dummy_CPM_Node")
        meshShapeNode = mc.listRelatives(meshName , s =1)[0]

        mc.connectAttr( meshShapeNode +".worldMatrix[0]" , cpointNode+".inputMatrix")
        mc.connectAttr( meshShapeNode +".worldMesh[0]" , cpointNode+".inMesh")
        mc.connectAttr( locatorName +".translate" , cpointNode+".inPosition")

        uValue = mc.getAttr(cpointNode + ".parameterU")
        vValue = mc.getAttr(cpointNode + ".parameterV")

        follicleNode = mc.createNode("follicle" , n = locatorName.replace(replaceWith , "fol_") + "Shape" )
        follicleTransform = mc.listRelatives(follicleNode , p =1)[0]
        mc.connectAttr(meshShapeNode +".outMesh" ,  follicleNode+".inputMesh")
        mc.connectAttr(meshShapeNode +".worldMatrix[0]" ,  follicleNode+".inputWorldMatrix")

        mc.connectAttr(follicleNode + ".outRotate", follicleTransform +".rotate" )
        mc.connectAttr(follicleNode + ".outTranslate", follicleTransform +".translate" )

        mc.setAttr(follicleNode + ".parameterU" , uValue)
        mc.setAttr(follicleNode + ".parameterV" , vValue)

        mc.delete(cpointNode)

        if scaleNode != None:
                mc.connectAttr(scaleNode + ".scaleY" , follicleTransform + ".scaleX" )
                mc.connectAttr(scaleNode + ".scaleY" , follicleTransform + ".scaleY" )
                mc.connectAttr(scaleNode + ".scaleY" , follicleTransform + ".scaleZ" )

        return follicleTransform
Leave a Comment