def _createMaterialNode(self, materialData, index): materialName = "mmd_material" if self.dictFlag: materialName = self.nameDict[index] material = None try: material = cmds.shadingNode("blinn", asShader=1, name='%s' % materialName) except: material = cmds.shadingNode("blinn", asShader=1) # 不正な名前のマテリアルはこれ util.setJpName(material, materialData.name) util.setInteger(material, "drawOrder", index) shader_group = cmds.sets(renderable=1, noSurfaceShader=1, empty=1, name='%sSG' % material) #cmds.sets(model, e=1, forceElement=shader_group) # ここは無視しておこう cmds.connectAttr("%s.outColor" % material, "%s.surfaceShader" % shader_group, f=1) return material, shader_group
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 _duplicateMesh(self): morphs = self.mmdData.morphs morphNames = [] morphPanelCounts = [0, 0, 0, 0, 0] for i in range(len(morphs)): morph = morphs[i] name = "expression" if self.dictFlag: name = "exp_" + self.nameDict[i] morphName = maya.cmds.duplicate(self.polyName, n=name)[0] util.setJpName(morphName, morphs[i].name) morphNames.append(morphName) morphPanelCounts[morph.panel] += 1 count = morphPanelCounts[morph.panel] maya.cmds.select(morphName) maya.cmds.move(8 * count, morph.panel * 8, -(morph.panel * 8)) return morphNames
def _createRigidbodies(self, jointNames): rigids = self.mmdData.rigidbodies shapes = [] for i in range(len(rigids)): rigid = rigids[i] maya.cmds.select(d=True) pCube = self._createPostureCube(rigid) pCube = maya.cmds.rename(pCube, "rcube_" + self.nameDict[i]) maya.cmds.select(pCube) shape = bullet.RigidBody.CreateRigidBody().executeCommandCB()[1] shape = maya.cmds.rename(shape, "rigid_" + self.nameDict[i]) util.setJpName(shape, rigid.name) self._setColliderSize(shape, rigid) self._setParams(shape, rigid.param) self._constraintRigidbody(shape, pCube, rigid, jointNames) self._setCollisionFilter(shape, rigid) shapes.append(shape) return shapes