예제 #1
0
    def buildSceneContent(self, fileType, sequenceNumber, shotNumber):
        '''
        Create scene content: import characters, environments, props, materials etc.

        Render scene schema:
            [Render obj]      [Environment]     [Characters]     [Props]      [FX]
            - materials       - Env             - char 1         - prop 1     - fx 1
            - lights                            - char 2         - prop 2     - fx 2
            - camera                            - ...            - ...        - ...

        :param fileType:
        :param sequenceNumber:
        :param shotNumber:
        :return:
        '''

        # Create Render scene
        if fileType == dna.fileTypes['renderScene']:

            # Get shot data
            shotGenes = dna.getShotGenes(sequenceNumber, shotNumber)
            env_data = shotGenes['environmentData']

            # Initialize scene
            scenePath = hou.hipFile.path()

            # SETUP SCENE (end frame ...)
            frameEnd = shotGenes['shotData']['sg_cut_out']
            hou.playbar.setFrameRange(dna.frameStart, frameEnd)
            hou.playbar.setPlaybackRange(dna.frameStart, frameEnd)

            # [Render obj]
            # Add Material lib HDA
            mat_data = env_data['materials']
            ML = sceneRoot.createNode(mat_data['hda_name'], mat_data['name'])
            ML.setPosition([0, 0])
            # Add lights HDA
            lit_data = env_data['lights']
            LIT = sceneRoot.createNode(lit_data['hda_name'], lit_data['name'])
            LIT.setPosition([0, -dna.nodeDistance_y])
            # Add Camera via ABC. Done in Import ANM

            # [Environment]
            ENV = sceneRoot.createNode(env_data['hda_name'], env_data['code'])
            ENV.setPosition([dna.nodeDistance_x, 0])

            # [Characters]
            char_data = shotGenes['charactersData']
            for n, character in enumerate(char_data):
                CHAR = self.createContainer(sceneRoot,
                                            char_data[n]['code'],
                                            mb=1)
                CHAR.setPosition(
                    [2 * dna.nodeDistance_x, n * dna.nodeDistance_y])

            # [Props]
            # No props for NSI project. Skipnig

            # [FX]
            fx_data = shotGenes['fxData']
            for n, FX in enumerate(fx_data):
                FX = self.createContainer(sceneRoot, fx_data[n]['code'], mb=1)
                FX.setPosition(
                    [3 * dna.nodeDistance_x, n * dna.nodeDistance_y])

            # SETUP MANTRA OUTPUT
            # Create mantra render node
            mantra = outRoot.createNode('ifd', 'RENDER')
            # Render file version setup
            renderFile = dna.buildFilePath('001',
                                           dna.fileTypes['renderSequence'],
                                           scenePath=scenePath)
            # Create folder for render file
            fileLocation = dna.analyzeFliePath(renderFile)['fileLocation']
            if not os.path.exists(fileLocation):
                # Make 001 folder
                os.makedirs(fileLocation)
            else:
                # If 001 file exists get latest version
                latestVersion = dna.extractLatestVersionFolder(fileLocation)
                nextVersion = '{:03d}'.format(int(latestVersion) + 1)
                # Build latest existing path
                renderFile = dna.buildFilePath(nextVersion,
                                               dna.fileTypes['renderSequence'],
                                               scenePath=scenePath)
                os.makedirs(dna.analyzeFliePath(renderFile)['fileLocation'])
                # Localize path (add $JOB)
                renderFile = renderFile.replace(dna.root3D, '$JOB')

            # Setup Mantra parameters
            mantra.parm('vm_picture').set(renderFile)
            cameraName = dna.nameCamera.format(sequenceNumber, shotNumber)
            mantra.parm('camera').set(
                '/obj/{}/cameraProperties'.format(cameraName))
            # Set common parameters from preset
            for param, value in dna.renderSettings['common'].iteritems():
                mantra.parm(param).set(value)
            # Set DRAFT parameters
            for param, value in dna.renderSettings['draft'].iteritems():
                mantra.parm(param).set(value)
예제 #2
0
# 256 Pipeline Tools
# Import Character Caches to a render scene

import hou

from EVE.dna import dna
reload(dna)

