def createTurbNoiseFolderParmTemplate(id): a_parm = hou.FloatParmTemplate('a' + id, 'Amp' + id, 1, default_value=(1, )) f_parm = hou.FloatParmTemplate('f' + id, 'Freq' + id, 1, default_value=(1, )) t_parm = hou.IntParmTemplate('t' + id, 'Turb' + id, 1, default_value=(5, )) r_parm = hou.FloatParmTemplate('r' + id, 'Rough' + id, 1, default_value=(0.5, )) at_parm = hou.FloatParmTemplate('at' + id, 'Atten' + id, 1, default_value=(1.0, )) type_parm = hou.StringParmTemplate('type'+id,'NoiseType'+id,1,default_value = ("a",),\ menu_items =("p","o","s","a","x","c"),\ menu_labels =("Perlin","OriginalPerlin","SparseConvultion","Alligator","Simplex","CorrectedPerlin"),\ join_with_next=True) noise_folder = hou.FolderParmTemplate('noise'+id,'Noise'+id,\ parm_templates = (a_parm,f_parm,t_parm,r_parm,at_parm,type_parm),\ folder_type = hou.folderType.Simple) return noise_folder
def get_new_parameter(self, parm): # ch, chf - float # chv - vector # chp - point # chs - string # chi- int # chramp - ramp if parm['func'] == 'ch' or parm['func'] == 'chf': return hou.FloatParmTemplate(parm['name'], parm['name'].title(), 1) elif parm['func'] == 'chv': return hou.FloatParmTemplate(parm['name'], parm['name'].title(), 3) elif parm['func'] == 'chs': return hou.StringParmTemplate(parm['name'], parm['name'].title(), 1) elif parm['func'] == 'chi': return hou.IntParmTemplate(parm['name'], parm['name'].title(), 1) elif parm['func'] == 'chramp': if parm['type'] == 'vector': return hou.RampParmTemplate(parm['name'], parm['name'].title(), hou.rampParmType.Color ) else: return hou.RampParmTemplate(parm['name'], parm['name'].title(), hou.rampParmType.Float ) elif parm['func'] == 'chp': return hou.FloatParmTemplate(parm['name'], parm['name'].title(), 4)
def createAaNoiseFolderParmTemplate(id): a_parm = hou.FloatParmTemplate('a' + id, 'Amp' + id, 1, default_value=(1, )) f_parm = hou.FloatParmTemplate('f' + id, 'Freq' + id, 1, default_value=(1, )) t_parm = hou.IntParmTemplate('t' + id, 'Turb' + id, 1, default_value=(3, )) o_parm = hou.FloatParmTemplate('o' + id, 'Offset' + id, 1, default_value=(0, )) r_parm = hou.FloatParmTemplate('r' + id, 'Rough' + id, 1, default_value=(0.5, )) xnoise = hou.ToggleParmTemplate('type' + id, 'Xnoise' + id, 1) noise_folder = hou.FolderParmTemplate('noise'+id,'Noise'+id,\ parm_templates = (a_parm,f_parm,t_parm,o_parm,r_parm,xnoise),\ folder_type = hou.folderType.Simple) return noise_folder
def createHelperBoneParms(bone, target): ptg = bone.parmTemplateGroup() parm = hou.FloatParmTemplate('correct_length', '', 2) ptg.addParmTemplate(parm) parm = hou.FloatParmTemplate('correct_angle', '', 2) ptg.addParmTemplate(parm) parm = hou.FloatParmTemplate('driver', '', 1) parm.setDefaultExpression( ('ch("' + bone.relativePathTo(target) + '/irx")', )) ptg.addParmTemplate(parm) parm = hou.FloatParmTemplate('corrected_length', '', 1) expr = 'fit(ch("driver"),ch("correct_anglex"),ch("correct_angley"),ch("correct_lengthx"),ch("correct_lengthy"))' parm.setDefaultExpression((expr, )) ptg.addParmTemplate(parm) bone.setParmTemplateGroup(ptg) bone.parm('correct_lengthx').set(bone.parm('length').eval()) bone.parm('correct_lengthy').set(bone.parm('length').eval() * 1.5) bone.parm('correct_anglex').set(0) bone.parm('correct_angley').set(90) bone.parm('corrected_length').lock(1) bone.parm('length').setExpression('ch("corrected_length")')
def createNoiseFolderParmTemplate(id): a_parm = hou.FloatParmTemplate('a'+id,'a'+id,1,default_value = (1,)) f_parm = hou.FloatParmTemplate('f'+id,'f'+id,1,default_value = (1,)) t_parm = hou.IntParmTemplate('t'+id,'t'+id,1,default_value = (3,)) r_parm = hou.FloatParmTemplate('r'+id,'r'+id,1,default_value = (0.5,)) noise_folder = hou.FolderParmTemplate('noise'+id,'Noise'+id,parm_templates = (a_parm,f_parm),folder_type = hou.folderType.Simple) return noise_folder
def parameters_ui(self): # opening the template group tg_parms = self.rig_subnet.parmTemplateGroup() ch_p_folder_parms = hou.FolderParmTemplate(self.node.name()+"character_placer", "character_placer") # creating the parms for i in self.limb_subnet.children(): hou_parm_template = hou.FloatParmTemplate(i.name()+"_t", "Translate", 3, default_value=([0, 0, 0]), min=0, max=10, min_is_strict=False, max_is_strict=False, look=hou.parmLook.Regular, naming_scheme=hou.parmNamingScheme.XYZW) ch_p_folder_parms.addParmTemplate(hou_parm_template) hou_parm_template = hou.FloatParmTemplate(i.name()+"_r", "Rotate", 3, default_value=([0, 0, 0]), min=0, max=360, min_is_strict=False, max_is_strict=False, look=hou.parmLook.Regular, naming_scheme=hou.parmNamingScheme.XYZW) ch_p_folder_parms.addParmTemplate(hou_parm_template) hou_parm_template = hou.FloatParmTemplate(i.name()+"_s", "Scale", 3, default_value=([1, 1, 1]), min=0, max=10, min_is_strict=False, max_is_strict=False, look=hou.parmLook.Regular, naming_scheme=hou.parmNamingScheme.XYZW) ch_p_folder_parms.addParmTemplate(hou_parm_template) hou_parm_template = hou.FloatParmTemplate(i.name()+"_p", "Pivot", 3, default_value=([0, 0, 0]), min=0, max=10, min_is_strict=False, max_is_strict=False, look=hou.parmLook.Regular, naming_scheme=hou.parmNamingScheme.XYZW) ch_p_folder_parms.addParmTemplate(hou_parm_template) hou_parm_template = hou.SeparatorParmTemplate(i.name()+"_sep") ch_p_folder_parms.addParmTemplate(hou_parm_template) #finding the folder to put the parms and closing the template folder_node = tg_parms.findFolder(["Rig Parms"]) tg_parms.appendToFolder(folder_node, ch_p_folder_parms) self.rig_subnet.setParmTemplateGroup(tg_parms)
def parm_create(node, type, name, label): if type == "integer": new_template = hou.IntParmTemplate(name, name, 1) if type == "toggle": new_template = hou.ToggleParmTemplate(name, name) if type == "float": new_template = hou.FloatParmTemplate(name, name, 1) if type == "vector": new_template = hou.FloatParmTemplate(name, name, 3) new_template.setLook(hou.parmLook.Regular) if type == "color": new_template = hou.FloatParmTemplate(name, name, 3) new_template.setNamingScheme(hou.parmNamingScheme.RGBA) new_template.setLook(hou.parmLook.ColorSquare) if type == "string": new_template = hou.StringParmTemplate(name, label, 1) new_template.setStringType(hou.stringParmType.Regular) if type == "file": new_template = hou.StringParmTemplate(name, name, 1) new_template.setStringType(hou.stringParmType.FileReference) if type == "node": new_template = hou.StringParmTemplate(name, name, 1) new_template.setStringType(hou.stringParmType.NodeReference) if type == "separator": new_template = hou.SeparatorParmTemplate(name) if type == "label": new_template = hou.LabelParmTemplate(name, label, [label], False, True) if type == "rampfloat": new_template = hou.RampParmTemplate(name, name, hou.rampParmType.Float) new_template.setShowsControls(False) if type == "rampcolor": new_template = hou.RampParmTemplate(name, name, hou.rampParmType.Color) new_template.setShowsControls(False) try: ptg = node.parmTemplateGroup() ptg.addParmTemplate(new_template) node.setParmTemplateGroup(ptg) existed = 0 except: existed = 1
def ghostShaderCreate(self, ghost_mat_folder, ghost_name): """Create a shader for a new ghost. INPUTS: ghost_mat_folder -- ghost shader network folder ghost_name -- object name from which a new ghost is created OUTPUTS: ghost_shader -- new ghost shader node """ with hou.undos.group("Create Ghost Shader"): current_frame = hou.frame() ghost_shader = ghost_mat_folder.createNode( 'vopmaterial', node_name=ghost_name + "_ghost_mat" + '_frame_' + str(current_frame)) parm_group = ghost_shader.parmTemplateGroup() parm_folder = hou.FolderParmTemplate("folder", "OpenGL") parm_folder.addParmTemplate( hou.FloatParmTemplate("ogl_spec", "Specular", 3)) parm_folder.addParmTemplate( hou.FloatParmTemplate("ogl_transparency", "Transparency", 1)) parm_folder.addParmTemplate( hou.FloatParmTemplate("ogl_ior", "IOR", 1)) parm_folder.addParmTemplate( hou.FloatParmTemplate("ogl_spec_intensity", "Intensity", 1)) parm_folder.addParmTemplate( hou.FloatParmTemplate("ogl_rough", "Roughness", 1)) parm_group.append(parm_folder) ghost_shader.setParmTemplateGroup(parm_group) ghost_shader.setParms({ "ogl_specx": self.ghostColorLabel.palette().color( QtGui.QPalette.Base).redF(), "ogl_specy": self.ghostColorLabel.palette().color( QtGui.QPalette.Base).greenF(), "ogl_specz": self.ghostColorLabel.palette().color( QtGui.QPalette.Base).blueF(), "ogl_transparency": 1, "ogl_ior": 1.06, "ogl_spec_intensity": 5, "ogl_rough": 0 }) ghost_shader.moveToGoodPosition() return ghost_shader
def add_parm(node): ptg = node.parmTemplateGroup() if ptg.parmTemplates()[-1].name() == 'wedge_list': for i in ptg.parmTemplates()[-1].parmTemplates(): node.parm(i.name()).set(10) else: parm_folder = hou.FolderParmTemplate('wedge_list', 'Wedge List') parm_folder.setFolderType(hou.folderType.Simple) parm_folder.addParmTemplate(hou.FloatParmTemplate('first', 'First', 1)) parm_folder.addParmTemplate(hou.FloatParmTemplate('last', 'Last', 1)) ptg.append(parm_folder) node.setParmTemplateGroup(ptg)
def AColorParmTemplate(parmName, parmLabel, parmDesc): v = parmDesc['default'] parmArgs = {} parmArgs['naming_scheme'] = hou.parmNamingScheme.RGBA parmArgs['default_value'] = v parmArgs['num_components'] = len(v) return hou.FloatParmTemplate(parmName, parmLabel, **parmArgs)
def exportIKRotations(n): solver = n.parm('solver') if solver is not None: solver = n.node(solver.evalAsString()) if solver is not None: #Create ir parm ptg = n.parmTemplateGroup() if ptg.find('ir') is not None: n.parmTuple('ir').lock((0, 0, 0)) ptg.remove('ir') parm = hou.FloatParmTemplate("ir", "Real Rotate", 3) ptg.addParmTemplate(parm) n.setParmTemplateGroup(ptg) #create rename node rename = solver.createOutputNode("rename", "rename_" + n.name()) rename.setPosition(solver.position() + hou.Vector2(0, -0.8)) rename.parm("renamefrom").set('*' + n.name() + ':r*') rename.parm("renameto").set('ir*') #create export node export = rename.createOutputNode("export", "export_" + n.name()) export.setPosition(rename.position() + hou.Vector2(0, -0.8)) export.parm("channels").set('ir*') export.parm("nodepath").set('../../' + n.name()) export.parm("path").set('ir*') export.setExportFlag(1)
def extractIKBoneRotates(n, use_asset_prefix): ptg = n.parmTemplateGroup() if ptg.find('ir') is not None: n.parmTuple('ir').lock((0, 0, 0)) ptg.remove('ir') parm = hou.FloatParmTemplate("ir", "Real Rotate", 3) ptg.addParmTemplate(parm) n.setParmTemplateGroup(ptg) solver = n.parm('solver').eval() if use_asset_prefix: asset_prefix = "/" + n.parent().type().name() else: asset_prefix = "" base_expr = 'chop("' + solver + asset_prefix + "/" + n.name() base_expr = 'chop("' + solver + "/" + '"+oprelativepath("/obj/",".")+"' expression = base_expr + ':rx")' n.parm('irx').setExpression(expression) expression = base_expr + ':ry")' n.parm('iry').setExpression(expression) expression = base_expr + ':rz")' n.parm('irz').setExpression(expression) n.parmTuple('ir').lock((1, 1, 1))
def matrixParm(p, dim=16, parent=None): name = parmName(p.name, prefix=parent) label = parmLabel(p) default_matrix = p.defaultValue.value default = [] dim_sqrt = int(math.sqrt(dim)) for i in range(dim_sqrt): for j in range(dim_sqrt): default.append(default_matrix[(i, j)]) min_val = 0.0 max_val = 10.0 min_lock = max_lock = False parm = hou.FloatParmTemplate(name, label, dim, default_value=default, min=min_val, max=max_val, min_is_strict=min_lock, max_is_strict=max_lock, look=hou.parmLook.Regular, naming_scheme=hou.parmNamingScheme.Base1, help=p.description) matrix = p.getTypedValue() initialValue = [] for i in range(dim_sqrt): for j in range(dim_sqrt): initialValue.append(matrix[(i, j)]) return {'name': name, 'tuple': parm, 'initialValue': initialValue}
def boxParmFloat(p, dim, parent=None): name = parmName(p.name, prefix=parent) label = parmLabel(p) default_box = p.defaultValue.value default = [] default = list(default_box.min) default.extend(list(default_box.max)) min_val = 0.0 max_val = 10.0 min_lock = max_lock = False parm = hou.FloatParmTemplate(name, label, dim * 2, default_value=default, min=min_val, max=max_val, min_is_strict=min_lock, max_is_strict=max_lock, look=hou.parmLook.Regular, naming_scheme=hou.parmNamingScheme.Base1, help=p.description) box = p.getTypedValue() initialValue = list(box.min) initialValue.extend(list(box.max)) return {'name': name, 'tuple': parm, 'initialValue': initialValue}
def create_path_null(self, where=hou.node("/obj")): path_cv = where.createNode("null", self.name) p1 = path_cv.node("point1") at_it = path_cv.createNode("attribcreate", "attribcreate_initial_twist") at_it.parm("name1").set("initial_twist") #hou_rig.utils.promote_parm_to_ui() didn't work because attribute create its Always tuple 4 parm length initial_twist_pt = hou.FloatParmTemplate("initialtwist", "Initial Twist", 1, default_value=([0]), min=0, max=10) hou_rig.utils.parm_to_ui(path_cv, initial_twist_pt, in_this_folder=["Misc"]) at_it.parm("value1v1").setExpression('ch("../initialtwist")') at_it.setInput(0, p1) at_twist = path_cv.createNode("attribcreate", "attribcreate_twist") at_twist.parm("name1").set("twist") at_twist.parm("value1v1").setExpression("ch('../rz')") at_twist.setFirstInput(at_it) pn = path_cv.createNode("point", "point_normal") pn.parm("donml").set("on") pn.parmTuple("n").deleteAllKeyframes() pn.parmTuple("n").set([0, 1, 0]) pn.setInput(0, at_twist) null_out = path_cv.createNode("null", "Out") null_out.setNextInput(pn) null_out.setRenderFlag(1) path_cv.layoutChildren() return path_cv
def add_TMP(attr_name, tmp_type, current_tmpparm, language_dict=None): attr_label = attr_name if language_dict: attr_label = language_dict.get(attr_name, attr_name) if tmp_type == "FloatParmTemplate": current_tmpparm.append(hou.FloatParmTemplate(attr_name, attr_label, 1)) elif tmp_type == "RampParmTemplate": current_tmpparm.append( hou.RampParmTemplate(attr_name, attr_label, hou.rampParmType.Float, default_value=2, default_basis=None, color_type=None)) elif tmp_type == "IntParmTemplate": current_tmpparm.append(hou.IntParmTemplate(attr_name, attr_label, 1)) elif tmp_type == "StringParmTemplate": current_tmpparm.append(hou.StringParmTemplate(attr_name, attr_label, 1)) elif tmp_type == "ToggleParmTemplate": current_tmpparm.append(hou.ToggleParmTemplate(attr_name, attr_label, 0)) elif tmp_type == "SeparatorParmTemplate": current_tmpparm.append( hou.SeparatorParmTemplate(attr_name, attr_label, 1)) return current_tmpparm
def loadCurve(*args, **kwargs): node = hou.pwd() node_path = node.type().definition().libraryFilePath() node_name = node.type().name() curves_node = node.node("Curves") data_folder = os.path.dirname(node_path) + "/%s_data" % node_name if not os.path.exists(data_folder): return # delete all child node for c_node in curves_node.children(): c_node.destroy() #read data for curve_data in os.listdir(data_folder): full_data_path = os.path.join(data_folder, curve_data) curve_name = os.path.splitext(curve_data)[0] #create curve node target_node = curves_node.createNode("curve", curve_name) parm_dic = {} with open(full_data_path, "r") as outfile: all_info = outfile.read() parm_dic = json.loads(all_info) #add width parm to interface current_tmpparm = target_node.parmTemplateGroup() current_tmpparm.append(hou.FloatParmTemplate("width", "Width", 1)) target_node.setParmTemplateGroup(current_tmpparm) target_node.setParms(parm_dic) print("Loaded!")
def add_midi_slot(self, channel_id, val): """add midi slot to the midi mapping node""" name = "ch" + str(channel_id) print("val = " + str(val)) slider = hou.FloatParmTemplate(name, name, 1) self.parmgroup.append(slider) self.midi_mapper.setParmTemplateGroup(self.parmgroup) return slider
def add_parm_value_multiplier(kwargs, add_exponent=False): """Adds a value/multipler parameter pair to the specified parameter. (Called from PARMmenu.xml) """ p = kwargs['parms'][0] try: n = p.node() v = p.eval() t = p.parmTemplate() g = n.parmTemplateGroup() pn = t.name() pl = t.label() pvn = '%s_value' % pn pmn = '%s_mult' % pn pxn = '%s_exp' % pn t = hou.FloatParmTemplate(name=p.name(), label="...", num_components=1) expr = "ch('%s') * ch('%s')" % (pvn, pmn, ) if not n.parm(pvn) and not n.parm(pmn): # value t.setName(pvn) t.setLabel('%s (v)' % pl) t.setDefaultValue( (v, ) ) g.insertAfter(pn, t) # mult t.setName(pmn) t.setLabel('%s (%%)' % pl) t.setMinValue(0.0) t.setMaxValue(2.0) t.setDefaultValue( (1.0, ) ) g.insertAfter(pvn, t) if add_exponent and not n.parm(pxn): # exp t.setName(pxn) t.setLabel('%s (exp)' % pl) t.setMinValue(0.001) t.setMaxValue(4.0) t.setDefaultValue( (2.0, ) ) g.insertAfter(pmn, t) expr = "ch('%s') * pow(ch('%s'), ch('%s'))" % (pvn, pmn, pxn, ) # add parms n.setParmTemplateGroup(g) p.setExpression(expr) else: hou.ui.setStatusMessage("Value/multiplier params already exist for %s" % p.path(), severity=hou.severityType.Warning) except: hou.ui.setStatusMessage("couldn't set up value/multiplier parameters on %s" % p.path(), severity=hou.severityType.Error)
def setup_parametric_ramp(node, ramp_parm, parametric_ramp_type): # type: (hou.Node, hou.Parm, str) -> None if parametric_ramp_type not in parametric_ramps: return ramp_name = ramp_parm.name() clean_parametric_spare_parms(node, ramp_parm) parametric_ramp = parametric_ramps[parametric_ramp_type] spare_parms = parametric_ramp.spare_parms name_prefix = name_prefix_format.format(ramp_name) callback = "node = kwargs['node']\n" callback += "ramp_name = '{}'\n".format(ramp_name) callback += """ ramp = node.parm(ramp_name) if not (ramp is None or ramp.evalAsInt() < {}): """.format(parametric_ramp.num_keys) for parm in spare_parms: # type: ParametricSpareParm callback += "\t{} = node.parm('{}').eval()\n".format(parm.name, name_prefix + parm.name) callback += parametric_ramp.callback ptg = node.parmTemplateGroup() # type: hou.ParmTemplateGroup insert_parm = get_multiparm_top_parent(ramp_parm) insert_parm_template = ptg.find(insert_parm.name()) ramp = hou.Ramp( (hou.rampBasis.Bezier,) * parametric_ramp.num_keys, np.linspace(0.0, 1.0, parametric_ramp.num_keys), np.linspace(0.0, 1.0, parametric_ramp.num_keys) ) ramp_parm.set(ramp) for parm in spare_parms: # type: ParametricSpareParm parm_template = hou.FloatParmTemplate( name_prefix + parm.name, label_format.format(ramp_parm.description(), parm.label), 1, (parm.default_value,), min=0.0, max=1.0, script_callback=callback, script_callback_language=hou.scriptLanguage.Python ) ptg.insertAfter(insert_parm_template, parm_template) node.setParmTemplateGroup(ptg) node.parm(name_prefix + spare_parms[0].name).pressButton()
def addExtendSize(node, parm=None): try: ptg = node.parmTemplateGroup() extendParm = hou.FloatParmTemplate("naw_expand", "Expand", 3, (0, 0, 0)) ptg.insertAfter("t", extendParm) node.setParmTemplateGroup(ptg) except hou.OperationFailed: pass if parm != None: parm.set(node.parm("executeAf"))
def bound(): """return bound box and centroid""" help(bound) import hou nodeSelect = hou.selectedNodes() black = hou.Color((0, 0, 0)) pink = hou.Color((0.98, 0.275, 0.275)) for node in nodeSelect: getName = node.name() outNull = node.createOutputNode("null", getName + "_IN_BOUND") outNull.setPosition(node.position()) outNull.move([0, -1]) outNull.setColor(black) outBound = outNull.createOutputNode("null", getName + "_BOUND_CENTROID") outBound.setColor(pink) #add create param to outBound parm_group = outBound.parmTemplateGroup() parm_folder = hou.FolderParmTemplate("folder", "Bound_Centroid") parm_folder.addParmTemplate(hou.FloatParmTemplate("bound", "Bound", 3)) parm_folder.addParmTemplate( hou.FloatParmTemplate("centroid", "Centroid", 3)) parm_group.append(parm_folder) outBound.setParmTemplateGroup(parm_group) outBound.parm('boundx').setExpression( "bbox(opinputpath('.',0),D_XSIZE)") outBound.parm('boundy').setExpression( "bbox(opinputpath('.',0),D_YSIZE)") outBound.parm('boundz').setExpression( "bbox(opinputpath('.',0),D_ZSIZE)") outBound.parm('centroidx').setExpression( "centroid(opinputpath('.',0),D_X)") outBound.parm('centroidy').setExpression( "centroid(opinputpath('.',0),D_Y)") outBound.parm('centroidz').setExpression( "centroid(opinputpath('.',0),D_Z)")
def unDeuxTrois(): """ setup une start scene basique """ help(unDeuxTrois) import hou obj = hou.node("/obj") cam = obj.createNode("cam", "myCam") cam.setParms({"resx": 1920, "resy": 1080}) cam.setParms({"tz": 3, "ty": 1.7}) resSim = obj.createNode("null", "resSim") resSim.setDisplayFlag(False) parm_group = resSim.parmTemplateGroup() parm_folder = hou.FolderParmTemplate("folder", "resSim") parm_folder.addParmTemplate(hou.FloatParmTemplate("flipSim", "flipSim", 1)) parm_folder.addParmTemplate(hou.FloatParmTemplate("pyroSim", "pyroSim", 1)) parm_group.append(parm_folder) resSim.setParmTemplateGroup(parm_group) geo1 = obj.createNode("geo", "source") geo1.move([0, -2]) file1 = hou.node("/obj/source/file1") file1.destroy() env = obj.createNode("envlight", "myEnv") env.setParms({"env_map": "$HFS/houdini/pic/DOSCH_SKIESV2_01SN_lowres.rat"}) env.move([0, 1]) out = hou.node("/out") mantra = out.createNode("ifd", "myMantra") mantra.setParms({"vm_renderengine": "pbrraytrace", "camera": "/obj/myCam"}) shop = hou.node("/shop") mat = shop.createNode("principledshader", "myMat") mat.setParms({"basecolorr": 1, "basecolorg": 1, "basecolorb": 1})
def imprint(node, data): """Store attributes with value on a node Depending on the type of attribute it creates the correct parameter template. Houdini uses a template per type, see the docs for more information. http://www.sidefx.com/docs/houdini/hom/hou/ParmTemplate.html Args: node(hou.Node): node object from Houdini data(dict): collection of attributes and their value Returns: None """ parm_group = node.parmTemplateGroup() parm_folder = hou.FolderParmTemplate("folder", "Extra") for key, value in data.items(): if value is None: continue if isinstance(value, float): parm = hou.FloatParmTemplate(name=key, label=key, num_components=1, default_value=(value, )) elif isinstance(value, bool): parm = hou.ToggleParmTemplate(name=key, label=key, default_value=value) elif isinstance(value, int): parm = hou.IntParmTemplate(name=key, label=key, num_components=1, default_value=(value, )) elif isinstance(value, six.string_types): parm = hou.StringParmTemplate(name=key, label=key, num_components=1, default_value=(value, )) else: raise TypeError("Unsupported type: %r" % type(value)) parm_folder.addParmTemplate(parm) parm_group.append(parm_folder) node.setParmTemplateGroup(parm_group)
def c_staticmodel(n): group = n.parmTemplateGroup() folder = hou.FolderParmTemplate("folder", "Static Model Component") folder.addParmTemplate(hou.StringParmTemplate("model", "Model", 1)) folder.addParmTemplate(hou.StringParmTemplate("material", "Material",1)) folder.addParmTemplate(hou.ToggleParmTemplate("isoccluder", "Is Occluder", 0)) folder.addParmTemplate(hou.ToggleParmTemplate("isoccludable", "Can Be Occluded", 1)) folder.addParmTemplate(hou.ToggleParmTemplate("castshadows", "Cast Shadows", 0)) folder.addParmTemplate(hou.FloatParmTemplate("drawdistance", "Draw Distance", 1 ) ) folder.addParmTemplate(hou.FloatParmTemplate("shadowdistance", "Shadow Distance", 1 ) ) folder.addParmTemplate(hou.FloatParmTemplate("lodbias", "LOD Bias", 1 ,(1.0,)) ) folder.addParmTemplate(hou.FloatParmTemplate("maxlights", "Max Lights", 1 ) ) folder.addParmTemplate(hou.IntParmTemplate("viewmask", "View Mask",1,(-1,))) folder.addParmTemplate(hou.IntParmTemplate("lightmask", "Light Mask",1,(-1,))) folder.addParmTemplate(hou.IntParmTemplate("shadowmask", "Shadow Mask",1,(-1,))) folder.addParmTemplate(hou.IntParmTemplate("zonemask", "Zone Mask",1,(-1,))) folder.addParmTemplate(hou.IntParmTemplate("occlodlevel", "Occ LOD Level",1,(-1,))) group.append(folder) n.setParmTemplateGroup(group)
def addCameraParms(cam, add_comment=False): ptg = cam.parmTemplateGroup() # Add Comment Folder if add_comment: comment_folder = hou.FolderParmTemplate("Comment", "Comment") comment = hou.StringParmTemplate("vcomment", "Viewport Comment", 1) comment.setTags({"editor": "1"}) comment_folder.addParmTemplate(comment) ptg.addParmTemplate(comment_folder) # Add custom Focal actions # focal point pt = hou.FloatParmTemplate("f", "Focus point", 3) pt.setTags({ "script_action": "n = kwargs[\"node\"]\n\nimport toolutils\nsv = toolutils.sceneViewer()\nsv.setSnappingMode(hou.snappingMode.Prim)\npos = sv.selectPositions(number_of_positions=1)\n\nif pos[0].length() > 0:\n n.parmTuple(\"f\").set(pos[0])\nsv.setSnappingMode(hou.snappingMode.Off)" }) ptg.addParmTemplate(pt) # focal distance pt = hou.FloatParmTemplate("f2t", "Focal2Target", 1) pt.setTags({ "script_action": "n = kwargs[\'node\']\nn.parm(\'RS_campro_dofDistance\').set(n.parm(\"f2t\"))\n" }) pt.setDefaultExpressionLanguage([hou.scriptLanguage.Python]) pt.setDefaultExpression([ "(hou.pwd().worldTransform().extractTranslates()-hou.Vector3(hou.pwd().parmTuple('f').eval())).length()" ]) ptg.addParmTemplate(pt) cam.setParmTemplateGroup(ptg) # use our custom dof cam.parm("RS_campro_dofUseHoudiniCamera").set(0) cam.parm('RS_campro_dofDistance').set(cam.parm("f2t")) cam.parm("RS_campro_dofCoC").set(0.02)
def add_TMP(attr_name, tmp_type, current_tmpparm): attr_label = language_dict.get(attr_name, attr_name) if tmp_type == "FloatParmTemplate": current_tmpparm.append(hou.FloatParmTemplate(attr_name, attr_label, 1)) elif tmp_type == "RampParmTemplate": current_tmpparm.append( hou.RampParmTemplate(attr_name, attr_label, hou.rampParmType.Float, default_value=2, default_basis=None, color_type=None)) elif tmp_type == "IntParmTemplate": current_tmpparm.append(hou.IntParmTemplate(attr_name, attr_label, 1)) return current_tmpparm
def createDisplace(self, parent, connector, channel, channelName): #Create Displacement Texture Node tex = parent.createNode("displacetexture") tex.setName(channelName, True) tex.parm("texture").set(channel) tex.parm("scale").set("0.1") #Connect UV Node tex.setInput(2, self.uv, 0) #Connect Displacement Node parent.glob("displacement_output")[0].setInput(0, tex, 0) parent.glob("displacement_output")[0].setInput(1, tex, 1) #Create Properties prop = parent.createNode("properties") #Add Template Parm group = prop.parmTemplateGroup() folder = hou.FolderParmTemplate("folder", "Shading") folder.addParmTemplate( hou.FloatParmTemplate("vm_displacebound", "Displacement Bound", 1)) group.append(folder) prop.setParmTemplateGroup(group) prop.parm("vm_displacebound").set(1) #Connect parent.glob("*collect")[0].setInput(2, prop, 0) #Layer Export lp = parent.createNode("layerpack") lp.setInput(3, tex, 0) lp.setInput(4, tex, 1) #Set Layer Properties layer = parent.createNode("parameter") layer.parm("parmname").set("layer") layer.parm("exportparm").set(1) layer.parm("useownexportcontext").set(1) layer.parm("exportcontext").set("displace") layer.parm("parmtype").set("struct") layer.parm("parmtypename").set("shaderlayer") layer.setInput(0, lp, 0) return
def createFlowNoiseFolderParmTemplate(id): a_parm = hou.FloatParmTemplate('a'+id,'Amp'+id,1,default_value = (1,)) f_parm = hou.FloatParmTemplate('f'+id,'Freq'+id,1,default_value = (1,)) t_parm = hou.IntParmTemplate('t'+id,'Turb'+id,1,default_value = (3,)) o_parm = hou.FloatParmTemplate('o'+id,'Offset'+id,1,default_value = (0,)) r_parm = hou.FloatParmTemplate('r'+id,'Rough'+id,1,default_value = (0.5,)) flow = hou.FloatParmTemplate('flow'+id,'Flow'+id,1,default_value = (0,)) flowrate = hou.FloatParmTemplate('flowrate'+id,'FlowRate'+id,1,default_value = (1,)) selfAdvect = hou.FloatParmTemplate('selfAdvect'+id,'SelfAdvect'+id,1,default_value = (0,)) noise_folder = hou.FolderParmTemplate('noise'+id,'Noise'+id,\ parm_templates = (a_parm,f_parm,t_parm,o_parm,r_parm,flow,flowrate,selfAdvect),\ folder_type = hou.folderType.Simple) return noise_folder
def floatParm(p, dim=1, parent=None): name = parmName(p.name, prefix=parent) label = parmLabel(p) # only simple floats have min/max values if dim == 1: default = [(p.defaultValue.value)] min_val = 0.0 max_val = 10.0 min_lock = max_lock = False if p.hasMinValue(): min_val = p.minValue min_lock = True if p.hasMaxValue(): max_val = p.maxValue max_lock = True else: default = list(p.defaultValue.value) min_val = 0.0 max_val = 10.0 min_lock = max_lock = False naming = hou.parmNamingScheme.Base1 if dim > 1: naming = hou.parmNamingScheme.XYZW parm = hou.FloatParmTemplate(name, label, dim, default_value=default, min=min_val, max=max_val, min_is_strict=min_lock, max_is_strict=max_lock, look=hou.parmLook.Regular, naming_scheme=naming, help=p.description) if dim == 1: initialValue = [p.getTypedValue()] else: initialValue = list(p.getTypedValue()) return {'name': name, 'tuple': parm, 'initialValue': initialValue}