コード例 #1
0
ファイル: dumpContents.py プロジェクト: iboshkov/lolblender
def cvsPrintSkn(filename, start=0, end=-1, returnStr = True, **options):
    header, materials, indices, vertices = lolMesh.importSKN(filename)
    headerStr = ""
    if(options['PRINT_HEADER']):
        headerStr+="#magic, matHeader, numObjects\n"
        headerStr += "%d,%d,%d\n" % (header['magic'], 
            header['matHeader'], header['numObjects']) 

    materialStr = ""
    if(options['PRINT_MATERIALS']):
        materialStr += "#numMaterials, name, startVertex, numVertices,"
        materialStr += "startIndex, numIndices\n"
        for material in materials:
            materialStr += \
            "%d,%s,%d,%d,%d,%d\n" %\
            (material['numMaterials'], bytes.decode(material['name']).strip('\x00'),material['startVertex'], \
            material['numVertices'], material['startIndex'], material['numIndices'])

    indexStr = ""
    if(options['PRINT_INDICES']):
        indexStr+="#Index list"
        for indx in indices:
            indexStr += "%d," %(indx[0],)

        indexStr+="\n"

    vertexStr = ""
    if(options['PRINT_VERTICES']):
        vertexStr+="#pos_x, pos_y, pos_z,"
        vertexStr+="boneIndex_0, boneIndex_1, boneIndex_2, boneIndex_3,"
        vertexStr+="norm_x, norm_y, norm_z,"
        vertexStr+="boneWeight_0, boneWeight_1, boneWeight_2, boneWeight_3,"
        vertexStr+="uv_u, uv_v\n"
        for indx, vtx in enumerate(vertices[start:stop]):
            vertexStr += \
                "%d,%f,%f,%f,%d,%d,%d,%d,"%(start+indx, 
                    vtx['position'][0], vtx['position'][1],vtx['position'][2],
                    vtx['boneIndex'][0],vtx['boneIndex'][1],vtx['boneIndex'][2],vtx['boneIndex'][3])
            vertexStr += \
                "%f,%f,%f,%f,%f,%f,%f,"%\
                (vtx['normal'][0],vtx['normal'][1],vtx['normal'][2],\
                vtx['weights'][0],vtx['weights'][1],vtx['weights'][2],vtx['weights'][3])
            vertexStr += "%f,%f\n"%(vtx['texcoords'][0],vtx['texcoords'][1])

    if returnStr == True:
        return headerStr+materialStr+indexStr+vertexStr
    else:
        print(headerStr+materialStr+indexStr+vertexStr)
コード例 #2
0
def cvsPrintSkn(filename, start=0, end=-1, returnStr=True, **options):
    header, materials, indices, vertices = lolMesh.importSKN(filename)
    headerStr = ""
    if (options['PRINT_HEADER']):
        headerStr += "#magic, matHeader, numObjects\n"
        headerStr += "%d,%d,%d\n" % (header['magic'], header['matHeader'],
                                     header['numObjects'])

    materialStr = ""
    if (options['PRINT_MATERIALS']):
        materialStr += "#numMaterials, name, startVertex, numVertices,"
        materialStr += "startIndex, numIndices\n"
        for material in materials:
            materialStr += \
            "%d,%s,%d,%d,%d,%d\n" %\
            (material['numMaterials'], bytes.decode(material['name']).strip('\x00'),material['startVertex'], \
            material['numVertices'], material['startIndex'], material['numIndices'])

    indexStr = ""
    if (options['PRINT_INDICES']):
        indexStr += "#Index list"
        for indx in indices:
            indexStr += "%d," % (indx[0], )

        indexStr += "\n"

    vertexStr = ""
    if (options['PRINT_VERTICES']):
        vertexStr += "#pos_x, pos_y, pos_z,"
        vertexStr += "boneIndex_0, boneIndex_1, boneIndex_2, boneIndex_3,"
        vertexStr += "norm_x, norm_y, norm_z,"
        vertexStr += "boneWeight_0, boneWeight_1, boneWeight_2, boneWeight_3,"
        vertexStr += "uv_u, uv_v\n"
        for indx, vtx in enumerate(vertices[start:stop]):
            vertexStr += \
                "%d,%f,%f,%f,%d,%d,%d,%d,"%(start+indx,
                    vtx['position'][0], vtx['position'][1],vtx['position'][2],
                    vtx['boneIndex'][0],vtx['boneIndex'][1],vtx['boneIndex'][2],vtx['boneIndex'][3])
            vertexStr += \
                "%f,%f,%f,%f,%f,%f,%f,"%\
                (vtx['normal'][0],vtx['normal'][1],vtx['normal'][2],\
                vtx['weights'][0],vtx['weights'][1],vtx['weights'][2],vtx['weights'][3])
            vertexStr += "%f,%f\n" % (vtx['texcoords'][0], vtx['texcoords'][1])

    if returnStr == True:
        return headerStr + materialStr + indexStr + vertexStr
    else:
        print(headerStr + materialStr + indexStr + vertexStr)
コード例 #3
0
def prettyPrintSkn(filename, start=0, end=-1, returnStr=True, **options):
    header, materials, indices, vertices = lolMesh.importSKN(filename)
    headerStr = ""
    if (options['PRINT_HEADER']):
        headerStr += "magic:%d\nmatHeader:%d\nnumObjects:%d\nnumMaterials:%d\n\n" % (
            header.magic, header.matHeader, header.numObjects, len(materials))

    materialStr = ""
    if (options['PRINT_MATERIALS']):
        if header.matHeader == 0:
            materialStr += "No material blocks present\n\n"
        else:
            for material in materials:
                materialStr += \
                "name:%s\nstartVertex:%d\tnumVertices:%d\nstartIndex:%d\tnumIndices:%d\n\n" %\
                (bytes.decode(material.name).strip('\x00'),material.startVertex, \
                material.numVertices, material.startIndex, material.numIndices)

    indexStr = ""
    if (options['PRINT_INDICES']):
        for indx in indices:
            indexStr += "%d\n" % (indx[0], )

    vertexStr = ""
    if (options['PRINT_VERTICES']):
        for indx, vtx in enumerate(vertices[start:stop]):
            vertexStr += \
                "%d\tpos:(%f,%f,%f)\tboneIndx:(%d,%d,%d,%d)\n"%(start+indx,
                    vtx.position[0], vtx.position[1],vtx.position[2],
                    vtx.boneIndex[0],vtx.boneIndex[1],vtx.boneIndex[2],vtx.boneIndex[3])
            vertexStr += \
                "\tnorm:(%f,%f,%f)\tweights:(%f,%f,%f,%f)\n"%\
                (vtx.normal[0],vtx.normal[1],vtx.normal[2],\
                vtx.weights[0],vtx.weights[1],vtx.weights[2],vtx.weights[3])
            vertexStr += "\tuvs:(%f, %f)\n" % (vtx.texcoords[0],
                                               vtx.texcoords[1])

    if returnStr == True:
        return headerStr + materialStr + indexStr + vertexStr
    else:
        print(headerStr + materialStr + indexStr + vertexStr)
コード例 #4
0
ファイル: dumpContents.py プロジェクト: iboshkov/lolblender
def prettyPrintSkn(filename, start=0, end=-1, returnStr = True, **options):
    header, materials, indices, vertices = lolMesh.importSKN(filename)
    headerStr = ""
    if(options['PRINT_HEADER']):
        headerStr += "magic:%d\nmatHeader:%d\nnumObjects:%d\nnumMaterials:%d\n\n" % (header.magic, 
            header.matHeader, header.numObjects, len(materials)) 

    materialStr = ""
    if(options['PRINT_MATERIALS']):
        if header.matHeader == 0:
            materialStr +="No material blocks present\n\n"
        else:
            for material in materials:
                materialStr += \
                "name:%s\nstartVertex:%d\tnumVertices:%d\nstartIndex:%d\tnumIndices:%d\n\n" %\
                (bytes.decode(material.name).strip('\x00'),material.startVertex, \
                material.numVertices, material.startIndex, material.numIndices)

    indexStr = ""
    if(options['PRINT_INDICES']):
        for indx in indices:
            indexStr += "%d\n" %(indx[0],)

    vertexStr = ""
    if(options['PRINT_VERTICES']):
        for indx, vtx in enumerate(vertices[start:stop]):
            vertexStr += \
                "%d\tpos:(%f,%f,%f)\tboneIndx:(%d,%d,%d,%d)\n"%(start+indx, 
                    vtx.position[0], vtx.position[1],vtx.position[2],
                    vtx.boneIndex[0],vtx.boneIndex[1],vtx.boneIndex[2],vtx.boneIndex[3])
            vertexStr += \
                "\tnorm:(%f,%f,%f)\tweights:(%f,%f,%f,%f)\n"%\
                (vtx.normal[0],vtx.normal[1],vtx.normal[2],\
                vtx.weights[0],vtx.weights[1],vtx.weights[2],vtx.weights[3])
            vertexStr += "\tuvs:(%f, %f)\n"%(vtx.texcoords[0],vtx.texcoords[1])

    if returnStr == True:
        return headerStr+materialStr+indexStr+vertexStr
    else:
        print(headerStr+materialStr+indexStr+vertexStr)