From c24d23e02549111473c91e0b044841d231e21ad2 Mon Sep 17 00:00:00 2001 From: Eiichi Takebuchi Date: Mon, 19 May 2014 18:07:08 +0900 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E6=89=8B=E3=81=8F=E8=A1=8C=E3=81=8B?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=81=AE=E3=81=A7=E5=89=9B=E4=BD=93=E3=81=AF?= =?UTF-8?q?=E5=BB=B6=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit どうやらMMDのBulletは魔改造しているらしく、もしかするとそのままだと動かないかもしれない --- bonegen.py | 4 ++-- expgen.py | 3 +++ mmdcommand.py | 12 ++++++------ rigidgen.py | 24 ++++++++---------------- util.py | 5 ++++- 5 files changed, 23 insertions(+), 25 deletions(-) diff --git a/bonegen.py b/bonegen.py index 3cf9a95..32a72d6 100644 --- a/bonegen.py +++ b/bonegen.py @@ -64,8 +64,8 @@ def _lockHideAttributes(self, jointName, disableType): def _settingDrawStyle(self, bones, jointNames): for i in range(len(bones)): visible = 0 if bones[i].getVisibleFlag() else 2 - jointName = jointNames[i] - maya.cmds.setAttr("%s.drawStyle" % jointName, visible) + visible = 2 if bones[i].getIkFlag() else visible + maya.cmds.setAttr("%s.drawStyle" % jointNames[i], visible) # 回転・移動・操作フラグからLockとHideを各チャンネルに行う diff --git a/expgen.py b/expgen.py index 3c8c97f..89bbf1e 100644 --- a/expgen.py +++ b/expgen.py @@ -5,6 +5,7 @@ import maya.OpenMaya import filemanager +import util class ExpressionGenerator: @@ -36,6 +37,7 @@ def _duplicateMesh(self): 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) @@ -43,6 +45,7 @@ def _createDisplayLayer(self, morphNames): if morphs[i].panel == panel + 1: maya.cmds.select(morphNames[i], tgl=True) groupName = maya.cmds.group(name=panels[panel]) + util.setJpName(groupName, panelJpNames[panel]) maya.cmds.setAttr("%s.v" % groupName, 0) groups.append(groupName) return groups diff --git a/mmdcommand.py b/mmdcommand.py index 36e47f7..b5cb9d5 100644 --- a/mmdcommand.py +++ b/mmdcommand.py @@ -74,7 +74,7 @@ def _grouping(self, polyName, jointNames, noparentBonesIndices): def _groupExpression(self, blendShapeNames, mother): - expgroup = maya.cmds.group(n="expresssion", w=True, em=True) + expgroup = maya.cmds.group(n="blendShapes", w=True, em=True) maya.cmds.parent(expgroup, mother) for gname in blendShapeNames: maya.cmds.parent(gname, expgroup) @@ -97,8 +97,8 @@ def _createData(self, argData): genMaterial.generate(meshName, incandescenseFlag) # Blend Shapeの生成 - #genExp = expgen.ExpressionGenerator(mmdData, filePath) - #blendShapeNames = genExp.generate(polyName) + genExp = expgen.ExpressionGenerator(mmdData, filePath) + blendShapeNames = genExp.generate(polyName) # ボーンの生成 genBone = bonegen.BoneGenerator(mmdData, filePath) @@ -118,12 +118,12 @@ def _createData(self, argData): genSkin = skingen.SkinGenerator(mmdData) genSkin.generate(skinCluster, jointNames, polyName) - genRigid = rigidgen.RigidBodyGenerator(mmdData, filePath) - genRigid.generate(jointNames) + #genRigid = rigidgen.RigidBodyGenerator(mmdData, filePath) + #genRigid.generate(jointNames) #グループ化 mother = self._grouping(polyName, jointNames, noparentBonesIndices) - #self._groupExpression(blendShapeNames, mother) + self._groupExpression(blendShapeNames, mother) def doIt(self, args): diff --git a/rigidgen.py b/rigidgen.py index d695355..0744ad9 100644 --- a/rigidgen.py +++ b/rigidgen.py @@ -68,7 +68,7 @@ def _constructConstraint(self, bones, rigidObj, shape, rigid, jointNames): if parentJoint != "": if mode == 0: # ボーン追従 - maya.cmds.setAttr("%s.bodyType" % shape, 1) + maya.cmds.setAttr("%s.bodyType" % shape, 0) current = bones[rigid.bone_index] parentJoint = jointNames[current.parent_index] self._parentConstraint(parentJoint, rigidObj) @@ -105,25 +105,15 @@ def _createRigidObjects(self, jointNames): return rigidObjects, rigidShapes - def _convertCoordinate(self, value, limitType, axis): - if limitType == "angular" and axis == "X": - return -value * self.constPI - elif limitType == "linear" and axis == "Z": - return -value - - if limitType == "angular": - return value * self.constPI - - return value - - def _setJointLimitation(self, constraint, minVector, maxVector, limitType, axis, i): args = (constraint, limitType, axis) minValue = minVector[i] #self._convertCoordinate(minVector[i], limitType, axis) maxValue = maxVector[i] #self._convertCoordinate(maxVector[i], limitType, axis) + if minVector[i] > maxVector[i]: + maya.cmds.setAttr("%s.%sConstraint%s" % args, 0) if minVector[i] == 0.0 and maxVector[i] == 0.0: - maya.cmds.setAttr("%s.%sConstraint%s" % args, 2) + maya.cmds.setAttr("%s.%sConstraint%s" % args, 1) else: maya.cmds.setAttr("%s.%sConstraint%s" % args, 2) maya.cmds.setAttr("%s.%sConstraintMin%s" % args, minValue) @@ -132,7 +122,9 @@ def _setJointLimitation(self, constraint, minVector, maxVector, limitType, axis, def _setSpringLimitation(self, constraint, limitVector, limitType, axis, i): limitValue = limitVector[i] #self._convertCoordinate(limitVector[i], limitType, axis) - maya.cmds.setAttr("%s.%sSpringStiffness%s" % (constraint, limitType, axis), limitValue) + args = (constraint, limitType, axis) + maya.cmds.setAttr("%s.%sSpringEnabled%s" % args, 1) + maya.cmds.setAttr("%s.%sSpringStiffness%s" % args, limitValue) def _constraintJoint(self, joint, rigidShapes): ai = joint.rigidbody_index_a @@ -158,4 +150,4 @@ def _createJoint(self, rigidShapes): def generate(self, jointNames): rigidObjects, rigidShapes = self._createRigidObjects(jointNames) - #self._createJoint(rigidShapes) \ No newline at end of file + self._createJoint(rigidShapes) \ No newline at end of file diff --git a/util.py b/util.py index b9db244..25137bc 100644 --- a/util.py +++ b/util.py @@ -4,4 +4,7 @@ def setJpName(objName, jpName): maya.cmds.addAttr(objName, dt="string", ln="jpName", h=False, k=False) - maya.cmds.setAttr("%s.jpName" % objName, jpName, typ="string") \ No newline at end of file + maya.cmds.setAttr("%s.jpName" % objName, jpName, typ="string") + +def getJpName(objName): + return maya.cmds.getAttr("%s.jpName" % objName) \ No newline at end of file