Пример #1
0
def hipCtrlShape(name, normalDirection=[0, -1, 1], scale=1):
    ctrl = pm.circle(n=name, s=10, nr=[0, 0, 1])[0]

    pm.move(0, 0, 1, ctrl.cv[3:4], ctrl.cv[8:9], r=True, os=True)
    pm.scale([ctrl.cv[3:4], ctrl.cv[8:9]], [1, 3, 1], r=True, p=[0, 0, 1])
    pm.scale([ctrl.cv[0], ctrl.cv[2], ctrl.cv[5], ctrl.cv[7]], [1.75, 1.35, 1], r=True, p=[0, 0, 0])
    pm.move(0, 0, -0.75, ctrl.cv[0], ctrl.cv[2], ctrl.cv[5], ctrl.cv[7], r=True, os=True)
    pm.move(0, 0, -1, ctrl.cv[1], ctrl.cv[6], r=True, os=True)
    pm.scale(ctrl.cv[:], [1, 0.5, 1], r=True, p=[0, 0, 0])
    # pm.xform(ctrl, ws=True, pivots=[0, 0, -0.15])

    if normalDirection[0] == 1:
        pm.rotate(ctrl.cv[:], [90, 0, 0])
    elif normalDirection[0] == -1:
        pm.rotate(ctrl.cv[:], [-90, 0, 0])

    if normalDirection[1] == 1:
        pm.rotate(ctrl.cv[:], [0, 90, 0])
    elif normalDirection[1] == -1:
        pm.rotate(ctrl.cv[:], [0, -90, 0])

    if normalDirection[2] == 1:
        pm.rotate(ctrl.cv[:], [0, 0, 90])
    elif normalDirection[2] == -1:
        pm.rotate(ctrl.cv[:], [0, 0, -90])

    ctrl.scale.set(scale, scale, scale)
    common.deleteHistory(ctrl)
    common.freezeTranform(ctrl)

    return ctrl
Пример #2
0
def sphereCtrlShape(name, scale=1):
    ctrlObject = pm.circle(n=name, ch=False, normal=[1, 0, 0], radius=scale)[0]
    addShape = pm.circle(n=name, ch=False, normal=[0, 0, 1], radius=scale)[0]
    pm.parent(pm.listRelatives(addShape, s=1), ctrlObject, r=1, s=1)
    pm.delete(addShape)

    common.deleteHistory(ctrlObject)
    common.freezeTranform(ctrlObject)
    return ctrlObject
Пример #3
0
def controlShapeAdaptive(controlList, geoList, ctrlSmooth=6, scaleConstant=1.5, rebuildCV=32):
    adaptiveShapeBuildGrp = pm.group(n='daptiveShapeBuild_GRP', em=True)
    geoList = pm.ls(geoList)
    dupliGeo = pm.duplicate(geoList)
    geoCombined = pm.polyUnite(dupliGeo, ch=False, name='tmpAdaptiveRef_GEO')[0]
    pm.parent(geoCombined, adaptiveShapeBuildGrp)

    ctrlList = pm.ls(controlList)
    for ctrl in ctrlList:
        ctrlShapeBuildGrp = pm.group(n=ctrl.name() + '_GRP', em=True, p=adaptiveShapeBuildGrp)

        dupliCtrl = pm.duplicate(ctrl, n='tmpCtrl')[0]
        pm.delete(pm.ls(dupliCtrl, dagObjects=True, exactType='transform')[1:])
        pm.rebuildCurve(dupliCtrl, ch=False, s=rebuildCV)
        pm.parent(dupliCtrl, ctrlShapeBuildGrp)

        # extrusion
        extrudeCircle = pm.circle(r=0.1, ch=0)[0]
        pm.parent(extrudeCircle, ctrlShapeBuildGrp)
        motionPathNode = \
            pm.ls(pm.pathAnimation(extrudeCircle, curve=dupliCtrl, fractionMode=True, follow=True, followAxis='z',
                                   upAxis='y', worldUpType='vector', worldUpVector=[0, 1, 0], inverseUp=False,
                                   inverseFront=False, bank=False))[0]

        pm.disconnectAttr(extrudeCircle.tx)
        pm.disconnectAttr(extrudeCircle.ty)
        pm.disconnectAttr(extrudeCircle.tz)
        pm.disconnectAttr(extrudeCircle.rx)
        pm.disconnectAttr(extrudeCircle.ry)
        pm.disconnectAttr(extrudeCircle.rz)
        pm.disconnectAttr(motionPathNode.u)
        pm.delete(motionPathNode)

        extrudedSurface = \
            pm.extrude(extrudeCircle, dupliCtrl, ch=False, rn=False, po=0, et=2, ucp=0, fpt=1, upn=0, rotation=0,
                       scale=1,
                       rsp=1)[0]
        pm.parent(extrudedSurface, ctrlShapeBuildGrp)
        nurbsToPoly = pm.nurbsToPoly(extrudedSurface, ch=False, polygonType=1, chr=0.9)
        pm.parent(nurbsToPoly, ctrlShapeBuildGrp)

        # add deformer
        wrapNode = deform.wrapDeformer(dupliCtrl, nurbsToPoly)
        shrinkWrapNode = deform.shrinkWrapDeformer(nurbsToPoly, geoCombined)

        shrinkWrapNode.projection.set(4)
        shrinkWrapNode.targetSmoothLevel.set(ctrlSmooth)

        # delete history
        common.deleteHistory(nurbsToPoly)
        common.deleteHistory(dupliCtrl)
        pm.scale(dupliCtrl.cv[:], [scaleConstant, scaleConstant, scaleConstant])

        copyShape(dupliCtrl, ctrl)

    pm.delete(adaptiveShapeBuildGrp)