# Get shot and sequence number from the scene name
scenePath = hou.hipFile.path()
pathMap = dna.analyzeFliePath(scenePath)
sequenceNumber = pathMap['sequenceNumber']
shotNumber = pathMap['shotNumber']
# Get shot data
shotGenes = dna.getShotGenes(sequenceNumber, shotNumber)
# Get scene root
sceneRoot = hou.node('/obj/')


def importCameraAnim():
    # HIP format
    # Build camera path to the 001 version of ABC: '<root3D>/geo/SHOTS/010/SHOT_010/CAM/E010_S010_001.abc'
    pathCamera = dna.buildFilePath('001',
                                   dna.fileTypes['cacheCamera'],
                                   scenePath=scenePath)
    print pathCamera
    # Build path latest version. TBD
    sceneRoot.loadItemsFromFile(pathCamera)

    # ABC format
    """
예제 #3
0
    def buildSceneContent(self, fileType, sequenceNumber, shotNumber):
        '''
        Create scene content: import characters, environments, materials etc.
        :param fileType:
        :param sequenceNumber:
        :param shotNumber:
        :return:
        '''

        # Create Render scene
        if fileType == dna.fileTypes['renderScene']:
            # Get shot data
            shotData, assetsData, environmentData, charactersData = dna.getShotGenes(sequenceNumber, shotNumber)

            # Initialize scene
            scenePath = hou.hipFile.path()

            # BUILD ENVIRONMENT
            # Proxy
            ENV_PRX = self.createContainer(sceneRoot, dna.nameEnvProxy)
            self.createHDA(ENV_PRX, environmentData['proxy_hda']['hda_name'], environmentData['proxy_hda']['name'])
            ENV_PRX.setPosition([0, 0])
            # Base
            ENVIRONMENT = self.createContainer(sceneRoot, dna.nameEnv, bbox=2, disp=0)
            self.createHDA(ENVIRONMENT, environmentData['hda_name'], environmentData['code'])
            ENVIRONMENT.setPosition([0, -dna.nodeDistance_y])
            # Animation
            ENV_ANM = self.createContainer(sceneRoot, dna.nameEnvAnim, bbox=2, mb=1)
            self.createHDA(ENV_ANM, environmentData['animation_hda']['hda_name'], environmentData['animation_hda']['name'])
            ENV_ANM.setPosition([0, -2 * dna.nodeDistance_y])

            CROWDS = self.createContainer(sceneRoot, dna.nameCrowds, bbox=2, mb=1)
            self.createHDA(CROWDS, environmentData['crowds_hda']['hda_name'], environmentData['crowds_hda']['name'])
            CROWDS.setPosition([0, -3 * dna.nodeDistance_y])

            # BUILD CHARACTERS
            # Create characters container
            CHARACTERS = self.createContainer(sceneRoot, dna.nameChars, mb=1)
            CHARACTERS.setPosition([0, -4 * dna.nodeDistance_y])

            # Create nodes to pull character caches
            self.buildCharacterLoaders(CHARACTERS, charactersData)

            # IMPORT MATERIALS
            # Create Geometry node in scene root
            ML = sceneRoot.createNode('ml_general', dna.nameMats)
            ML.setPosition([dna.nodeDistance_x, 0])

            # IMPORT ENV LIGHTS
            LIT = sceneRoot.createNode(environmentData['light_hda']['hda_name'], environmentData['light_hda']['name'])
            LIT.setPosition([dna.nodeDistance_x, -dna.nodeDistance_y])

            # SETUP OUTPUT
            # Create mantra render node
            mantra = outRoot.createNode('ifd', 'RENDER')

            # Render file version setup
            # renderFile = '$JOB/render/010/SHOT_040/001/E010_S040_001.$F.exr'
            renderFile = dna.buildFliePath('001', dna.fileTypes['renderFile'], scenePath=scenePath)
            fileLocation = dna.analyzeFliePath(renderFile)['fileLocation']
            if not os.path.exists(fileLocation):
                # Make 001 folder
                os.makedirs(fileLocation)
            else:
                # If 001 file exists get latest version
                latestVersion = dna.extractLatestVersionFolder(fileLocation)
                nextVersion = '{:03d}'.format(int(latestVersion) + 1)
                # Build latest existing path
                renderFile = dna.buildFliePath(nextVersion, dna.fileTypes['renderFile'], scenePath=scenePath)
                os.makedirs(dna.analyzeFliePath(renderFile)['fileLocation'])
                # Localize path (add $JOB)
                renderFile = renderFile.replace(dna.root3D, '$JOB')

            # Setup Mantra parameters
            mantra.parm('vm_picture').set(renderFile)
            mantra.parm('camera').set('/obj/E{0}_S{1}'.format(sequenceNumber, shotNumber))
            # Set common parameters from preset
            for param, value in dna.renderSettings['common'].iteritems():
                mantra.parm(param).set(value)
            # Set DRAFT parameters
            for param, value in dna.renderSettings['draft'].iteritems():
                mantra.parm(param).set(value)

            # SETUP SCENE (end frame ...)
            frameEnd = shotData['sg_cut_out']
            hou.playbar.setFrameRange(dna.frameStart, frameEnd)
            hou.playbar.setPlaybackRange(dna.frameStart, frameEnd)

            # IMPORT ANIMATION
            # Import characters caches
            self.importAnimation(scenePath, charactersData)

        # Save scene
        hou.hipFile.save()
예제 #4
0
    def buildSceneContent(self, fileType, sequenceNumber, shotNumber):
        '''
        Create scene content: import characters, environments, props, materials etc.

        Render scene schema:
            [Render obj]      [Environment]     [Characters]     [Props]      [FX]
            - materials       - Env             - char 1         - prop 1     - fx 1
            - lights                            - char 2         - prop 2     - fx 2
            - camera                            - ...            - ...        - ...

        :param fileType:
        :param sequenceNumber:
        :param shotNumber:
        :return:
        '''

        # Create Render scene
        if fileType == dna.fileTypes['renderScene']:

            # Get shot data
            shotGenes = dna.getShotGenes(sequenceNumber, shotNumber)
            env_data = shotGenes['environmentData']

            # Initialize scene
            scenePath = hou.hipFile.path()

            # SETUP SCENE (end frame ...)
            frameEnd = shotGenes['shotData']['sg_cut_out']
            hou.playbar.setFrameRange(dna.frameStart, frameEnd)
            hou.playbar.setPlaybackRange(dna.frameStart, frameEnd)

            # [Render obj]
            # Add Material lib HDA
            mat_data = env_data['materials']
            ML = sceneRoot.createNode(mat_data['hda_name'], mat_data['name'])
            ML.setPosition([0, 0])
            # Add lights HDA
            lit_data = env_data['lights']
            LIT = sceneRoot.createNode(lit_data['hda_name'], lit_data['name'])
            LIT.setPosition([0, -dna.nodeDistance_y])
            # Add Camera via ABC. Done in Import ANM

            # [Environment]
            ENV = sceneRoot.createNode(env_data['hda_name'], env_data['code'])
            ENV.setPosition([dna.nodeDistance_x, 0])

            # [Characters]
            char_data = shotGenes['charactersData']
            for n, character in enumerate(char_data):
                CHAR = dna.createContainer(sceneRoot,
                                           char_data[n]['code'],
                                           mb=1)
                CHAR.setPosition(
                    [2 * dna.nodeDistance_x, n * dna.nodeDistance_y])

            # [Props]
            # No props for NSI project.

            # [FX]
            fx_data = shotGenes['fxData']
            for n, FX in enumerate(fx_data):
                FX = sceneRoot.createNode(FX['hda_name'], FX['code'])
                FX.setPosition(
                    [3 * dna.nodeDistance_x, n * dna.nodeDistance_y])

            # SETUP MANTRA OUTPUT
            # Create mantra render node
            mantra = outRoot.createNode('ifd', dna.mantra)

            # Render sequence setup
            renderSequence = dna.buildRenderSequencePath(scenePath)

            # Setup Mantra parameters
            mantra.parm('vm_picture').set(renderSequence)
            cameraName = dna.cameraName.format(sequenceNumber, shotNumber)
            mantra.parm('camera').set('/obj/{}'.format(cameraName))
            # Set common parameters from preset
            for param, value in dna.renderSettings['common'].iteritems():
                mantra.parm(param).set(value)
            # Set DRAFT parameters
            for param, value in dna.renderSettings['draft'].iteritems():
                mantra.parm(param).set(value)