Exemple #1
0
def attenString(obj, now, ltype):
    plist = obj.evaluate(attenParms, now)

    atten_start = plist['atten_start'].Value[0]
    atten_type = plist['atten_type'].Value[0]
    atten_dist = plist['atten_dist'].Value[0]
    attenrampenable = plist['attenrampenable'].Value[0]
    rampstart = plist['atten_rampstart'].Value[0]
    rampend = plist['atten_rampend'].Value[0]

    atten = ' attenstart %g' % atten_start

    if atten_type == 'none':
        atten += ' doatten 0'
    elif atten_type == 'half':
        atten += ' doatten 1 atten %g' % atten_dist
    elif atten_type == 'physical':
        atten += ' doatten 2'

    if attenrampenable:
        parmlist = [SohoParm('object:instancename', 'string', [''])]
        obj.evaluate(parmlist, 0)
        hlight = hou.node(parmlist[0].Value[0])
        if hlight:
            attenramp = hlight.parmTuple('attenramp')
            if attenramp:
                rampParms = shopclerks.ifdclerk.IfdParmEval(
                    None, soho.Precision,
                    None).getRampParms(attenramp, hou.timeToFrame(now))
                atten += ' doattenramp 1'
                atten += ' rampstart %g rampend %g' % (rampstart, rampend)
                for rp in rampParms:
                    atten += ' ' + rp[0]
                    atten += ' ' + rp[1]
    return atten
Exemple #2
0
    def get_frame_range(self):
        """returns the frame range of the
        """
        # use the hscript commands to get the frame range
        timeInfo = hou.hscript('tset')[0].split('\n')

        pattern = r'[-0-9\.]+'

        start_frame = int(
            hou.timeToFrame(float(re.search(pattern, timeInfo[2]).group(0))))
        duration = int(re.search(pattern, timeInfo[0]).group(0))
        end_frame = start_frame + duration - 1

        return start_frame, end_frame
Exemple #3
0
def buildShaderString(style, shopname, time, parmnames, options):
    precision = options.get('soho_precision', 12)
    shop = hou.node(shopname)
    shader = '"%s" ' % shop.shaderName(False, style)
    frame = hou.timeToFrame(time)
    comma = False

    args = [ shader ]
    parmeval = oslParmEval( None, precision, options )
    for parm in parmeval.getShaderParms( shop, frame, parmnames ):
        args.extend( parm )
    
    #return shader parameter string
    return ' '.join( args )
Exemple #4
0
    def get_frame_range(self):
        """returns the frame range of the
        """
        # use the hscript commands to get the frame range
        timeInfo = hou.hscript('tset')[0].split('\n')

        pattern = r'[-0-9\.]+'

        start_frame = int(
            hou.timeToFrame(
                float(re.search(pattern, timeInfo[2]).group(0))
            )
        )
        duration = int(re.search(pattern, timeInfo[0]).group(0))
        end_frame = start_frame + duration - 1

        return start_frame, end_frame
Exemple #5
0
def outputMPlayFormatOptions(wrangler, cam, now):
    plist = cam.wrangle(wrangler, _iplay_specific, now)
    rendermode = plist['rendermode'].Value[0]
    framemode = plist['framemode'].Value[0]
    trange = plist['trange'].Value[0]
    curframe = hou.timeToFrame(now)
    if trange:
        frange = cam.wrangleInt(wrangler, 'f', now, [curframe, curframe])
        if len(frange) < 2:
            frange = [curframe, curframe]
    else:
        frange = [curframe, curframe]

    # There are 4 combinations of rendermode and framemode
    #   rendermode/framemode |  append    |  match
    #   ---------------------+------------+-----------
    #         new            | new-append | new-frame
    #       current          |   append   |  replace
    #  However, we only perform "new" render mode if we the render
    #  frame is at the beginning of the frame range
    if abs(curframe - frange[0]) < 0.01:
        rendermode = 'current'
    if rendermode == 'new':
        if framemode == 'append':
            rendermode = 'new-append'
        else:
            rendermode = 'new-frame'
    else:
        if framemode == 'append':
            rendermode = 'append'
        else:
            rendermode = 'replace'
    cmd_declare('plane', 'string', 'IPlay.rendermode', [rendermode])
    frange = '%d %d' % (int(frange[0]), int(frange[1]))
    cmd_declare('plane', 'string', 'IPlay.framerange', [frange])
    cmd_declare('plane', 'float', 'IPlay.currentframe', [curframe])
    rendersource = soho.getDefaultedString('lv_rendersource',
                                           [soho.getOutputDriver().getName()])
    cmd_declare('plane', 'string', 'IPlay.rendersource', rendersource)
