コード例 #1
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
コード例 #2
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
コード例 #3
0
def readMeshes(file, hasBones):
    meshes = []
    meshCount = ascii_ops.readInt(file)

    for meshId in range(meshCount):
        # Name
        meshName = ascii_ops.readString(file)
        if not meshName:
            meshName = 'xxx'
        # print('Mesh Name:', meshName)
        # uv Count
        uvLayerCount = ascii_ops.readInt(file)
        # Textures
        textures = []
        textureCount = ascii_ops.readInt(file)
        for texId in range(textureCount):
            textureFile = ntpath.basename(ascii_ops.readString(file))
            # print('Texture file', textureFile)
            uvLayerId = ascii_ops.readInt(file)

            xpsTexture = xps_types.XpsTexture(texId, textureFile, uvLayerId)
            textures.append(xpsTexture)

        # Vertices
        vertex = []
        vertexCount = ascii_ops.readInt(file)
        for vertexId in range(vertexCount):
            coord = readXYZ(file)
            normal = readXYZ(file)
            vertexColor = read4Int(file)

            uvs = []
            for uvLayerId in range(uvLayerCount):
                uvVert = readUvVert(file)
                uvs.append(uvVert)
                # if ????
                # tangent????
                # tangent = read4float(file)

            boneWeights = []
            if hasBones:
                # if cero bones dont have weights to read
                boneIdx = readBoneId(file)
                boneWeight = readBoneWeight(file)

                for idx in range(len(boneIdx)):
                    boneWeights.append(
                        xps_types.BoneWeight(boneIdx[idx], boneWeight[idx]))
            xpsVertex = xps_types.XpsVertex(
                vertexId, coord, normal, vertexColor, uvs, boneWeights)
            vertex.append(xpsVertex)

        # Faces
        faces = []
        triCount = ascii_ops.readInt(file)
        for i in range(triCount):
            triIdxs = readTriIdxs(file)
            faces.append(triIdxs)
        xpsMesh = xps_types.XpsMesh(
            meshName, textures, vertex, faces, uvLayerCount)
        meshes.append(xpsMesh)
    return meshes
コード例 #4
0
def readMeshes(file, hasBones):
    meshes = []
    meshCount = ascii_ops.readInt(file)

    for meshId in range(meshCount):
        # Name
        meshName = ascii_ops.readString(file)
        if not meshName:
            meshName = 'xxx'
        # print('Mesh Name:', meshName)
        # uv Count
        uvLayerCount = ascii_ops.readInt(file)
        # Textures
        textures = []
        textureCount = ascii_ops.readInt(file)
        for texId in range(textureCount):
            textureFile = ntpath.basename(ascii_ops.readString(file))
            # print('Texture file', textureFile)
            uvLayerId = ascii_ops.readInt(file)

            xpsTexture = xps_types.XpsTexture(texId, textureFile, uvLayerId)
            textures.append(xpsTexture)

        # Vertices
        vertex = []
        vertexCount = ascii_ops.readInt(file)
        for vertexId in range(vertexCount):
            coord = readXYZ(file)
            normal = readXYZ(file)
            vertexColor = read4Int(file)

            uvs = []
            for uvLayerId in range(uvLayerCount):
                uvVert = readUvVert(file)
                uvs.append(uvVert)
                # if ????
                # tangent????
                # tangent = read4float(file)

            boneWeights = []
            if hasBones:
                # if cero bones dont have weights to read
                boneIdx = readBoneId(file)
                boneWeight = readBoneWeight(file)

                for idx in range(len(boneIdx)):
                    boneWeights.append(
                        xps_types.BoneWeight(boneIdx[idx], boneWeight[idx]))
            xpsVertex = xps_types.XpsVertex(vertexId, coord, normal,
                                            vertexColor, uvs, boneWeights)
            vertex.append(xpsVertex)

        # Faces
        faces = []
        triCount = ascii_ops.readInt(file)
        for i in range(triCount):
            triIdxs = readTriIdxs(file)
            faces.append(triIdxs)
        xpsMesh = xps_types.XpsMesh(meshName, textures, vertex, faces,
                                    uvLayerCount)
        meshes.append(xpsMesh)
    return meshes