def _createJoints(self, bones): noparentBones = [] jointNames = [] for i in range(len(bones)): boneName = "joint" if self.dictFlag: boneName = self.nameDict[i] pos = bones[i].position if bones[i].parent_index == -1: noparentBones.append(i) maya.cmds.select(d=True) jointName = "" try: jointName = maya.cmds.joint(p=[pos.x, pos.y, -pos.z], name=boneName) except: jointName = maya.cmds.joint(p=[pos.x, pos.y, -pos.z]) # 稀に不正な名前のボーンが存在する jointNames.append(jointName) # 表示先の設定 for i in range(len(bones)): util.setJpName(jointNames[i], bones[i].name) tailIndex = bones[i].tail_index if tailIndex >= 0: util.setString(jointNames[i], "tailTargetName", jointNames[tailIndex]) else: util.setString(jointNames[i], "tailTargetName", "") return jointNames, noparentBones
def _createJoints(self, bones): noparentBones = [] jointNames = [] for i in range(len(bones)): boneName = "joint" if self.dictFlag: boneName = self.nameDict[i] pos = bones[i].position if bones[i].parent_index == -1: noparentBones.append(i) maya.cmds.select(d=True) jointName = "" try: jointName = maya.cmds.joint(p=[pos.x, pos.y, -pos.z], name=boneName) except: print u"Invalid bone name: %s" % boneName jointName = maya.cmds.joint(p=[pos.x, pos.y, -pos.z]) # 稀に不正な名前のボーンが存在する jointNames.append(jointName) # 表示先の設定 for i in range(len(bones)): util.setJpName(jointNames[i], bones[i].name) tailIndex = bones[i].tail_index if tailIndex >= 0: util.setString(jointNames[i], "tailTargetName", jointNames[tailIndex]) else: util.setString(jointNames[i], "tailTargetName", "") return jointNames, noparentBones
def groupingStandard(self, polyName, jointNames, noparentBonesIndices): maya.cmds.select(d=True) boneGroup = maya.cmds.group(n="bones", w=True, em=True) util.setString(boneGroup, "nodeType", "boneGroup") maya.cmds.parent(boneGroup, self.group) maya.cmds.parent(polyName, self.group) for i in noparentBonesIndices: maya.cmds.parent(jointNames[i], boneGroup)
def _createDisplayLayer(self, morphNames): morphs = self.mmdData.morphs panels = ["eyebrow_group", "eye_group", "mouth_group", "other_group"] panelJpNames = [u"眉", u"目", u"口", u"その他"] groups = [] for panel in range(4): maya.cmds.select(d=True) for i in range(len(morphs)): if morphs[i].panel == panel + 1: maya.cmds.select(morphNames[i], tgl=True) groupName = maya.cmds.group(name=panels[panel]) util.setString(groupName, "expression", panelJpNames[panel]) maya.cmds.setAttr("%s.v" % groupName, 0) groups.append(groupName) return groups
def generate(self, jointNames): bones = self.mmdData.bones for i in range(len(bones)): establishFlag = False if bones[i].getExternalRotationFlag(): self._makeExpression(bones, jointNames, i, "rotate") establishFlag = True if bones[i].getExternalTranslationFlag(): self._makeExpression(bones, jointNames, i, "translate") establishFlag = True util.setFloat(jointNames[i], "establishFactor", bones[i].effect_factor) eIndex = bones[i].effect_index util.setString(jointNames[i], "establishParent", jointNames[eIndex]) util.setBoolean(jointNames[i], "enableEstablish", establishFlag)
def _createDisplayLayer(self, morphNames): morphs = self.mmdData.morphs panels = ["eyebrow_group", "eye_group", "mouth_group", "other_group"] panelJpNames = [u"眉", u"目", u"口", u"その他"] groups = [] for panel in range(4): maya.cmds.select(d=True) for i in range(len(morphs)): if morphs[i].panel == panel + 1: maya.cmds.select(morphNames[i], tgl=True) # モーフグループを形成できない場合は,グループ化を無視する if len(maya.cmds.ls(sl=True)) > 0: groupName = maya.cmds.group(name=panels[panel]) util.setString(groupName, "expression", panelJpNames[panel]) maya.cmds.setAttr("%s.v" % groupName, 0) groups.append(groupName) return groups
def groupingConstraints(self, constraints): constGroup = maya.cmds.group(n="constraints", w=True, em=True) maya.cmds.parent(constGroup, self.group) util.setString(constGroup, "nodeType", "constraintGroup") for constName in constraints: maya.cmds.parent(constName, constGroup)
def groupingRigidbodies(self, rigidbodies): rigidGroup = maya.cmds.group(n="rigidbodies", w=True, em=True) maya.cmds.parent(rigidGroup, self.group) util.setString(rigidGroup, "nodeType", "rigidbodyGroup") for rigidName in rigidbodies: maya.cmds.parent(rigidName, rigidGroup)
def groupingBlendShapes(self, blendShapeNames): expgroup = maya.cmds.group(n="blendShapes", w=True, em=True) util.setString(expgroup, "nodeType", "blendShapeGroup") maya.cmds.parent(expgroup, self.group) for gname in blendShapeNames: maya.cmds.parent(gname, expgroup)