Beispiel #1
0
def main():

    parameters = soho.evaluate(parameterDefines)

    #
    # init soho
    #
    logger = logging.getLogger()
    oldHandlers = logger.handlers
    handler = logging.StreamHandler(stream=sys.__stderr__)
    logger.handlers = [handler]

    ropName = parameters['ropname'].Value[0]
    node = hou.node(ropName)
    vStr = node.type().nameComponents()[-1]
    version = 0 if not vStr else int(vStr)

    now = parameters['now'].Value[0]

    soho.initialize(now, '')
    soho.lockObjects(now)

    if parameters['trange'].Value[0] == 0:
        ff = lf = int(now * parameters['fps'].Value[0] + 1)
    else:
        ff = int(parameters['f'].Value[0])
        lf = int(parameters['f'].Value[1])
    stride = int(parameters['f'].Value[2])

    sourcefiles = parameters['sourcefiles'].Value[0]
    outfile = parameters['outfile'].Value[0]

    try:

        coalesceFiles(outfile, sourcefiles, list(range(ff, lf + 1)), stride)

    except Exception as e:
        soho.error('Failed to stitch USD files: ' + str(e) + '\n' +
                   traceback.format_exc())

    finally:
        logger.handlers = oldHandlers
Beispiel #2
0
def main():

    parameters = soho.evaluate(parameterDefines)

    #
    # init soho
    #
    logger = logging.getLogger()
    oldHandlers = logger.handlers
    handler = logging.StreamHandler( stream = sys.__stderr__ )
    logger.handlers = [handler]

    ropName = parameters['ropname'].Value[0]
    node = hou.node( ropName )
    vStr = node.type().nameComponents()[-1]
    version = 0 if not vStr else int( vStr )

    now = parameters['now'].Value[0]

    soho.initialize(now, '')
    soho.lockObjects(now)

    if parameters['trange'].Value[0] == 0:
        ff = lf = int(now * parameters['fps'].Value[0] + 1)
    else:
        ff = int(parameters['f'].Value[0])
        lf = int(parameters['f'].Value[1])
    stride = int(parameters['f'].Value[2])

    sourcefiles = parameters['sourcefiles'].Value[0]
    outfile = parameters['outfile'].Value[0]

    try:

        coalesceFiles( outfile, sourcefiles, range(ff,lf+1), stride )

    except Exception as e:
        soho.error( 'Failed to stitch USD files: ' + str(e) + '\n' + traceback.format_exc())

    finally:
        logger.handlers = oldHandlers
Beispiel #3
0
###############################################################################

parameterDefines = {
    'f': soho.SohoParm('f', 'real', [1, 1, 1], False),
    'now': soho.SohoParm('state:time', 'real', [0], False, key='now'),
    'destfile': soho.SohoParm('destfile', 'string', [''], False),
    'path': soho.SohoParm('path', 'string', [''], False),
    'reffile': soho.SohoParm('reffile', 'string', [''], False),
}

parameters = soho.evaluate(parameterDefines)

#
# init soho
#
now = parameters['now'].Value[0]
soho.initialize(now, '')
soho.lockObjects(now)

destFile = parameters['destfile'].Value[0]
path = parameters['path'].Value[0]
reffile = parameters['reffile'].Value[0]

try:

    insertReference(destFile, path, reffile)

except Exception as e:

    soho.error('Failed to add USD file reference: ' + str(e))
