Exemplo n.º 1
0
def buildBones():
    bones = []

    id = 0
    name = 'bone1'
    co = [0, 0, 0]
    parentId = -1
    bone = xps_types.XpsBone(id, name, co, parentId)
    bones.append(bone)

    id = 1
    name = 'bone2'
    co = [0.5, 0.5, 0.5]
    parentId = 0
    bone = xps_types.XpsBone(id, name, co, parentId)
    bones.append(bone)
    return bones
Exemplo n.º 2
0
def readBones(file):
    bones = []
    # Bone Count
    boneCount = bin_ops.readUInt32(file)
    for boneId in range(boneCount):
        boneName = readFilesString(file)
        parentId = bin_ops.readInt16(file)
        coords = readXYZ(file)

        xpsBone = xps_types.XpsBone(boneId, boneName, coords, parentId)
        bones.append(xpsBone)
    return bones
Exemplo n.º 3
0
def readBones(file):
    bones = []
    # Bone Count
    boneCount = ascii_ops.readInt(file)
    for boneId in range(boneCount):
        boneName = ascii_ops.readString(file)
        parentId = ascii_ops.readInt(file)
        coords = readXYZ(file)

        xpsBone = xps_types.XpsBone(boneId, boneName, coords, parentId)
        bones.append(xpsBone)
    return bones
Exemplo n.º 4
0
def exportArmature(armature):
    xpsBones = []
    if armature:
        bones = armature.data.bones
        print('Exporting Armature', len(bones), 'Bones')
        # activebones = [bone for bone in bones if bone.layers[0]]
        activebones = bones
        for bone in activebones:
            objectMatrix = armature.matrix_local
            id = bones.find(bone.name)
            name = bone.name
            co = coordTransform(objectMatrix * bone.head_local.xyz)
            parentId = None
            if bone.parent:
                parentId = bones.find(bone.parent.name)
            xpsBone = xps_types.XpsBone(id, name, co, parentId)
            xpsBones.append(xpsBone)
    if not xpsBones:
        xpsBone = xps_types.XpsBone(0, 'root', (0, 0, 0), -1)
        xpsBones.append(xpsBone)

    return xpsBones