Example #1
0
  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
Example #2
0
  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
Example #3
0
 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)
Example #4
0
 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)
Example #5
0
 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
Example #6
0
    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)
Example #7
0
    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
Example #8
0
    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)
Example #9
0
 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)
Example #10
0
 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)
Example #11
0
 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)
Example #12
0
 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)
Example #13
0
 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)
Example #14
0
 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)