Skip to content

Commit

Permalink
上手く行かないので剛体は延期
Browse files Browse the repository at this point in the history
どうやらMMDのBulletは魔改造しているらしく、もしかするとそのままだと動かないかもしれない
  • Loading branch information
GRGSIBERIA committed May 19, 2014
1 parent 3705740 commit c24d23e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 25 deletions.
4 changes: 2 additions & 2 deletions bonegen.py
Expand Up @@ -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を各チャンネルに行う
Expand Down
3 changes: 3 additions & 0 deletions expgen.py
Expand Up @@ -5,6 +5,7 @@
import maya.OpenMaya

import filemanager
import util

class ExpressionGenerator:

Expand Down Expand Up @@ -36,13 +37,15 @@ 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)
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.setJpName(groupName, panelJpNames[panel])
maya.cmds.setAttr("%s.v" % groupName, 0)
groups.append(groupName)
return groups
Expand Down
12 changes: 6 additions & 6 deletions mmdcommand.py
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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):
Expand Down
24 changes: 8 additions & 16 deletions rigidgen.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -158,4 +150,4 @@ def _createJoint(self, rigidShapes):

def generate(self, jointNames):
rigidObjects, rigidShapes = self._createRigidObjects(jointNames)
#self._createJoint(rigidShapes)
self._createJoint(rigidShapes)
5 changes: 4 additions & 1 deletion util.py
Expand Up @@ -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")
maya.cmds.setAttr("%s.jpName" % objName, jpName, typ="string")

def getJpName(objName):
return maya.cmds.getAttr("%s.jpName" % objName)

0 comments on commit c24d23e

Please sign in to comment.