예제 #1
0
def importCharacterAnim():
    '''
    Import character animation for the current render scene: set FileCache nodes paths.

    pathCache = $JOB/geo/SHOTS/010/SHOT_010/ROMA/GEO/001/E010_S010_ROMA_001.$F.bgeo.sc
    :return:
    '''

    # For each character in shot
    for characterData in shotGenes['charactersData']:
        characterName = characterData['code']
        fileCacheName = dna.fileCacheName.format(characterName)

        # Get character container or create if not exists
        characterContainer = hou.node('/obj/{0}'.format(characterName))
        if not characterContainer:
            characterContainer = dna.createContainer(sceneRoot,
                                                     characterName,
                                                     mb=1)

        # Get Character Cache node or create if not exists
        characterCache = hou.node('/obj/{0}/{1}'.format(
            characterName, fileCacheName))
        if not characterCache:
            # Create File Cache SOP
            characterCache = characterContainer.createNode(
                'filecache', fileCacheName)
            characterNull = characterContainer.createNode(
                'null', 'OUT_{0}'.format(characterName))
            characterNull.setInput(0, characterCache)
            characterNull.setDisplayFlag(1)
            characterNull.setRenderFlag(1)
            characterContainer.layoutChildren()
            print '>>>> Created Cache Network: {0}'.format(fileCacheName)

        # BUILD CACHE PATH (LATEST VERSION)
        # Build a path to the 001 version of cache
        pathCache = dna.buildFilePath('001',
                                      dna.fileTypes['cacheAnim'],
                                      scenePath=scenePath,
                                      characterName=characterName)

        # Check latest existing version, build new path if exists
        pathCacheFolder = dna.convertPathCache(pathCache)
        latestCacheVersion = dna.extractLatestVersionFolder(pathCacheFolder)
        if latestCacheVersion != '001':
            pathCache = dna.buildFilePath(latestCacheVersion,
                                          dna.fileTypes['cacheAnim'],
                                          scenePath=scenePath,
                                          characterName=characterName)

        # Set path to character cache
        characterCache.parm('file').set(pathCache)
        characterCache.parm('loadfromdisk').set(1)
예제 #2
0
def exportCamera():
    '''
    Export shot camera
    Two options avalable, ABC and HIP. Use HIP currently.
    :return:
    '''

    print '>> Exporting camera...'

    cameraName = dna.cameraName.format(sequenceNumber, shotNumber)
    camera = hou.node('obj/{}'.format(cameraName))
    pathCamera = dna.buildFilePath('001',
                                   dna.fileTypes['cacheCamera'],
                                   scenePath=scenePath)
    dna.createFolder(dna.convertPathCache(pathCamera))
    # Set camera parameters
    camera.parm('far').set(5000)
    camera.parm('resx').set(dna.resolution_HR[0])
    camera.parm('resy').set(dna.resolution_HR[1])

    # HIP export
    listCameraNodes = dna.collectCamera(camera)
    # Export camera to a file
    sceneRoot.saveItemsToFile(listCameraNodes, pathCamera)
    """
    # ABC export
    # Get Camera parent nodes
    listCameraNodes = '{}'.format(camera.name())
    for i in camera.inputAncestors():
        listCameraNodes += ' {}'.format(i.name())


    # Create ROP network
    ROP = sceneRoot.createNode('ropnet')
    ABC = ROP.createNode('alembic')
    ABC.parm('trange').set(1)
    ABC.parm('filename').set(pathCamera)
    ABC.parm('objects').set(listCameraNodes)
    ABC.parm('execute').pressButton()
    ROP.destroy()
    """
    print '>> Exporting camera done: {}'.format(pathCamera)
예제 #3
0
def exportCamera():
    '''
    Export shot camera
    Two options avalable, ABC and HIP. Use HIP currently.
    :return:
    '''
    cameraName = dna.nameCamera.format(sequenceNumber, shotNumber)
    camera = hou.node('obj/{}'.format(cameraName))
    pathCamera = dna.buildFilePath('001',
                                   dna.fileTypes['cacheCamera'],
                                   scenePath=scenePath)
    dna.createFolder(dna.convertPathCache(pathCamera))

    # HIP export
    listCameraNodes = []
    listCameraNodes.extend(camera.inputAncestors())
    listCameraNodes.append(camera)
    # Export camera to a file
    sceneRoot.saveItemsToFile(listCameraNodes, pathCamera)
    """
예제 #4
0
def importCharacterAnim():
    '''
    Import character animation for the current render scene: set FileCache nodes paths.

    pathCache = $JOB/geo/SHOTS/010/SHOT_010/ROMA/GEO/001/E010_S010_ROMA_001.$F.bgeo.sc
    :return:
    '''
    # For each character in shot
    for character in shotGenes['charactersData']:
        characterName = character['code']
        # Get character container
        CHAR = hou.node('/obj/{0}'.format(characterName))
        # Create File Cache SOP
        CACHE = CHAR.createNode('filecache',
                                dna.fileCacheName.format(characterName))

        # BUILD CACHE PATH (LATEST VERSION)
        # Build a path to the 001 version of cache
        pathCache = dna.buildFilePath('001',
                                      dna.fileTypes['cacheAnim'],
                                      scenePath=scenePath,
                                      characterName=characterName)

        # Check latest existing version, build new path if exists
        pathCacheFolder = dna.convertPathCache(pathCache)
        latestCacheVersion = dna.extractLatestVersionFolder(pathCacheFolder)
        if latestCacheVersion != '001':
            pathCache = dna.buildFilePath(latestCacheVersion,
                                          dna.fileTypes['cacheAnim'],
                                          scenePath=scenePath,
                                          characterName=characterName)

        CACHE.parm('file').set(pathCache)
        CACHE.parm('loadfromdisk').set(1)
        NULL = CHAR.createNode('null', 'OUT_{0}'.format(characterName))
        NULL.setInput(0, CACHE)
        NULL.setDisplayFlag(1)
        NULL.setRenderFlag(1)
        CHAR.layoutChildren()