def getVertBoneMapping(skel, skeletonMesh): from animation import VertexBoneWeights vertBoneMapping = {} # Format: { boneName: [(vertIdx, weight), ...], ... } if not hasattr(skeletonMesh, "boneShape"): raise RuntimeError( "Specified mesh object %s is not a skeleton mesh. Make sure it is created using meshFromSkeleton()" % skeletonMesh) type = skeletonMesh.boneShape if type == 'axis': global _axismesh_ if _axismesh_ is None: import geometry3d _axismesh_ = geometry3d.AxisMesh(scale=0.5) nVertsPerBone = _axismesh_.getVertexCount() else: nVertsPerBone = len(SHAPE_VECTORS[type]) #nBones = len(skel.getBones()) #nVertsPerBone = int(mesh.getVertexCount()/nBones) offset = 0 for bone in skel.getBones( ): # We assume that skeleton mesh has bones in breadt-first order verts = range(offset, offset + nVertsPerBone) weights = np.repeat(1, nVertsPerBone) vertBoneMapping[bone.name] = zip(verts, weights) offset = offset + nVertsPerBone return VertexBoneWeights( vertBoneMapping) # , nVertsPerBone*skel.getBoneCount())