Пример #4
0
    def __init__(self, geo, doParentCnst=True, threshold=0.45):
        self.proxyGeoList = []
        pivotLocator = pm.spaceLocator(n='pivotGeo_LOC')
        # Create proxy geo Group
        self.shapeGrp = pm.group(n='fastGeo_GRP', em=True)

        # Get Shape and skin from Object
        skinCluster = skin.findRelatedSkinCluster(geo)
        if not skinCluster:
            print('Missing SkinCluster')
        else:
            self.skin = skinCluster

            # Get joint influence of the skin
            influnces = self.skin.getInfluence(q=True)  # influences is joint
            for joint in influnces:
                # duplicate mesh for a control
                transform, dupliShape = self.duplicateSourceMesh(obj=geo,
                                                                 joint=joint)
                common.centerPivot(transform, pivotLocator)

                # copy skinCluster
                skin.copyBind(pm.ls(geo)[0], transform)

                # delete faces in the new shape based on selected joint
                self.deleteVertex(joint=joint,
                                  newShape=dupliShape,
                                  threshold=threshold)

                # delete non deformer history
                common.deleteHistory(dupliShape)

                # parent under proxy group
                pm.parent(transform, self.shapeGrp)
                self.proxyGeoList.append(transform)

                # parentConstraint with joint
                if doParentCnst:
                    pm.parentConstraint(joint, transform, mo=True)

            # delete pivot locator
            pm.delete(pivotLocator)
Пример #5
0
    def makeProxyGeo(self, geo, percentage=50):
        proxyName = name.removeSuffix(geo.name()) + 'Proxy_GEO'
        proxyGeo = pm.duplicate(geo, n=proxyName)[0]
        pm.polyReduce(proxyGeo,
                      p=percentage,
                      ver=1,
                      trm=0,
                      shp=0,
                      keepBorder=1,
                      keepMapBorder=1,
                      keepColorBorder=1,
                      keepFaceGroupBorder=1,
                      keepHardEdge=1,
                      keepCreaseEdge=1,
                      keepBorderWeight=0.5,
                      keepMapBorderWeight=0.5,
                      keepColorBorderWeight=0.5,
                      keepFaceGroupBorderWeight=0.5,
                      keepHardEdgeWeight=0.5,
                      keepCreaseEdgeWeight=0.5,
                      useVirtualSymmetry=0,
                      symmetryTolerance=0.01,
                      sx=0,
                      sy=1,
                      sz=0,
                      sw=0,
                      preserveTopology=1,
                      keepQuadsWeight=1,
                      vertexMapName='',
                      cachingReduce=1,
                      ch=1,
                      vct=0,
                      tct=0,
                      replaceOriginal=1)
        common.deleteHistory(proxyGeo)

        return proxyGeo