Exemple #6
0
abcLists = os.listdir(abcPath)
abcLists = [i for i in abcLists if os.path.splitext(i)[1] == '.abc']
abcLists = [i for i in abcLists if hipSC.lower() in i.lower()]
if len(abcLists) == 0:
    hou.ui.displayMessage('Error: $JOB/abc have not abc File for this scene.',
                          title='Search Path',
                          severity=hou.severityType.Error)
abcLists.sort()
abcFile = abcLists[-1]
abcFullFile = abcPath + '/' + abcFile

# Set FrameRange
timeRange = abc.alembicTimeRange(abcFullFile)
if timeRange is not None:
    hou.playbar.setFrameRange(hou.playbar.frameRange()[0],
                              hou.timeToFrame(timeRange[1]) - 1)
    #hou.playbar.setPlaybackRange(hou.playbar.playbackRange()[0], hou.timeToFrame(timeRange[1])-1)

# Filter Camera, (Need Optimization!!!)
abcMenuTuples = abc.alembicGetObjectPathListForMenu(
    hou.expandString(abcFullFile))
cameraList = []
for i in set(abcMenuTuples):
    cameraABCObject = abc.alembicGetSceneHierarchy(abcFullFile, i)
    if cameraABCObject[1] == 'camera':
        cameraList.append(i)
cameraExclude = [
    '/front/frontShape', '/top/topShape', '/side/sideShape',
    '/persp/perspShape'
]
cameraList = [i for i in cameraList if i not in cameraExclude]
    def get_geo_path_and_part(self, geo_location, sop_path, ext, time_dependent=True):
        SaveLocations = collections.namedtuple(
            "SaveLocations", ["save_path", "pbrt_path", "part"]
        )

        # Since we have two modes of operation, piping to the renderer and saving
        # to a diskfile, our output options need to have two different meanings.
        # Generally when working with relative paths, for diskfiles you want them
        # to be relative to your diskfile, however when piping to a renderer it
        # makes more sense to have relative paths to your $HIP. Technically we could
        # use os.chdir, but his might break other file references within the session.

        if not os.path.isabs(geo_location):
            if self.output_mode == 1:
                # Disk file behavior (diskfile)
                # os.getcwd : /my/project
                # disk_file : /my/project/pbrt/scene.pbrt
                # geo_location : geometry
                # pbrt_path : geometry/filename.ext
                # save_path : /my/project/pbrt/geometry/filename.ext
                diskfile_dir = os.path.dirname(self.disk_file)
                # Note, we can't use os.path.join, since on Windows Houdini still
                # prefers "/"
                diskfile_dir = "." if not diskfile_dir else diskfile_dir
                save_dir = "{}/{}".format(diskfile_dir, geo_location)
            else:
                # Stdout behavior ($HIP)
                # os.getcwd : /my/project
                # geo_location : geometry
                # pbrt_path : geometry/filename.ext
                # save_path : /my/project/geometry/filename.ext
                save_dir = "./{}".format(geo_location)
        else:
            save_dir = geo_location
        pbrt_dir = geo_location

        part_num = self.geometry_parts[sop_path]
        self.geometry_parts[sop_path] += 1

        # TODO: We could be smart and not output frames that are not time dependent.
        #       we can check this via a sohog gdp.globalValue('geo:timedependent')[0]

        frame_str = ""
        if time_dependent:
            frame = hou.timeToFrame(self.now)
            frame_str = ".{frame:g}".format(frame=frame)

        filename = sop_path
        if filename.startswith("/obj/"):
            filename = filename[5:]
        else:
            filename = filename[1:]
        filename = filename.replace("/", "+")
        filename = "{filename}+{part}{frame}.{ext}".format(
            filename=filename, part=part_num, frame=frame_str, ext=ext
        )
        return SaveLocations(
            "{}/{}".format(save_dir, filename),
            "{}/{}".format(pbrt_dir, filename),
            part_num,
        )