Functions | |
| bool | initialize (fpreal render_time, const char *camera_path) |
| Initialize the SOHO scene. | |
| void | finalize () |
| Reset the SOHO scene. | |
| void | message (int severity, const char *text) |
| Add a message, warning or error to the output driver. | |
| bool | addCandidates (fpreal render_time, const char *geometry_pattern, const char *light_pattern, const char *fog_pattern, const char *geometry_parm="soho.visibleobjects", const char *light_parm="soho.visiblelights", const char *fog_parm="soho.visiblefog", bool parameter_filtering=true, bool remove_objects=false) |
| Add or remove objects from the SOHO scene. | |
| void | lockCandidates () |
| Finalize the object selection made by addCandidates(). | |
| FILE * | getFile (int descriptor) |
| Get SOHO file descriptors. | |
| void | indent (int bump=0, text="", comment="#", close_comment="") |
| Output indented text on the output stream. | |
| void | printArray (const char *prefix, PyObject *list, const char *suffix) |
| Print an array to the output stream. | |
| const char * | arrayToString (const char *prefix, PyObject *list, const char *suffix) |
| Print an array to a string object. | |
| void | storeObjectData (int handle, const char *name, void *data) |
| Store blind data on a SOHO object. | |
| void * | getObjectData (int handle, const char *name) |
| Get blind data from a SOHO object. | |
| void * | clearObjectData (int handle, const char *name,...) |
| Clear blind data from a SOHO object. | |
| PyObject * | evaluate (PyObject *parameters, fpreal time, int handle) |
| Evaluate parameters on an object. | |
| UT_StringArray | processShaderString (const char *shader_string, const UT_Options &options) |
| Process a shader, evaluating VOP or op: references. | |
| void | pushOverrides (const UT_Options &options) |
| Push a set of parameter overrides. | |
| void | popOverrides () |
| Pop the override stack (see pushOverrides());. | |
| PyObject * | newIterator (const char *type, fpreal time, int object_handle, const char *pattern_override, const char *category_override) |
| Start iterating over a list of objects. | |
| int | nextIterator (PyObject *iterator) |
| Proceed to the next iteration of an iterator. | |
| int | gCreate (const char *path, fpreal cook_time) |
| Create a geometry object. | |
| void | gDelete (int geo_handle) |
| Release a geometry handle. | |
| PyDictObject * | gPartition (int geo_handle, const char *style, PyObject *option) |
| Partition geometry into new geometry objects. | |
| int | gTesselate (int geo_handle, UT_Options &options) |
| Tesselate geometry into polygons (Houdini 11.0 and greater). | |
| int | gAttribute (int geo_handle, const char *owner, const char *name) |
| Look up a geometry attribute. | |
| PyListObject * | gValue (int geo_handle, int attribute, int element) |
| Evaluate a geometry attribute. | |
| PyListObject * | gVertex (int geo_handle, int attribute, int primitive, int vertex) |
| Evaluate a geometry attribute by (primitive,vertex). | |
| bool | gSaveAll (int geo_handle, const char *filename, const UT_Options &options) |
| A short-cut to save geometry to a known format. | |
The SOHO API is currently only available through a Python API. The functions are documented in the help() of the soho module. However, this document provides documentation in a more usable form.
| bool HDK_SOHO_API::addCandidates | ( | fpreal | render_time, | |
| const char * | geometry_pattern, | |||
| const char * | light_pattern, | |||
| const char * | fog_pattern, | |||
| const char * | geometry_parm = "soho.visibleobjects", |
|||
| const char * | light_parm = "soho.visiblelights", |
|||
| const char * | fog_parm = "soho.visiblefog", |
|||
| bool | parameter_filtering = true, |
|||
| bool | remove_objects = false | |||
| ) |
Add or remove objects from the SOHO scene.
| render_time | The time to be used for filtering evaluations | |
| geometry_pattern | An object name pattern used to match geometry objects. Only objects which match the name pattern will be considered for the operation. | |
| light_pattern | An object name pattern used to match light objects. | |
| fog_pattern | An object name pattern used to match fog objects. | |
| parameter_filtering | When selecting objects for addition to the scene, turning on parameter_filtering will cause parameter evaluation to before acceptance of an object.
| |
| remove_objects | Remove selected objects from the scene (instead of adding to the scene) | |
| geometry_parm | The name of the parameter that was evaluated in order to obtain geometry_pattern. | |
| light_parm | The name of the parameter that was evaluated in order to obtain light_pattern. | |
| fog_parm | The name of the parameter that was evaluated in order to obtain fog_pattern. |
Sub-network Filtering
When evaluating a sub-network object which matches the candidate pattern, the subnet_filter parameter is evaluated on the sub-network. This parameter can have three possible values
all pattern subnet_pattern is evaluated and only children which match that pattern are selected.display (default)
| const char* HDK_SOHO_API::arrayToString | ( | const char * | prefix, | |
| PyObject * | list, | |||
| const char * | suffix | |||
| ) |
Print an array to a string object.
This is a convenience function to print an array of values to the SOHO output stream. In Python code, this is equivalent to:
def arrayToString(prefix, value, suffix): precision = soho.getDefaultedInt("soho_precision", [12])[0] result = prefix for i in value: if type(i) == float: result += ' %.*g' % (prec, i) else: result += ' %s' % repr(i) result += suffix return result
| void* HDK_SOHO_API::clearObjectData | ( | int | handle, | |
| const char * | name, | |||
| ... | ||||
| ) |
Clear blind data from a SOHO object.
SOHO objects are referenced by handles in the Python API. There is a class wrapped around the integer handle, but multiple instances of the class may be created for the same object. SOHO provides a way to store blind data on the object.
Multiple entries can be cleared from the dictionary at one time.
The data is stored in a dictionary.
| PyObject* HDK_SOHO_API::evaluate | ( | PyObject * | parameters, | |
| fpreal | time, | |||
| int | handle | |||
| ) |
Evaluate parameters on an object.
The evaluate() function is the work-horse in SOHO. The function takes a Python list or dict of parameter objects and returns a list or dict of evaluated parameters. The parameter object should have the following attributes:
Key: A unique name for the parameter (used in the returned dict)Houdini: The name of a Houdini parameter to evaluateType: The type of data expected (i.e. how the parameter should be evaluated). Possible values are: 'float', 'bool', 'int', 'string', 'shader', 'bounds', 'oplist'.Default: Optional default valueSkipDefault: If the Houdini parameter is at it's default value, and this attribute is True, then, the parameter will not be returned in the resulting list or dict.There is a sample class object defined (SohoParm) in soho.py which is used throughout the factory Python scripts.
After evaluation, the parameter object will have a new attribute Value which stores the resulting value. The Value attribute will always be a list/tuple, even if the parameter is a scalar.
For example:
def getDefaultedInt(object_handle, name, default_value): # Create a parameter list. Specify the default value to be # returned if the parameter cannot be evaluated. parmlist = [ SohoParm(name, 'int', default_value, False) ] # Evaluate the parameter list parmlist = evaluate(parmlist, None, object_handle) return parmlist[0].Value
def getDefaultedInt(object_handle, name, default_value): # Create a parameter list. Specify the default value to be # returned if the parameter cannot be evaluated. parmlist = [ SohoParm(name, 'int', [], True) ] # Evaluate the parameter list. If the evaluation fails, then # return the default_value. if not evaluate(parmlist, None, object_handle): return default_value return parmlist[0].Value
| parameters | A Python list or dict of parameter objects | |
| time | The evaluation time. If no evaluation time is specified, the time given by initialize() is used. | |
| handle | An object handle identifier. This may be 0 to evaluate parameters on the output driver (i.e. global parameters). |
list or dict of parameters with a Value attribute set to the evaluated results. Otherwise, returns None state:alltokens state:allgeotokens state:precision state:houdiniversion state:time objlist:camera objlist:light objlist:instance objlist:lightmask object:name object:soppath object:creator space:world space:local | void HDK_SOHO_API::finalize | ( | ) |
Reset the SOHO scene.
This function will re-initialize the SOHO scene with an empty scene. The output driver object will be kept in the scene.
| int HDK_SOHO_API::gAttribute | ( | int | geo_handle, | |
| const char * | owner, | |||
| const char * | name | |||
| ) |
Look up a geometry attribute.
Attributes in SOHO are accessed using integer handles. Valid handles have values greater than 0. The gAttribute() function will query geometry to find a handle to the named attribute. This handle can then be used by gValue() or gVertex() to evaluate the value from the geometry.
SOHO maintains a list of intrinsic attributes which can be used to access information about the topology of the geometry, primitive properties or other intrinsic attributes which aren't tied directly to a user attribute. You can get a list of all geometry tokens using the evaluate() function (with the 'state:allgeotokens' parameter name).
When the parameter owner is "geo:attrib", the attribute handle can be used to query information about attribute handles. The following intrinsic attributes are supported in this case:
Example:
# Find the P point attribute and print it for the first 10 # points P = gAttribute(geo_handle, 'geo:point', 'P') for i in range(10): print i, gValue(geo_handle, P, i) # Find the "intrinsic" attribute for the primitive type name # and print it out for the first 10 primitives pname = gAttribute(geo_handle, 'geo:primitive', 'geo:primname') for i in range(10): print i, gValue(geo_handle, pname, i) # Find an attribute to query the vector size of an attribute # Use this attribute to print out the vector size of the P and # pname attributes. a_vsize = gAttribute(geo_handle, 'geo:attrib', 'geo:vectorsize) P_size = gValue(geo_handle, a_vsize, P) primname_size = gValue(geo_handle, a_vsize, pname) print 'P[%d] pname[%d]' % (P_size, primname_size)
| geo_handle | The geometry handle created with gCreate() | |
| owner | The owner of the attribute. This may be one of
| |
| name | The name of the attribute to look up. This may be the name of an intrinsic attribute. |
| int HDK_SOHO_API::gCreate | ( | const char * | path, | |
| fpreal | cook_time | |||
| ) |
Create a geometry object.
| path | The Houdini path to a SOP object. This SOP's geometry will be evaluated. You can find the SOP path for an object by evaluating | |
| cook_time | The time used to evaluate the SOP's geometry |
| void HDK_SOHO_API::gDelete | ( | int | geo_handle | ) |
Release a geometry handle.
Release the geometry associated with the handle. The handle should have been created with gCreate().
| FILE* HDK_SOHO_API::getFile | ( | int | descriptor | ) |
Get SOHO file descriptors.
The SOHO output driver evaluates the soho_outputmode parameter, and based on its value will create 2 internal file descriptors.
| descriptor | @
|
| void* HDK_SOHO_API::getObjectData | ( | int | handle, | |
| const char * | name | |||
| ) |
Get blind data from a SOHO object.
SOHO objects are referenced by handles in the Python API. There is a class wrapped around the integer handle, but multiple instances of the class may be created for the same object. SOHO provides a way to store blind data on the object.
The data is stored in a dictionary.
| PyDictObject* HDK_SOHO_API::gPartition | ( | int | geo_handle, | |
| const char * | style, | |||
| PyObject * | option | |||
| ) |
Partition geometry into new geometry objects.
Partitioning geometry splits one geometry object into a dictionary of geometry objects. Each element of the dictionary is composed of a sub-set of the primitives of the original geometry. The dictionary values are the handles associated with the geometry objects. You must call gDelete() on these handles.
There are four styles of partitioning currently implemented.
geo:partgroup
In this case, the option parameter refers to a primitive group name. All primitives in that group are returned in a new geometry object.
geo:partattrib
In this case, the option parameter refers to a string attribute. The geometry is partitioned based on the values of the string. That is, all primitives which have the same string value are put into a single partition group. This approach can be used to partition geometry based on material assignments for example.
geo:partlist
This is the most flexible partitioning process. The option parameter in this case, refers to a list of strings. There should be one string for each primitive in the geometry. Each primitive will be placed in a partition named by the corresponding string. Python generator objects are accepted in this function.
geo:partenlarge
This is a special case partitioner which looks at edge connectedness of polygon sets. The option is ignored. The returned partition will contain a super-set of the original geometry which has additional polygons which were connected to the original geometry. This assumes that the geometry was part of a partitioned set.
Examples
# Create a single partition with all the primitives in the # group named 'renderme' partition('geo:partgroup', 'renderme') # Partition the geometry into partitions based on the value of # the 'material' attribute. partition('geo:partattrib', 'material') # Partition the geometry into partitions based on a generator def generator(nprimitives): for x in xrange(0, nprimitives): if isprime(x): return 'prime' else: return 'composite' partition('geo:partlist', generator(nprimitives))
| bool HDK_SOHO_API::gSaveAll | ( | int | geo_handle, | |
| const char * | filename, | |||
| const UT_Options & | options | |||
| ) |
A short-cut to save geometry to a known format.
This method will call GU_Detail::save() to save the geometry to the given filename. If the filename is 'stdout.geo', 'stdout.bgeo' or 'stdout', the geometry will be saved to the SOHO output stream (as returned by getFile(1))
The options are passed to the GU_Detail::save() method and can be used to "tune" saving. Some common options include:
| int HDK_SOHO_API::gTesselate | ( | int | geo_handle, | |
| UT_Options & | options | |||
| ) |
Tesselate geometry into polygons (Houdini 11.0 and greater).
This takes source geometry and creates a tesselated version of the geometry. The tesselation is controlled using the options passed. For a current list of options, please see $HH/soho/soho.doc. However, some common options include:
geo1 = gCreate(path); geo2 = tesselate(geo1, {'tess:style':'lod', 'tess:polysides':3})
| PyListObject* HDK_SOHO_API::gValue | ( | int | geo_handle, | |
| int | attribute, | |||
| int | element | |||
| ) |
Evaluate a geometry attribute.
| geo_handle | The geometry handle created by gCreate() | |
| attribute | The attribute handle created by gAttribute() | |
| element | The number of the element to be evaluated. This integer is dependent on the attribute type, and it's the users responsibility to ensure that the value has the correct meaning. The meaning is based on the attribute owner type:
|
nprim_handle = gAttribute(geo, 'geo:global', 'geo:primcount') nprims = gValue(geo, nprim_handle, 0) # Should be: vvv # nprims = gValue(geo, nprim_handle, 0)[0] # ^^^
| PyListObject* HDK_SOHO_API::gVertex | ( | int | geo_handle, | |
| int | attribute, | |||
| int | primitive, | |||
| int | vertex | |||
| ) |
Evaluate a geometry attribute by (primitive,vertex).
| geo_handle | The geometry handle created by gCreate() | |
| attribute | The attribute handle created by gAttribute() | |
| primitive | The primitive number for evaluation. | |
| vertex | The vertex number for evaluation |
gValue(geo_handle, attribute, (primitive, vertex))
| void HDK_SOHO_API::indent | ( | int | bump = 0, |
|
| text | = "", |
|||
| comment | = "#", |
|||
| close_comment | = "" | |||
| ) |
Output indented text on the output stream.
This is a convenience function to indent the SOHO output stream. In Python code, this is equivalent to:
def indent(bump=0, text="", comment="#', close_comment=""): global theIndent bump *= soho.getDefaultedInt("soho_indentstep", [4])[0] if bump < 0: theIndent += bump sys.stdout.write("%*s" % (theIndent, "")) if text: sys.stdout.write(text) if comment: if bump < 0: sys.stdout.write("\t %s } %s" % (comment, closecomment)) else: sys.stdout.write("\t %s { %s" % (comment, closecomment)) if bump > 0: theIndent += bump
| bool HDK_SOHO_API::initialize | ( | fpreal | render_time, | |
| const char * | camera_path | |||
| ) |
Initialize the SOHO scene.
SOHO maintains an internal representation of the Houdini Scene. SOHO may filter some objects out of the render scene. It also flattens all instancing so that each instanced object is represented as a single SOHO object. This includes DOP instancing.
The camera path may be NULL, in which case there will be no camera in the scene and the scene will be considered to be contained by "/obj".
This function will also set the internal state by evaluating
soho_precision soho_indentstep - Default := 4 Indent step for indent() functionsoho_almostzero - Default := 0 Real numbers which have their value less than this tolerance will be output as 0 exactly.soho_safename - Default := False Change object names to "safe" names. Safe names follow standard variable naming conventions, only alpha-numeric characters and the underscore ('_')soho_autoheadlight - Default := True Automatically add a light at the camera's location if there are no lights in the scene.The method will fail if the user specifes a camera path, but there is no corresponding camera in the Houdini scene.
When rendering from the viewport menu, this function will succeed even if the camera doesn't exist. See SOHO Overrides for details.
The global indent level is reset to 0.
| void HDK_SOHO_API::lockCandidates | ( | ) |
Finalize the object selection made by addCandidates().
| void HDK_SOHO_API::message | ( | int | severity, | |
| const char * | text | |||
| ) |
Add a message, warning or error to the output driver.
Depending on the severity, this function will add a message (information), a warning or an error to the output driver.
| text | Message text. This text will be added to the output driver as a message (information), warning or error depending on the severity. | |
| severity | Specify the severity of the message.
|
| PyObject* HDK_SOHO_API::newIterator | ( | const char * | type, | |
| fpreal | time, | |||
| int | object_handle, | |||
| const char * | pattern_override, | |||
| const char * | category_override | |||
| ) |
Start iterating over a list of objects.
Create an iterator object which allows iteration over a selection of objects in the SOHO scene.
| type | The type of iteration. This should be one of:
| |
| time | Evaluation time to evaluate the parameters controlling the selection | |
| object_handle | The lightmask, shadowmask, reflectmask, refractmask can all be evaluated on a per-object basis. The handle can be -1 to evaluate the parameters on the output driver (for example for 'objlist:light') | |
| pattern_override | Specify a pattern which filters objects based on object name. This defaults to "*". | |
| category_override | Specify a pattern which filters objects based on category tags/selection tags. This defaults to "*". |
| int HDK_SOHO_API::nextIterator | ( | PyObject * | iterator | ) |
Proceed to the next iteration of an iterator.
| iterator | An iterator created by newIterator() |
For example, to implement an iteration over all light sources in a SOHO scene as a Python generator:
def allLights():
it = newIterator('objlist:light', None, None, None,None)
while True:
handle = nextIterator(it)
if result < 0:
break
yield handle
| void HDK_SOHO_API::popOverrides | ( | ) |
Pop the override stack (see pushOverrides());.
| void HDK_SOHO_API::printArray | ( | const char * | prefix, | |
| PyObject * | list, | |||
| const char * | suffix | |||
| ) |
Print an array to the output stream.
This is a convenience function to print an array of values to the SOHO output stream. In Python code, this is equivalent to:
def printArray(prefix, value, suffix): precision = soho.getDefaultedInt("soho_precision", [12])[0] sys.stdout.write(prefix) for i in value: if type(i) == float: sys.stdout.write(' %.*g' % (prec, i)) else: sys.stdout.write(' %s' % repr(i)) sys.stdout.write(suffix)
| UT_StringArray HDK_SOHO_API::processShaderString | ( | const char * | shader_string, | |
| const UT_Options & | options | |||
| ) |
Process a shader, evaluating VOP or op: references.
When a shader is defined by a VOP network, the VOP network may need to be processed for a valid shader to exist.
In addition, some shaders may have arguments which reference other assets in the .hip file (i.e. COP images). This function will also process arguments, scanning for 'op:' or 'opdef:' to determine whether assets have to be passed to the render script.
At the current time, scanning for op: is mantra/IFD specific.
| shader_string | The shader string to process | |
| options | A dictionary of options which tell processShaderString() how the shader string should be processed.
|
| void HDK_SOHO_API::pushOverrides | ( | const UT_Options & | options | ) |
Push a set of parameter overrides.
This function takes a dictionary of name/value pairs. When SOHO is asked to evaluate a parameter, it first checks to see whether the parameter is defined in the current overrides. If so, the value from the overrides is returned.
The overrides form a stack, and all pushed overrides are scanned when parameters are evaluated.
pushOverrides() and popOverrides() are wrapped in the PropertyOverride object (soho.py).
| void HDK_SOHO_API::storeObjectData | ( | int | handle, | |
| const char * | name, | |||
| void * | data | |||
| ) |
Store blind data on a SOHO object.
SOHO objects are referenced by handles in the Python API. There is a class wrapped around the integer handle, but multiple instances of the class may be created for the same object. SOHO provides a way to store blind data on the object.
The data is stored in a dictionary.
1.5.9