Beispiel #4
0
def soho_render():
    control_parms = {
        # The time at which the scene is being rendered
        'now': SohoParm('state:time', 'real', [0], False, key='now'),
        'fps': SohoParm('state:fps', 'real', [24], False, key='fps'),
        'camera': SohoParm('camera', 'string', ['/obj/cam1'], False),
    }

    parms = soho.evaluate(control_parms)

    now = parms['now'].Value[0]
    camera = parms['camera'].Value[0]
    fps = parms['fps'].Value[0]

    options = {'state:precision': 6}
    if not soho.initialize(now, camera, options):
        soho.error("Unable to initialize rendering module with given camera")

    object_selection = {
        # Candidate object selection
        'vobject': SohoParm('vobject', 'string', ['*'], False),
        'alights': SohoParm('alights', 'string', ['*'], False),
        'forceobject': SohoParm('forceobject', 'string', [''], False),
        'forcelights': SohoParm('forcelights', 'string', [''], False),
        'excludeobject': SohoParm('excludeobject', 'string', [''], False),
        'excludelights': SohoParm('excludelights', 'string', [''], False),
        'sololight': SohoParm('sololight', 'string', [''], False),
    }

    for cam in soho.objectList('objlist:camera'):
        break
    else:
        soho.error('Unable to find viewing camera for render')

    objparms = cam.evaluate(object_selection, now)

    stdobject = objparms['vobject'].Value[0]
    stdlights = objparms['alights'].Value[0]
    forceobject = objparms['forceobject'].Value[0]
    forcelights = objparms['forcelights'].Value[0]
    excludeobject = objparms['excludeobject'].Value[0]
    excludelights = objparms['excludelights'].Value[0]
    sololight = objparms['sololight'].Value[0]
    forcelightsparm = 'forcelights'

    if sololight:
        stdlights = excludelights = None
        forcelights = sololight
        forcelightsparm = 'sololight'

    # First, we add objects based on their display flags or dimmer values
    soho.addObjects(now, stdobject, stdlights, '', True)
    soho.addObjects(now, forceobject, forcelights, '', False)
    soho.removeObjects(now, excludeobject, excludelights, '')

    # Lock off the objects we've selected
    soho.lockObjects(now)

    with hou.undos.disabler(), scene_state:
        PBRTscene.render(cam, now)
    return
Beispiel #5
0
parameterDefines = {
    'f'         : soho.SohoParm('f', 'real', [1, 1, 1], False),
    'now'       : soho.SohoParm('state:time', 'real', [0], False, key = 'now'),
    'destfile'  : soho.SohoParm('destfile', 'string', [''], False ),
    'path'      : soho.SohoParm('path', 'string', [''], False ),
    'reffile'   : soho.SohoParm('reffile', 'string', [''], False ),
}

parameters = soho.evaluate(parameterDefines)

#
# init soho
#
now = parameters['now'].Value[0]
soho.initialize(now, '')
soho.lockObjects(now)

destFile =  parameters['destfile'].Value[0]
path     =  parameters['path'].Value[0]
reffile  =  parameters['reffile'].Value[0]

try:

    insertReference( destFile, path, reffile )

except Exception as e:

    soho.error( 'Failed to add USD file reference: ' + str(e) )

Beispiel #6
0
def soho_render():
    control_parms = {
        # The time at which the scene is being rendered
        "now": SohoParm("state:time", "real", [0], False, key="now"),
        "camera": SohoParm("camera", "string", ["/obj/cam1"], False),
    }

    parms = soho.evaluate(control_parms)

    now = parms["now"].Value[0]
    camera = parms["camera"].Value[0]

    options = {}
    if not soho.initialize(now, camera, options):
        soho.error("Unable to initialize rendering module with given camera")

    object_selection = {
        # Candidate object selection
        "vobject": SohoParm("vobject", "string", ["*"], False),
        "alights": SohoParm("alights", "string", ["*"], False),
        "forceobject": SohoParm("forceobject", "string", [""], False),
        "forcelights": SohoParm("forcelights", "string", [""], False),
        "excludeobject": SohoParm("excludeobject", "string", [""], False),
        "excludelights": SohoParm("excludelights", "string", [""], False),
        "sololight": SohoParm("sololight", "string", [""], False),
    }

    for cam in soho.objectList("objlist:camera"):
        break
    else:
        soho.error("Unable to find viewing camera for render")

    objparms = cam.evaluate(object_selection, now)

    stdobject = objparms["vobject"].Value[0]
    stdlights = objparms["alights"].Value[0]
    forceobject = objparms["forceobject"].Value[0]
    forcelights = objparms["forcelights"].Value[0]
    excludeobject = objparms["excludeobject"].Value[0]
    excludelights = objparms["excludelights"].Value[0]
    sololight = objparms["sololight"].Value[0]
    forcelightsparm = "forcelights"

    if sololight:
        stdlights = excludelights = ""
        forcelights = sololight
        forcelightsparm = "sololight"

    # First, we add objects based on their display flags or dimmer values
    soho.addObjects(
        now,
        stdobject,
        stdlights,
        "",
        True,
        geo_parm="vobject",
        light_parm="alights",
        fog_parm="",
    )
    soho.addObjects(
        now,
        forceobject,
        forcelights,
        "",
        False,
        geo_parm="forceobject",
        light_parm=forcelightsparm,
        fog_parm="",
    )
    soho.removeObjects(
        now,
        excludeobject,
        excludelights,
        "",
        geo_parm="excludeobject",
        light_parm="excludelights",
        fog_parm="",
    )

    # Lock off the objects we've selected
    soho.lockObjects(now)

    with hou.undos.disabler(), scene_state:
        if "SOHO_PBRT_DEV" in os.environ:  # pragma: no coverage
            import cProfile

            pr = cProfile.Profile()
            pr.enable()
            try:
                PBRTscene.render(cam, now)
            finally:
                pr.disable()
                pr.dump_stats("hou-prbt.stats")
        else:
            PBRTscene.render(cam, now)
    return
