Exemplo n.º 1
0
def run():
    dataBase = '/var/tmp/downloads/lol/DATA/Characters/'
    sknFile = 'Ryze/Ryze.skn'
    sklFile = 'Ryze/Ryze.skl'

    sklHeader, boneDict = lolSkeleton.importSKL(dataBase + sklFile)
    lolSkeleton.buildSKL(boneDict)

    sknHeader, materials, indices, vertices = lolMesh.importSKN(dataBase + sknFile)
    lolMesh.buildMesh(dataBase + sknFile)

    meshObj = bpy.data.objects['Mesh']
    armObj = bpy.data.objects['Armature']

    lolMesh.addDefaultWeights(boneDict, vertices, armObj, meshObj)
Exemplo n.º 2
0
def run():
    dataBase = '/var/tmp/downloads/lol/DATA/Characters/'
    sknFile = 'Ryze/Ryze.skn'
    sklFile = 'Ryze/Ryze.skl'

    sklHeader, boneDict = lolSkeleton.importSKL(dataBase + sklFile)
    lolSkeleton.buildSKL(boneDict)

    sknHeader, materials, indices, vertices = lolMesh.importSKN(dataBase +
                                                                sknFile)
    lolMesh.buildMesh(dataBase + sknFile)

    meshObj = bpy.data.objects['Mesh']
    armObj = bpy.data.objects['Armature']

    lolMesh.addDefaultWeights(boneDict, vertices, armObj, meshObj)
Exemplo n.º 3
0
def import_char(MODEL_DIR="", SKN_FILE="", SKL_FILE="", DDS_FILE="",
        CLEAR_SCENE=True, APPLY_WEIGHTS=True, APPLY_TEXTURE=True):
    '''Import a LoL Character
    MODEL_DIR:  Base directory of the model you wish to import.
    SKN_FILE:  .skn mesh file for the character
    SKL_FILE:  .skl skeleton file for the character
    DDS_FILE:  .dds texture file for the character
    CLEAR_SCENE: remove existing meshes, armatures, surfaces, etc.
                 before importing
    APPLY_WEIGHTS:  Import bone weights from the mesh file
    APPLY_TEXTURE:  Apply the skin texture

    !!IMPORTANT!!:
    If you're running this on a windows system make sure
    to escape the backslashes in the model directory you give.

    BAD:  c:\\path\\to\\model
    GOOD: c:\\\\path\\\\to\\\\model
    '''
    import bpy
    import lolMesh, lolSkeleton
    from os import path

    if CLEAR_SCENE:
        for type in ['MESH', 'ARMATURE', 'LATTICE', 'CURVE', 'SURFACE']:
            bpy.ops.object.select_by_type(extend=False, type=type)
            bpy.ops.object.delete()

    if SKL_FILE:
        SKL_FILEPATH=path.join(MODEL_DIR, SKL_FILE)
        print(SKL_FILEPATH)
        sklHeader, boneDict = lolSkeleton.importSKL(SKL_FILEPATH)
        lolSkeleton.buildSKL(boneDict)
        armObj = bpy.data.objects['Armature']
        armObj.name ='lolArmature'

    if SKN_FILE:
        SKN_FILEPATH=path.join(MODEL_DIR, SKN_FILE)
        sknHeader, materials, indices, vertices = lolMesh.importSKN(SKN_FILEPATH)
        lolMesh.buildMeshNative(SKN_FILEPATH)
        meshObj = bpy.data.objects['lolMesh']
        #meshObj.name = 'lolMesh'
        #Presently io_scene_obj.load() does not import vertex normals, 
        #so do it ourselves
        #for id, vtx in enumerate(meshObj.data.vertices):
        #    vtx.normal = vertices[id]['normal']
        
    if SKN_FILE and SKL_FILE and APPLY_WEIGHTS:
        lolMesh.addDefaultWeights(boneDict, vertices, armObj, meshObj)

    if DDS_FILE and APPLY_TEXTURE:
        DDS_FILEPATH=path.join(MODEL_DIR, DDS_FILE)
        bpy.ops.object.mode_set(mode='OBJECT')
        bpy.ops.object.select_all(action='DESELECT')
        #bpy.data.objects['lolMesh'].select = True
        #bpy.ops.object.mode_set(mode='EDIT')

        img = bpy.data.images.new(DDS_FILE)
        img.filepath=DDS_FILEPATH
        img.source = 'FILE'

        tex = bpy.data.textures.new('lolTexture', type='IMAGE')
        tex.image = img
        mat = bpy.data.materials.new(name=tex.name)


        mtex = mat.texture_slots.add()
        mtex.texture = tex
        mtex.texture_coords = 'UV'
        mtex.use_map_color_diffuse = True

        meshObj.data.materials.append(mat)

        meshObj.data.uv_textures[0].data[0].image = img
        meshObj.data.uv_textures[0].data[0].use_image = True
        meshObj.data.uv_textures[0].data[0].blend_type = 'ALPHA'