Example #1
0
    def __init__(self, character, skeleton_grp, muscle_grp, fascia_geo, fat_geo, skin_geo):
        self.skeleton = util.getAllObjectUnderGroup(skeleton_grp)
        self.muscles = util.getAllObjectUnderGroup(muscle_grp)
        self.fascia = pm.ls(fascia_geo)[-1]
        self.fat = pm.ls(fat_geo)[-1]
        self.skin = pm.ls(skin_geo)[-1]

        # prepare skeleton
        if len(self.skeleton) > 1:
            self.skeleton = tool.zPolyCombine(self.skeleton)

        super().__init__(character, rig_type='skin')
        self.clean_skin()
Example #2
0
    def __init__(self, character='Warewolf', skeleton_grp='Skeleton_GRP', muscle_grp='Muscle_GRP', tet_size=2, attachment_radius=1, combine_skeleton=True):
        self.skeleton_grp = skeleton_grp
        self.muscle_grp = muscle_grp
        self.skeleton = util.getAllObjectUnderGroup(skeleton_grp)
        self.muscles = util.getAllObjectUnderGroup(muscle_grp)

        # prepare skeleton
        if len(self.skeleton) > 1 and combine_skeleton:
            self.skeleton = tool.zPolyCombine(self.skeleton)

        # make bone
        self.ziva_bone = addBone(self.skeleton)

        # make tissue
        self.ziva_tissue_muscles = []
        for geo in self.muscles:
            muscle = addTissue(geo, tet_size=tet_size)
            self.ziva_tissue_muscles.append(muscle)

        # attachment
        # - bone to muscle
        for geo in self.muscles:
            attachment.addAttachment(self.skeleton, geo, value=attachment_radius)

        # - muscle to muscle
        self.muscle_to_muscle_attachemnt(value=attachment_radius)

        # fiber
        self.curve_list = []
        self.rivets_list = []

        self.loa_grp = pm.group(n='loa_grp', em=True)
        self.curve_grp = pm.group(n='curve_grp', em=True, p=self.loa_grp)
        self.rivet_grp = pm.group(n='rivet_grp', em=True, p=self.loa_grp)

        for geo in self.muscles:
            curve, rivets = fiber.createLineOfAction(geo, self.skeleton)
            self.curve_list.append(curve)
            self.rivets_list.extend(rivets)

        pm.parent(self.curve_list, self.curve_grp)
        pm.parent(self.rivets_list, self.rivet_grp)

        # zOut
        self.zMuscleCombined = tool.zPolyCombine(self.muscles)
        self.zOut_grp = pm.group(self.zMuscleCombined, n='zOut_grp')

        # CleanUp
        super().__init__(character, rig_type='muscle')
        self.clean_muscle()
Example #3
0
        return self.checkFaceWithHoles

    def getNonPlanarFaces(self):
        return self.checkNonPlanarFaces

    def getLaminaFaces(self):
        return self.checkLaminaFaces

    def getNonmanifoldGeometry(self):
        return self.checkNonmanifoldGeometry

    def getEdgesWithZeroLenght(self):
        return self.checkEdgesWithZeroLenght

    def getFacesWithZeroGeometryArea(self):
        return self.checkFacesWithZeroGeometryArea

    def getFacesWithZeroMapArea(self):
        return self.checkFacesWithZeroMapArea

    def getInvalidComponents(self):
        return self.checkInvalidComponents


if __name__ == "__main__":
    geoList = getAllObjectUnderGroup(pm.ls(sl=True)[0])
    for geo in geoList:
        print geo.name()
        modelFix = ModelFix(geo)
        modelFix.autoFix()
Example #4
0
    def __init__(self,
                 characterName='new',
                 model_filePath='',
                 buildScene_filePath='',
                 rootJnt='spineJA_jnt',
                 headJnt='headJA_jnt',
                 loadSkinCluster=True,
                 doProxyGeo=True,
                 goToTPose=True):
        """
        Create Base Rig
        :param characterName: str
        :param model_filePath: str
        :param buildScene_filePath: str
        :param rootJnt: str
        :param loadSkinCluster: bool
        :param doProxyGeo: bool
        :param goToTPose: bool
        """

        start = pm.timerX()
        print '-- START --'

        # New Scene
        if buildScene_filePath:
            pm.newFile(force=True)

        # Import model
        if model_filePath:
            pm.importFile(model_filePath)

        # Import buildScene
        if buildScene_filePath:
            pm.importFile(buildScene_filePath)

        if goToTPose:
            joint.loadTPose(rootJnt)

        # Create proxy geo
        self.prxGeoList = pm.ls('*_PRX')
        if doProxyGeo:
            if len(self.prxGeoList) == 0 and len(pm.ls('mainProxy_GEO')) > 0:
                mainProxyGeo = pm.ls('mainProxy_GEO')[0]
                prxGeoInstance = proxyGeo.ProxyGeo(mainProxyGeo)
                self.prxGeoList = prxGeoInstance.getProxyGeoList()

        self.prepare()

        # search model grp
        self.sceneRadius = 1
        modelGrp = pm.ls(characterName + '_model' + '_GRP')
        if modelGrp:
            radius = util.getPlanarRadiusBBOXFromTransform(
                modelGrp[0])['planarY']
            self.sceneRadius = radius

        # Create rig
        self.baseModule = Base(characterName=characterName,
                               scale=self.sceneRadius,
                               mainCtrlAttachObj=headJnt)
        self.rig()

        # parent model group and clean scene
        if modelGrp:
            pm.parent(modelGrp, self.baseModule.mediumSlowGrp)
            if len(self.prxGeoList) > 0:
                pm.parent(self.prxGeoList, self.baseModule.fastModelGrp)
                if doProxyGeo and len(
                        pm.ls('mainProxy_GEO')) > 0 and pm.objExists(
                            prxGeoInstance.getFastGeoGroup()):
                    pm.delete(prxGeoInstance.getFastGeoGroup(),
                              pm.ls('mainProxy_GEO'))

        if pm.objExists('skeletonModel_GRP'):
            pm.parent('skeletonModel_GRP', self.baseModule.rigModelGrp)

        # parent joint group
        if pm.objExists(rootJnt):
            pm.parent(rootJnt, self.baseModule.jointsGrp)

        # Load SkinCluster
        if loadSkinCluster:
            joint.loadProjectionPose(rootJnt)
            geoList = [geo.name() for geo in pm.ls('*_GEO')]
            skin.loadSkinWeights(characterName, geoList)

        self.upgrade()

        # control shape
        if pm.objExists('controlShapes_GRP'):
            controlShapeList = util.getAllObjectUnderGroup('controlShapes_GRP',
                                                           type='transform')
            controlList = [
                cv for cv in pm.ls('*_CTRL') if cv not in controlShapeList
            ]
            for ctrl in controlList:
                for ctrlshape in controlShapeList:
                    if ctrlshape.name().split('|')[-1] == ctrl.name().split(
                            '|')[-1]:
                        ctrlShape.copyShape(ctrlshape, ctrl)
            pm.delete('controlShapes_GRP')

        self.finalize()

        totalTime = pm.timerX(startTime=start)
        print '-- END --'
        print 'Total time: ', totalTime