project = bool(parmlist['render_viewcamera'].Value[0])
projection_attribute = parmlist['projection_attribute'].Value[0]
attribute_rendering_resolution = [
    parmlist['attribute_rendering_resolution'].Value[0],
    parmlist['attribute_rendering_resolution'].Value[1]
]
attribute_scale_by_resolution = bool(
    parmlist['attribute_scale_by_resolution'].Value[0])

now = parmlist['now'].Value[0]
camera = parmlist['camera'].Value[0]
fps = parmlist['fps'].Value[0]
options = {"state:autoheadlight": False}

if not soho.initialize(now=now, camera=camera, options=options):
    soho.error('Unable to initialize rendering module with camera: {0}'.format(
        repr(camera)))

for cam in soho.objectList('objlist:camera'):
    break
else:
    soho.error("Unable to find viewing camera for render")

camParms = {
    'space:world':
    soho.SohoParm('space:world', 'real',
                  [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], False),
    'focal':
    soho.SohoParm('focal', 'real', [0.050], False),
    'aperture':
def soho_render():
    control_parms = {
        # The time at which the scene is being rendered
        "now": SohoParm("state:time", "real", [0], False, key="now")
    }

    parms = soho.evaluate(control_parms)

    now = parms["now"].Value[0]
    camera = None

    options = {}
    if not soho.initialize(now, camera, options):
        soho.error("Unable to initialize rendering module with given camera")

    object_selection = {
        # Candidate object selection
        "vobject": SohoParm("vobject", "string", ["*"], False),
        "forceobject": SohoParm("forceobject", "string", [""], False),
        "excludeobject": SohoParm("excludeobject", "string", [""], False),
    }

    objparms = soho.evaluate(object_selection, now)

    stdobject = objparms["vobject"].Value[0]
    forceobject = objparms["forceobject"].Value[0]
    excludeobject = objparms["excludeobject"].Value[0]

    # First, we add objects based on their display flags or dimmer values
    soho.addObjects(now,
                    stdobject,
                    "",
                    "",
                    True,
                    geo_parm="vobject",
                    light_parm="",
                    fog_parm="")
    soho.addObjects(
        now,
        forceobject,
        "",
        "",
        False,
        geo_parm="forceobject",
        light_parm="",
        fog_parm="",
    )
    soho.removeObjects(now,
                       excludeobject,
                       "",
                       "",
                       geo_parm="excludeobject",
                       light_parm="",
                       fog_parm="")

    # Lock off the objects we've selected
    soho.lockObjects(now)

    with hou.undos.disabler(), scene_state:
        if "SOHO_PBRT_DEV" in os.environ:  # pragma: no coverage
            import cProfile

            pr = cProfile.Profile()
            pr.enable()
            try:
                PBRTscene.archive(now)
            finally:
                pr.disable()
                pr.dump_stats("hou-prbtarchive.stats")
        else:
            PBRTscene.archive(now)
    return
def export():
    """Main export function."""

    is_last = False

    try:
        T = timer('FrameExport')

        ps = soho.evaluate({
            'now':
            SohoParm('state:time', 'real', [0], False, key='now'),
            'fps':
            SohoParm('state:fps', 'real', [24], False, key='fps'),
            'hver':
            SohoParm('state:houdiniversion', 'string', [''], False,
                     key='hver'),
            'objpath':
            SohoParm('objpath', 'string', [''], False),
            'abcoutput':
            SohoParm('abcoutput', 'string', [''], False),
            'camera':
            SohoParm('camera', 'string', [None], False),
            'trange':
            SohoParm('trange', 'int', [0], False),
            'f':
            SohoParm('f', 'int', None, False)
        })

        now = ps['now'].Value[0]
        fps = ps['fps'].Value[0]
        hver = ps['hver'].Value[0]
        camera = ps['camera'].Value[0]

        dbg("now=%.3f fps=%.3f" % (now, fps))

        if not soho.initialize(now, camera):
            soho.error("couldn't initialize soho (make sure camera is set)")
            abc_cleanup()
            return

        # NOTE: this is prone to float inaccuracies
        frame = now * fps + 1.0

        objpath = ps['objpath'].Value[0]
        abc_file = ps['abcoutput'].Value[0]
        trange = ps['trange'].Value[0]
        f = ps['f'].Value

        is_first = frame < f[0] + 0.5  # working around float funniness
        is_last = frame > f[1] - 0.5

        if trange == 0:
            is_first = is_last = True

        dbg("is_first=%d is_last=%d" % (is_first, is_last))
        dbg("now=%.3f fps=%.3f -> %f" % (now, fps, frame))

        dbg("objpath=%s camera=%s abcoutput=%s trange=%d f=%s" % \
         (objpath, camera, abc_file, trange, str(f)))

        T.lap('init')

        # collect hierarchy to be exported
        # (read from scene directly, ie. not containing instances, etc.)
        # results in array [ (parentname, objname) [, ...]  ] -- (full pathnames)
        #
        #dbg("COLLECTING ARCHY:")
        archy = collect_archy(objpath)
        archy_objs = [n[1] for n in archy]
        #dbg("DONE.")

        # collect geometry to be exported and their render SOPS
        # (including point- and other instances, etc)
        # (NOTE: the entire scene is to be searched, unfortunately)
        #
        soho.addObjects(now, '*', '*', '', do_culling=False)
        soho.lockObjects(now)

        soho_objs = {}  # {objname: soho_obj}
        soho_only = {
        }  # soho-only objects (can't be accessed directly with hdk)

        obj_list = []
        sop_dict = {}  # {objname: sopname}
        objs = soho.objectList('objlist:instance')

        #dbg("COLLECT soho instance/sop pairs ------------------")
        for obj in objs:
            n = obj.getName()  # full pathname
            obj_list.append(n)
            soho_objs[n] = obj
            path = obj.getDefaultedString('object:soppath', now, [None])[0]
            #dbg(" -- %s (sop:%s)" % (n, str(path)) )
            if path and path != "":
                sop_dict[n] = path

        T.lap('collect-objs')

        if False:
            dbg('-' * 40)
            dbg("sop_dict: %s" % str(sop_dict))

        # extend hierarchy with per-point instances
        #
        p1 = re.compile(":[^:]+:")
        for obj in obj_list:
            if re.search(p1, obj):
                m = obj.split(":")
                p = m[-2]  # parent: 2nd from right
                if p in archy_objs:
                    archy.append((p, obj, "%s__%s" % (m[-2], m[-1])))
                    soho_only[obj] = p
                    #dbg(" -+- %s %s" % (p, obj))

        # fill rest of the archy array
        # elem: (parentpath, objpath, exportname, soppath)
        #
        archy2 = []
        for a in archy:
            N = list(a)
            if len(N) < 3: N.append(N[1])  # N = [ N[0], N[1], N[1] ]
            if N[1] in sop_dict:
                N = [N[0], N[1], N[2], sop_dict[N[1]]]
            else:
                # empty xform (no sop)
                N = [N[0], N[1], N[1], None]

            N[2] = re.search("[^/]+$", N[2]).group(0)
            archy2.append(N)
        archy = archy2

        if False:
            dbg('-' * 40)
            dbg("COLLECTED ARCHY:")
            for a in archy:
                dbg("- %s: " % (a[1], ))

        dbg("COLLECTED ARCHY: %d elems" % len(archy))

        T.lap('got-archy')

        # we now have a list of all objects to be exported
        # (parentname, objname, exportname, soppath)
        #
        archy_objs = [n[1] for n in archy]
        skip_frame = False

        now_out = now + (1.0 / fps)

        # check for user abort
        #
        if False:  # TODO: check for user abort!
            skip_frame = True
            is_last = True
            warn("user abort")

        # first frame: init all internal stuff
        #
        if is_first:
            dbg("\n\n\n")
            dbg("IS_FIRST--INIT")
            G.archy = archy[:]
            G.archy_objs = archy_objs[:]

            s = abc_init(abc_file, tstep=1.0 / fps, tstart=now_out)
            if s:
                # build objects for oarchive
                #
                for E in archy:
                    objname = E[1]
                    parent = E[0]
                    outname = E[2]
                    soppath = E[3]
                    if parent is None: parent = "-"
                    if soppath is None: soppath = "-"

                    # TODO: if instance, objname should be the base obj name
                    obj_src = objname
                    if objname in soho_only:
                        obj_src = soho_only[objname]

                    #dbg("-- new xform\n\toutname= %s\n\tobj    = %s\n\tparent = %s\n\tsop    = %s" % (outname, objname, parent, soppath))

                    hou.hscript('%s newobject "%s" "%s" "%s" "%s" "%s"' % \
                     (CCMD, objname, obj_src, parent, outname, soppath))

                    # set object flags (static, etc.)
                    #
                    if objname in soho_objs:
                        ps = soho_objs[objname].evaluate(
                            {
                                'abc_staticgeo':
                                SohoParm('abc_staticgeo', 'int', [0], False)
                            }, now)

                        if ps['abc_staticgeo'].Value[0] != 0:
                            hou.hscript('%s objset "%s" static' %
                                        (CCMD, objname))

            else:
                warn("couldn't output to file %s--aborting" % abc_file)
                skip_frame = True
                is_last = True

        T.lap('frame-first')

        # frame export: collect xforms, geoms, and export them
        #
        if archy_objs == G.archy_objs and not skip_frame:

            dbg("\n")
            dbg(" -- EXPORTING frame %.1f" % frame)

            for E in archy:
                #dbg("\n-")
                #dbg("- OBJ: %s" % str(E))
                objname = E[1]
                soppath = E[3]
                #dbg("- OBJ: %s" % E[1])

                # get xform matrix (TODO: get pretransform too!)
                #
                xform = ''

                # TODO: use this only for instances!
                #if objname in soho_objs:
                if objname in soho_only:
                    # get matrix from soho
                    #dbg(" --- (mtx from soho)")
                    xform = []
                    soho_objs[objname].evalFloat('space:local', now, xform)
                    xform = hou.Matrix4(xform)
                    xform = ' '.join([str(n) for n in xform.asTuple()])

                # perform sample write
                # (c++ code decides if geom is to be written)
                #
                if True:
                    hou.hscript('%s writesample %f "%s" %s' % \
                     (CCMD, now_out, objname, xform))

        else:
            #soho.error("couldn't export frame %.1f--no. of objects changed" % frame)
            warn("couldn't export frame %.1f--no. of objects changed" % frame)

        T.lap('frame-export')

    except:
        dbg("INTERRUPTED BY EXCEPTION")
        is_last = True

    # last frame: cleanup all internal stuff,
    # finish export
    #
    if is_last:
        dbg("\n\n\n")
        dbg("IS_LAST--FINISHING...")
        abc_cleanup()

    T.lap('frame-last')

    T.stats()
def export():
	"""Main export function."""

	is_last = False

	try:
		T = timer('FrameExport')

		ps = soho.evaluate({
			'now':		SohoParm('state:time',			'real', [0],  False, key='now'),
			'fps':		SohoParm('state:fps',			'real', [24],  False, key='fps'),
			'hver':		SohoParm('state:houdiniversion',	'string', [''],  False, key='hver'),
			'objpath':	SohoParm('objpath',		'string',	[''], False),
			'abcoutput':	SohoParm('abcoutput',		'string',	[''], False),
			'camera':	SohoParm('camera',		'string',	[None], False),
			'trange':	SohoParm('trange',		'int',		[0], False),
			'f':		SohoParm('f',			'int',		None, False)
		})
		
		now = ps['now'].Value[0]
		fps = ps['fps'].Value[0]
		hver = ps['hver'].Value[0]
		camera = ps['camera'].Value[0]

		dbg("now=%.3f fps=%.3f" % (now, fps))

		if not soho.initialize(now, camera):
			soho.error("couldn't initialize soho (make sure camera is set)")
			abc_cleanup()
			return

		# NOTE: this is prone to float inaccuracies
		frame = now*fps + 1.0

		objpath   = ps['objpath'].Value[0]
		abc_file  = ps['abcoutput'].Value[0]
		trange    = ps['trange'].Value[0]
		f         = ps['f'].Value

		is_first  = frame < f[0]+0.5 # working around float funniness
		is_last   = frame > f[1]-0.5

		if trange==0:
			is_first= is_last= True

		dbg("is_first=%d is_last=%d" % (is_first, is_last))
		dbg("now=%.3f fps=%.3f -> %f" % (now, fps, frame))

		dbg("objpath=%s camera=%s abcoutput=%s trange=%d f=%s" % \
			(objpath, camera, abc_file, trange, str(f)))

		T.lap('init')

		# collect hierarchy to be exported
		# (read from scene directly, ie. not containing instances, etc.)
		# results in array [ (parentname, objname) [, ...]  ] -- (full pathnames)
		#
		#dbg("COLLECTING ARCHY:")
		archy = collect_archy(objpath)
		archy_objs = [ n[1] for n in archy ]
		#dbg("DONE.")


		# collect geometry to be exported and their render SOPS
		# (including point- and other instances, etc)
		# (NOTE: the entire scene is to be searched, unfortunately)
		#
		soho.addObjects(now, '*', '*', '', do_culling=False)
		soho.lockObjects(now)

		soho_objs = {} # {objname: soho_obj}
		soho_only = {} # soho-only objects (can't be accessed directly with hdk)

		obj_list = []
		sop_dict = {} # {objname: sopname}
		objs = soho.objectList('objlist:instance')

		#dbg("COLLECT soho instance/sop pairs ------------------")
		for obj in objs:
			n = obj.getName() # full pathname
			obj_list.append(n)
			soho_objs[n] = obj
			path = obj.getDefaultedString('object:soppath', now, [None])[0]
			#dbg(" -- %s (sop:%s)" % (n, str(path)) )
			if path and path!="":
				sop_dict[n] = path

		T.lap('collect-objs')

		if False:
			dbg( '-' * 40 )
			dbg("sop_dict: %s" % str(sop_dict))

		# extend hierarchy with per-point instances
		#
		p1 = re.compile(":[^:]+:")
		for obj in obj_list:
			if re.search(p1, obj):
				m = obj.split(":")
				p = m[-2] # parent: 2nd from right
				if p in archy_objs:
					archy.append( ( p, obj, "%s__%s" % (m[-2], m[-1]) )  )
					soho_only[obj]=p
					#dbg(" -+- %s %s" % (p, obj))


		# fill rest of the archy array
		# elem: (parentpath, objpath, exportname, soppath)
		#
		archy2 = []
		for a in archy:
			N = list(a)
			if len(N)<3: N.append(N[1]) # N = [ N[0], N[1], N[1] ]
			if N[1] in sop_dict:
				N = [ N[0], N[1], N[2], sop_dict[N[1]] ]
			else:
				# empty xform (no sop)
				N = [ N[0], N[1], N[1], None ]
			
			N[2] = re.search("[^/]+$", N[2]).group(0)
			archy2.append(N)
		archy = archy2

		if False:
			dbg( '-' * 40 )
			dbg("COLLECTED ARCHY:")
			for a in archy:
				dbg("- %s: " % (a[1], ))

		dbg("COLLECTED ARCHY: %d elems" % len(archy))

		T.lap('got-archy')

		# we now have a list of all objects to be exported
		# (parentname, objname, exportname, soppath)
		#
		archy_objs = [ n[1] for n in archy ]
		skip_frame = False

		now_out = now+(1.0/fps)

		# check for user abort
		#
		if False: # TODO: check for user abort!
			skip_frame = True
			is_last = True
			warn("user abort")


		# first frame: init all internal stuff
		#
		if is_first:
			dbg("\n\n\n")
			dbg("IS_FIRST--INIT")
			G.archy = archy[:]
			G.archy_objs = archy_objs[:]

			s = abc_init(abc_file, tstep=1.0/fps, tstart=now_out)
			if s:
				# build objects for oarchive
				#
				for E in archy:
					objname = E[1]
					parent  = E[0]
					outname = E[2]
					soppath = E[3]
					if parent is None: parent="-"
					if soppath is None: soppath="-"

					# TODO: if instance, objname should be the base obj name
					obj_src = objname
					if objname in soho_only:
						obj_src = soho_only[objname]

					#dbg("-- new xform\n\toutname= %s\n\tobj    = %s\n\tparent = %s\n\tsop    = %s" % (outname, objname, parent, soppath))

					hou.hscript('%s newobject "%s" "%s" "%s" "%s" "%s"' % \
						(CCMD, objname, obj_src, parent, outname, soppath))

					# set object flags (static, etc.)
					#
					if objname in soho_objs:
						ps = soho_objs[objname].evaluate({
							'abc_staticgeo': SohoParm('abc_staticgeo', 'int', [0], False)
						}, now)

						if ps['abc_staticgeo'].Value[0]!=0:
							hou.hscript('%s objset "%s" static' % (CCMD, objname))

			else:
				warn("couldn't output to file %s--aborting" % abc_file)
				skip_frame = True
				is_last = True

		T.lap('frame-first')


		# frame export: collect xforms, geoms, and export them
		#
		if archy_objs==G.archy_objs  and  not skip_frame:

			dbg("\n")
			dbg(" -- EXPORTING frame %.1f" % frame)

			for E in archy:
				#dbg("\n-")
				#dbg("- OBJ: %s" % str(E))
				objname = E[1]
				soppath = E[3]
				#dbg("- OBJ: %s" % E[1])

				# get xform matrix (TODO: get pretransform too!)
				#
				xform = ''

				# TODO: use this only for instances!
				#if objname in soho_objs:
				if objname in soho_only:
					# get matrix from soho
					#dbg(" --- (mtx from soho)")
					xform = []
					soho_objs[objname].evalFloat('space:local', now, xform)
					xform = hou.Matrix4(xform)
					xform = ' '.join([ str(n) for n in xform.asTuple() ])

				# perform sample write
				# (c++ code decides if geom is to be written)
				#
				if True:
					hou.hscript('%s writesample %f "%s" %s' % \
						(CCMD, now_out, objname, xform))

		else:
			#soho.error("couldn't export frame %.1f--no. of objects changed" % frame)
			warn("couldn't export frame %.1f--no. of objects changed" % frame)


		T.lap('frame-export')

	except:
		dbg("INTERRUPTED BY EXCEPTION")
		is_last=True


	# last frame: cleanup all internal stuff,
	# finish export
	#
	if is_last:
		dbg("\n\n\n")
		dbg("IS_LAST--FINISHING...")
		abc_cleanup()

	T.lap('frame-last')

	T.stats()
Beispiel #11
0
parmlist = soho.evaluate(controlParameters)

# Extract the values from the evaluation
now     = parmlist['now'].Value[0]
camera  = parmlist['camera'].Value[0]
fps     = parmlist['fps'].Value[0]
picture = parmlist['vm_picture'].Value[0]
samples = parmlist['vm_samples'].Value[0]
sampler = parmlist['vm_sampler'].Value[0]
reflectlimit = parmlist['vm_reflectlimit'].Value[0]
integrator   = parmlist['vm_integrator'].Value[0]
camera       = parmlist['camera'].Value[0]
skip_geo_export = parmlist['skip_geo_export'].Value[0]


if not soho.initialize(now, camera):
    soho.error("Unable to initialize rendering module with given camera")

objectSelection = {
    # Candidate object selection
    'vobject'     : SohoParm('vobject', 'string',       ['*'], False),
    'alights'     : SohoParm('alights', 'string',       ['*'], False),
    'vfog'        : SohoParm('vfog',    'string',       ['*'], False),

    'forceobject' : SohoParm('forceobject',     'string',       [''], False),
    'forcelights' : SohoParm('forcelights',     'string',       [''], False),
    'forcefog'    : SohoParm('forcefog',        'string',       [''], False),

    'excludeobject' : SohoParm('excludeobject', 'string',       [''], False),
    'excludelights' : SohoParm('excludelights', 'string',       [''], False),
    'excludefog'    : SohoParm('excludefog',    'string',       [''], False),
Beispiel #12
0
propdefs = parmlist['lv_defaults'].Value[0]

if mode != 'default':
    # Don't allow for nested evaluation in IPR mode
    inheritedproperties = False
else:
    inheritedproperties = parmlist['lv_inheritproperties'].Value[0]

options = {}
if inheritedproperties:
    # Turn off object->output driver inheritance
    options['state:inheritance'] = '-rop'
if propdefs and propdefs != 'stdin':
    options['defaults_file'] = propdefs

if not soho.initialize(now, camera, options):
    # If we're UV rendering and there's no camera, create one.
    if uvrender:
        camera = 'ipr_camera'
        if not soho.initialize(now, camera, options):
            soho.error(
                "Unable to initialize UV rendering module with a camera")
    else:
        soho.error("Unable to initialize rendering module with given camera")

#
# Add objects to the scene, we check for parameters on the viewing
# camera.  If the parameters don't exist there, they will be picked up
# by the output driver.
#
objectSelection = {
Beispiel #13
0
parmlist = soho.evaluate(controlParameters)

now     = parmlist['now'].Value[0]
IFDapi.ForceEmbedVex = parmlist['embedvex'].Value[0]
decl_shops = parmlist['decl'].Value[0]

inheritedproperties = parmlist['vm_inheritproperties'].Value[0]

options = {}
if inheritedproperties:
    # Turn off object->output driver inheritance
    options['state:inheritance'] = '-rop'

    
if not soho.initialize(now, None):
    soho.error("Unable to initialize rendering module")
    
#
# Add objects to the scene, we check for parameters on the viewing
# camera.  If the parameters don't exist there, they will be picked up
# by the output driver.
#
objectSelection = {
    # Candidate object selection
    # Candidate object selection
    'vobject'     : SohoParm('vobject', 'string',       ['*'], False),
    'alights'     : SohoParm('alights', 'string',       ['*'], False),
    'vfog'        : SohoParm('vfog',    'string',       ['*'], False),

    'forceobject' : SohoParm('forceobject',     'string',       [''], False),
Beispiel #14
0
import soho, sys

# Evaluate the 'camera' parameter as a string.
# If the 'camera' parameter # doesn't exist, use ['/obj/cam1'].
# SOHO always returns lists of values.
camera = soho.getDefaultedString('camera', ['/obj/cam1'])[0]

# However, for our purposes, we don't actually need a camera, so...
camera = None

# Evaluate an intrinsic parameter (see HDK_SOHO_API::evaluate())
# The 'state:time' parameter evaluates the time from the ROP.
evaltime = soho.getDefaultedFloat('state:time', [0.0])[0]

# Initialize SOHO with the camera.
if not soho.initialize(evaltime, camera):
    soho.error('Unable to initialize rendering module with camera: %s' %
               repr(camera))

# Now, add objects to our scene
#   addObjects(time, geometry, light, fog, use_display_flags)
soho.addObjects(evaltime, "*", "*", "*", True)

# Before we can evaluate the scene from SOHO, we need to lock the object lists.
soho.lockObjects(evaltime)


# Now, traverse all the objects
def outputObjects(fp, prefix, list):
    fp.write('%s = {' % prefix)
    for obj in list: