示例#1
0
def init_RS():
    # Create RS ROPs
    out = hou.node("/out")
    rop = autoNode.createRedshiftRop(out)
    rop.setParms({"RS_renderCamera":"cam_1080"})
    autoNode.createRedshiftIPR(out)

    # Default materials with AE Gallery application?
    shop = hou.node("/shop")
    mat = shop.createNode("RS_Material", "Base")
    entries = hou.galleries.galleryEntries(node_type=hou.nodeType(hou.shopNodeTypeCategory(), "RS_Material"))
    if entries:
        for entry in entries:
            entry.applyToNode(mat)

    inc = shop.createNode("rs_incandescent", "Solid")
    inc.move(hou.Vector2(0, 1))
    entries = hou.galleries.galleryEntries(node_type=hou.nodeType(hou.shopNodeTypeCategory(), "rs_incandescent"))
    if entries:
        for entry in entries:
            entry.applyToNode(inc)

    # Default camera
    obj = hou.node("/obj")
    cam = obj.createNode("cam", "cam_1080")
    cam.setParms({"resx": 1920, "resy": 1080})
    
    # Default Light
    dome = obj.createNode("rslightdome", "Dome")
    dome.move(hou.Vector2(0, 1))

    # does this work form a shelf?
    hou.hscript('Redshift_objectSpareParameters')
    hou.hscript('Redshift_cameraSpareParameters')
示例#2
0
def createSubnet():
    node = checkSelection()

    if node:
        sel = hou.selectedNodes()
        if len(sel) == 1 and node.type().name() == 'subnet':
            pat = re.compile('label\d')
            for p in node.parms():
                find = pat.search(p.name())
                if find:
                    p.hide(1)
            node.setColor(hou.Color(colors.subnet))
            return

        parent = node.parent()
        pos = node.position()
        sub = parent.createNode("subnet")
        sub.setPosition(pos + hou.Vector2(0, -1))
        sub.setInput(0, node)
        sub.setDisplayFlag(1)
        sub.setRenderFlag(1)
        sparms = sub.parms()
        for p in sparms:
            p.hide(1)

        innull = sub.createNode('null', node_name='IN')
        innull.setInput(0, sub.indirectInputs()[0])
        innull.setPosition(hou.Vector2(0, 5))
        out = sub.createNode('output', node_name='output0')
        out.setInput(0, innull)
        sub.setColor(hou.Color(colors.subnet))
        out.setColor(hou.Color(colors.output))
        node.setSelected(0)
        sub.setSelected(1)
示例#3
0
文件: lzrig.py 项目: tws0002/HTools
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)
示例#4
0
    def create_sop_exporter(self):
        # process out node
        self.out_node.setColor(hou.Color((0.9, 0.4, 0)))
        self.out_node.setUserData('nodeshape', 'bulge')

        # create exporter hda
        self.sop_exporter_node = self.parent.createNode(
            'exporter', self.sop_hda_name)
        self.sop_exporter_node.setPosition(self.out_node.position() +
                                           hou.Vector2([0, -1.3]))
        self.sop_exporter_node.setInput(0, self.out_node)
        self.sop_exporter_node.setColor(hou.Color((0, 0, 0)))

        # process cache node
        self.cache_node = hou.node(self.out_node.name().replace(
            'OUT_', 'CACHE_'))
        if self.cache_node is None:
            self.cache_node = self.parent.createNode(
                'null',
                self.out_node.name().replace('OUT_', 'CACHE_'))
            self.cache_node.setPosition(self.sop_exporter_node.position() +
                                        hou.Vector2([0, -1.3]))
            self.cache_node.setInput(0, self.sop_exporter_node)
            self.out_node_connexion_transfer()
        else:
            if self.cache_node.inputs in [(self.out_node, ), ()]:
                self.cache_node.setInput(0, self.sop_exporter_node)
                self.out_node_connexion_transfer()
            else:
                pass  # node has been connected to another node, skip
        self.cache_node.setColor(hou.Color((0.9, 0.4, 0)))
        self.cache_node.setUserData('nodeshape', 'bulge_down')
示例#5
0
def qpDist(pt0, pt1):
    """Calculate the distance between 2 vectors.

    pt0, pt1 -- type QtCore.QPoint
    """
    a = hou.Vector2(pt0.x(), pt0.y())
    b = hou.Vector2(pt1.x(), pt1.y())
    return a.distanceTo(b)
示例#6
0
    def __init__(self, state_name, scene_viewer):
        self.state_name = state_name
        self.scene_viewer = scene_viewer
        self.poly_id = -1
        self.cursor_text = "Text"
        self.geometry = None
        self.geometryHandles = None
        self.mouseStart = hou.Vector2()
        self.mouseXLast = -1
        self.mouse_screen = hou.Vector2()
        self.cursorStartPos = hou.Vector3()
        self.dragStartValue = 0
        self.handleStartPos = hou.Vector3()
        self.currentPoint = -1
        self.currentHandleIdx = -1
        self.currentPrimid = -1
        self.currentPrimu = -1
        self.currentPrimDist = -1
        self.dragAction = False
        self.isHandle = False
        self.autoSlide = False
        self.slideHandlesAhead = False
        self.slideHandlesBehind = False
        self.handlePosMethod = 0

        self.text = hou.TextDrawable(self.scene_viewer, "text")

        # Construct a geometry drawable group
        line = hou.GeometryDrawable(self.scene_viewer, hou.drawableGeometryType.Line, "line",
                                    params={
                                        "color1": (0.0, 0.0, 1.0, 1.0),
                                        "style": hou.drawableGeometryLineStyle.Plain,
                                        "line_width": 3}
                                    )

        face = hou.GeometryDrawable(self.scene_viewer, hou.drawableGeometryType.Face, "face",
                                    params={
                                        "style": hou.drawableGeometryFaceStyle.Plain,
                                        "color1": (0.0, 1.0, 0.0, 1.0)}
                                    )

        point = hou.GeometryDrawable(self.scene_viewer, hou.drawableGeometryType.Point, "point",
                                     params={
                                         "num_rings": 2,
                                         "radius": 8,
                                         "color1": (1.0, 0.0, 0.0, 1.0),
                                         "style": hou.drawableGeometryPointStyle.LinearCircle}
                                     )

        self.poly_guide = hou.GeometryDrawableGroup("poly_guide")

        self.poly_guide.addDrawable(face)
        self.poly_guide.addDrawable(line)
        self.poly_guide.addDrawable(point)
示例#7
0
 def setPosition(self, *args):
     """
     Convenience method for hou.Node.setPosition()
     """
     if not args:
         return HouQuery(data=returnData, prevData=self._data)
     if len(args) == 1:
         pos = hou.Vector2(args[0], 0)
     if len(args) > 1:
         pos = hou.Vector2(args[0], args[1])
     args = self.unshiftTuple("setPosition", (pos, ))
     return self._callAttrWithMethodName(*args)
示例#8
0
def setfit(oldcam, resx, resy):
    # get parent node
    camups = oldcam.inputAncestors()
    if camups == ():
        camup = oldcam
    else:
        camup = camups = oldcam.inputAncestors()[-1]
    # create node
    null = hou.node('obj').createNode('null', 'ScaleWorld')
    blend = hou.node('obj').createNode('blend', 'Blend_position')
    fetch = hou.node('obj').createNode('fetch', 'Fetch_newcam')
    newcam = hou.node('obj').createNode('cam', 'Render_Camera')
    # move node
    null.move(camup.position() + hou.Vector2(0, 1))
    blend.move(oldcam.position() + hou.Vector2(0, -1))
    fetch.move(oldcam.position() + hou.Vector2(0, -2))
    newcam.move(oldcam.position() + hou.Vector2(0, -3))
    # set input
    camup.setNextInput(null)
    blend.setNextInput(oldcam)
    fetch.setNextInput(blend)
    newcam.setNextInput(fetch)
    # set flag
    oldcam.setDisplayFlag(False)
    null.setDisplayFlag(False)
    blend.setDisplayFlag(False)
    fetch.setDisplayFlag(False)
    # set attr
    blend.parm(blend.path() + "/blendm1").set(63)
    fetch.parm(fetch.path() + "/useinputoffetched").set(1)
    oldcam.parm(oldcam.path() + "/resx").set(resx)
    oldcam.parm(oldcam.path() + "/resy").set(resy)
    oldcampath = oldcam.path()
    relativepath = newcam.relativePathTo(oldcam)
    resx = " ch(\"" + relativepath + "/resx\")"
    resy = " ch(\"" + relativepath + "/resy\")"
    focal = " ch(\"" + relativepath + "/focal\")"
    aperture = " ch(\"" + relativepath + "/aperture\")"
    vm_background = " ch(\"" + relativepath + "/vm_background\")"
    newcam.setParmExpressions(
        dict(resx=resx,
             resy=resy,
             focal=focal,
             aperture=aperture,
             vm_background=vm_background))
    newcam.parm("vm_bgenable").set(0)
    newcam.parm("vm_bgenable").set(0)
    newcam.parm("vm_bgenable").lock(True)
示例#9
0
        def __init__(self, gobj):
            if (not isinstance(gobj, GameObject)):
                raise TypeError("gobj must be a valid GameObject instance")
            gobj.transform = self
            self.__gameObject = gobj
            self.__localposition = hou.Vector2()
            self.__parent = None
            self.__children = set()
            self.__localangle = 0

            self.__position = hou.Vector2()  #actually cached position
            self.__angle = 0  #actually cached angle

            self.__requiresupdate = True
            self.__transmat = None  #hou.Matrix3(1)
            self.__itransmat = None  #hou.Matrix3(1)
示例#10
0
    def update(self):
        gobj = self.gameObject()

        if (self.__rewriteNeeded):
            spareshapes = [x for x in self.__shapes]
            self.__shapes = []
            stext = str(self.__score)
            for x in stext:
                node = None
                if (len(spareshapes) > 0):
                    node = spareshapes.pop(0)
                else:
                    node = hou.node(self.__nodelevel).createNode(
                        "null", "score")

                node.setUserData("nodeshape", "numbers" + x)
                self.__shapes.append(node)

            for shape in spareshapes:
                shape.destroy()
            self.__rewriteNeeded = False

        #position shapes
        pos = gobj.position
        for shape in self.__shapes:
            shape.setPosition(pos)
            pos += hou.Vector2(0.75, 0)
示例#11
0
def rescanLC( mlc, path ) :
    if path :
        exclude = mlc.parm("exclude").eval().split(" ")
        par = None
        for child in mlc.children() :
            if child.name() != "parent" :
                child.destroy()
            else :
                par = child

        y = 0
        for item in os.listdir( path ) :
            ext = item.split(".")[-1]
            name = item.replace( ".%s"%ext, "" )
            if ext == "cam" or ext == "light":
                find = None
                for pattern in exclude :
                    if pattern :
                        regex = re.compile( r"%s"%pattern.replace( "*", ".+" ) )
                        s = regex.match( name )
                        if s and ext != 'cam' :
                            find = True

                if not find :
                    node = mlc.createNode( "maya_%s" % ext, node_name = name )
                    if node.parm('dodof') : node.parm('dodof').setExpression('ch("../dodof")')
                    node.parm( "json" ).set( "$MDATA/%s" % item )
                    node.parm( "update" ).pressButton()
                    node.setPosition( hou.Vector2(0, y) )
                    node.setSelectableInViewport(0)
                    node.setFirstInput( par )
                    for child in node.children() :
                        child.setSelectableInViewport(0)

                    y += 0.5
示例#12
0
    def __init__(self, gobj):
        super(BaseColliderComponent, self).__init__(gobj)

        #warning: these radiuses are super important and it's your responsibility to set them in children classes
        self._radius = 99999
        self._radius2 = 99999
        self._pivot = hou.Vector2()
示例#13
0
 def __m3v2(self, mtx3, vec2):
     p = [0, 0]
     p[0] = vec2[0] * mtx3.at(0, 0) + vec2[1] * mtx3.at(1, 0) + mtx3.at(
         2, 0)
     p[1] = vec2[0] * mtx3.at(0, 1) + vec2[1] * mtx3.at(1, 1) + mtx3.at(
         2, 1)
     return hou.Vector2((p[0], p[1]))
示例#14
0
def omerge():
    for n in hou.selectedNodes():
        print("node: ", str(n))

        # Get node data
        node_path = n.path()
        n_pos = n.position()

        # Create object_merge node
        m = n.parent().createNode("object_merge")
        print("node parent: ", n.parent())

        # Calculate object_merge node's position
        offset_y = n.size()[1]
        v2 = hou.Vector2((0, offset_y))
        m_pos = n_pos - 3 * v2
        m.move(m_pos)

        # Set Parms of object_merge node
        parm_dict = {}
        parm_dict["numobj"] = 2
        parm_dict["objpath1"] = node_path
        parm_dict["objpath2"] = m.relativePathTo(n)
        parm_dict["enable2"] = False
        m.setParms(parm_dict)

        name = "_merge_" + n.name()

        # Set Flags on object_merge_node
        m.setName(name, True)
        m.setColor(hou.Color((0, 0, 0)))
        m.setDisplayFlag(True)
        n.setRenderFlag(False)
        m.setCurrent(True, True)
    def create_empty_shadernetwork(self):
        """Create asset's SOP shader network.

        Example:
            sceneRoot = hou.node('/obj/')
            name = "char_nono"
            create_empty_shadernetwork(name)

        Args:
            asset_name(str): name of the asset

        Returns:
            hou.Nodes

        """
        NODE_COLOR = (0.282353, 0.819608, 0.8)
        NODE_POS = (3, 0)

        custom_name = self.ui.sel_asset_name.text().upper()

        scene_root = hou.node('/obj/')
        shaderpack_name = 'SHADER_' + custom_name
        shaderpack_root = '/obj/' + shaderpack_name
        if hou.node(shaderpack_root):
            hou.node(shaderpack_root).destroy()
        else:
            pass
        shaderpack_node = scene_root.createNode('geo', shaderpack_name)
        shaderpack_node.setColor(hou.Color(*NODE_COLOR))

        shaderpack_node.createNode('shopnet', 'shopnet')
        shaderpack_node.createNode('matnet', 'matnet').setPosition(
            hou.Vector2(*NODE_POS))
示例#16
0
    def create_network_box(self, 
                            parent_node, 
                            child_node_list, 
                            network_box_name = None, 
                            position_x = 0,
                            position_y = 0):
        """
        Create network box with children and optional name.
        """

        #network_box_node
        network_box_node = parent_node.createNetworkBox(network_box_name)

        #layout children
        parent_node.layoutChildren(child_nodes = child_node_list)

        #add children
        for child_node in child_node_list:

            #add
            network_box_node.addNode(child_node)

        #fit
        network_box_node.fitAroundContents()

        #setPosition
        vec_position = hou.Vector2((position_x, position_y))
        network_box_node.setPosition(vec_position)
示例#17
0
def createNodes():
    for node in hou.selectedNodes():
        curParent = node.parent().name()

        rop = out.createNode("geometry", node.name())
        rop.moveToGoodPosition()
        file = node.parent().createNode("file")

        try:
            outNodes = node.outputs()
            for i, outNode in enumerate(outNodes):
                for j, inNode in enumerate(outNode.inputs()):
                    if inNode != None:
                        if inNode.name() == node.name():
                            #print j
                            outNode.setInput(j, file)
        except:
            pass

        rop.parm("soppath").set(node.path())
        ropOutput = '`chs("' + rop.path() + '/sopoutput")`'
        file.parm("file").set(ropOutput)
        file.parm("missingframe").set(1)
        file.setInput(0, node)
        file.setPosition(node.position() + hou.Vector2(0, -1))

        txt = 'create "' + rop.path() + '" and "' + file.path() + '"'
        hou.ui.setStatusMessage(txt,
                                severity=hou.severityType.ImportantMessage)
示例#18
0
def deleteByName16():
    node = hou.selectedNodes()[0]
    if node:
        selNames = []
        geo = node.geometry()
        viewer = toolutils.sceneViewer()
        viewportSel = viewer.selectGeometry()
        for selection in viewportSel.selections():
            type = selection.selectionType()
            elements = selection.points(
                geo) if type == hou.geometryType.Points else selection.prims(
                    geo)
            grouptype = "point" if type == hou.geometryType.Points else "prims"
            for p in elements:
                name = p.attribValue("name")
                selNames.append("@name=%s" % name)

        selString = ' '.join(list(set(selNames)))

        parent = node.parent()
        pos = node.position()

        blast = parent.createNode("blast")
        blast.setPosition(pos + hou.Vector2(0, -1))
        blast.setInput(0, node)
        blast.parm("group").set(selString)
        blast.parm("negate").set(1)
        blast.setDisplayFlag(1)
        blast.setRenderFlag(1)
        node.setSelected(0)
        blast.setSelected(1)
示例#19
0
def create_empty_shadernetwork(asset_name):
    """Create asset's SOP shader network.

    Example:
        sceneRoot = hou.node('/obj/')
        name = "char_nono"
        create_empty_shadernetwork(name)

    Args:
        asset_name(str): name of the asset

    Returns:
        hou.Nodes

    """
    NODE_COLOR = (0.282353, 0.819608, 0.8)
    NODE_POS = (3, 0)

    shaderpack_name = 'SHADER_' + asset_name.upper()
    shaderpack_node = sceneRoot.createNode('geo', shaderpack_name)
    shaderpack_node.setColor(hou.Color(*NODE_COLOR))

    shaderpack_node.createNode('shopnet', 'shopnet')
    shaderpack_node.createNode('matnet', 'matnet').setPosition(
        hou.Vector2(*NODE_POS)
    )
    shaderpack_node.setCurrent(on=True, clear_all_selected=True)
    shaderpack_node.setDisplayFlag(True)
示例#20
0
def BaseRenderSet():
    """
    This func is return Preset RenderROP&MatPath

    Samples***
    BaseRenderSet()
    """
    import hou
    root = hou.node("/obj")
    ROP_Node = root.createNode("ropnet", "ROP")
    MAT_Node = root.createNode("matnet", "MAT")

    #ROP sectiion
    RopPath = ROP_Node.path()
    MantraNode = hou.node(RopPath)
    MantraNode.createNode("ifd", "PaletteRender")

    #MAT sectiion
    MatPath = MAT_Node.path()
    BuilderNode = hou.node(MatPath)
    BuilderNode.createNode("materialbuilder", "Mat_Container")

    GetPos = hou.Vector2([0, 0])

    ROP_Node.setPosition([GetPos[0], GetPos[1]])
    MAT_Node.setPosition([GetPos[0], GetPos[1] - 1])

    netBox = root.createNetworkBox()
    netBox.addItem(ROP_Node)
    netBox.addItem(MAT_Node)
    netBox.setComment("RenderWorkSet")
    netBox.fitAroundContents()

    del hou
示例#21
0
def create_rootSubnet(context, fixINode, fixIParentPath, fixINodePos,
                      projectSettings):
    """ set the fix import node display """
    color = fixINode.setColor(hou.Color((0.6, 1.0, 0.6)))

    try:
        fixINode.setName(projectSettings)

    except:
        pass
    """ set the fix import node display """
    root = hou.node(fixIParentPath).createNode(remapRootNode, remapRoot, 1)
    root.setPosition(hou.Vector2(fixINodePos[0], fixINodePos[1] - 1.5))
    color = root.setColor(hou.Color((1, 0.96, 0.45)))
    root.setInput(0, fixINode, 0)
    """ create subnet transform node """
    transform = hou.node(root.path()).createNode(remapRootNode, remapTransform,
                                                 1)
    subnetOutput = root.indirectInputs()
    transform.setInput(0, subnetOutput[0])
    color = transform.setColor(hou.Color((1, 0.96, 0.45)))
    """ apply sceneScale scale to root """
    fixImportNodeName = fixINode.name()
    root.parm('tx').lock(1)
    root.parm('ty').lock(1)
    root.parm('tz').lock(1)
    root.parm('rx').lock(1)
    root.parm('ry').lock(1)
    root.parm('rz').lock(1)
    root.parm('sx').lock(1)
    root.parm('sy').lock(1)
    root.parm('sz').lock(1)
    root.parm('px').lock(1)
    root.parm('py').lock(1)
    root.parm('pz').lock(1)
    root.parm('scale').setExpression('ch("../' + fixImportNodeName +
                                     '/global_scale")')
    """ apply scene transform to transform """
    fixImportNodeName = fixINode.name()
    transform.parm('tx').setExpression('ch("../../' + fixImportNodeName +
                                       '/translatex")')
    transform.parm('ty').setExpression('ch("../../' + fixImportNodeName +
                                       '/translatey")')
    transform.parm('tz').setExpression('ch("../../' + fixImportNodeName +
                                       '/translatez")')
    transform.parm('rx').setExpression('ch("../../' + fixImportNodeName +
                                       '/rotatex")')
    transform.parm('ry').setExpression('ch("../../' + fixImportNodeName +
                                       '/rotatey")')
    transform.parm('rz').setExpression('ch("../../' + fixImportNodeName +
                                       '/rotatez")')
    transform.parm('sx').lock(1)
    transform.parm('sy').lock(1)
    transform.parm('sz').lock(1)
    transform.parm('px').lock(1)
    transform.parm('py').lock(1)
    transform.parm('pz').lock(1)
    transform.parm('scale').lock(1)
    return transform
示例#22
0
def make_obj_merge(node):
    om = node.parent().createNode('object_merge', 'get__'+node.name(), run_init_scripts=True, load_contents=True, exact_type_name=True)
        
    om.setPosition(node.position())
    #om.moveToGoodPosition()
    om.move(hou.Vector2(1, -1))
    om.parm('objpath1').set(om.relativePathTo(node))
    om.parm('xformtype').set('none')
示例#23
0
def main():
    nodes = hou.selectedNodes()
    for node in nodes:
        file_path = node.parm('file').eval()
        temp = file_path.split('.')
        temp[-2] = '$F'
        file_path = '.'.join(temp)
        abs_file = node.parent().createNode('file')
        abs_file.parm('file').set(file_path)
        abs_file.move(node.position() + hou.Vector2(-3, 0))
示例#24
0
        def left(self):
            '''
			get left pointing normal hou.Vector2
			'''
            rangle = radians(self.angle)
            si = sin(rangle)
            co = cos(rangle)
            x = co
            y = si
            return hou.Vector2((x, y))
示例#25
0
        def fwd(self):
            '''
			get forward pointing normal hou.Vector2
			'''
            rangle = radians(self.angle)
            si = sin(rangle)
            co = cos(rangle)
            x = -si
            y = co
            return hou.Vector2((x, y))
示例#26
0
def drag(include_ancestors=False, dx=0, dy=0):
    items = set(hou.selectedItems())
    if include_ancestors:
        ancestors = set()
        for node in items:
            ancestors = ancestors.union(set(node.inputAncestors()))
        items = items.union(ancestors)

    with hou.undos.group("Move nodes"):
        for selected in items:
            position = selected.position()
            position += hou.Vector2(dx, dy)
            selected.setPosition(position)
示例#27
0
def extractTrans():
    s = hou.selectedNodes()
    if s:
        node = None
        out = None
        if s[0].type().category().name() == 'Object':
            node = s[0]
            out = hou.node('%s/__display_sop__' % node.path())
        if s[0].type().category().name() == 'Sop':
            out = s[0]
            node = out.parent()
        if node and out:
            pos = out.position()
            shift = node.createNode('timeshift')
            shift.setPosition(pos + hou.Vector2(-1, -1))
            shift.setInput(0, out)
            shift.parm('frame').deleteAllKeyframes()
            shift.parm('frame').set(1)

            black = hou.Color((0, 0, 0))

            static = node.createNode('null', 'STATIC')
            static.setPosition(pos + hou.Vector2(-1, -2))
            static.setInput(0, shift)
            static.setColor(black)

            animated = node.createNode('null', 'ANIMATED')
            animated.setPosition(pos + hou.Vector2(1, -2))
            animated.setInput(0, out)
            animated.setColor(black)

            transform = node.parent().createNode('extractgeo',
                                                 '%s_transform' % node.name())
            transform.setPosition(node.position() + hou.Vector2(2, 0))
            transform.parm('srcpath').set(static.path())
            transform.parm('dstpath').set(animated.path())
            node.setSelected(0)
            transform.setSelected(1)
    return None
示例#28
0
文件: lzrig.py 项目: tws0002/HTools
def createPerFaceHooks(n):
    end = n.displayNode()
    #create make_face_uvs node
    make_face_uvs = end.createOutputNode("attribwrangle", "make_face_uvs")
    make_face_uvs.setPosition(end.position() + hou.Vector2(0, -1))
    make_face_uvs.parm("class").set(1)
    make_face_uvs.parm("snippet").set(
        'int pts[] = primpoints(0,@primnum);\nsetpointattrib(0,"uv",pts[0],{0,0,0} + set(@primnum,0,0));\nsetpointattrib(0,"uv",pts[1],{0,1,0} + set(@primnum,0,0));\nsetpointattrib(0,"uv",pts[2],{1,1,0} + set(@primnum,0,0));\nsetpointattrib(0,"uv",pts[3],{1,0,0} + set(@primnum,0,0));'
    )

    #create OUT_HOOKS node
    OUT_HOOKS = make_face_uvs.createOutputNode("null", "OUT_HOOKS")
    OUT_HOOKS.setPosition(make_face_uvs.position() + hou.Vector2(0, -1))

    for prim in OUT_HOOKS.geometry().prims():
        tasset_hook = n.createOutputNode("sticky", n.name() + "_hook1")
        tasset_hook.setPosition(n.position() + hou.Vector2(
            1.5 *
            (hou.hscriptExpression('opdigits("' + tasset_hook.name() + '")') -
             1), -1))
        tasset_hook.parm("stickysop").set('../`opinput(".",0)`/OUT_HOOKS')
        tasset_hook.parm('stickyuv1').setExpression(
            'opdigits($OS) - 0.5', language=hou.exprLanguage.Hscript)
        tasset_hook.setDisplayFlag(True)
        #kinda bad kinda lazy
        tasset_hook.parm("stickyurange2").set(100.0)
        tasset_hook.setDisplayFlag(0)

        #create tasset_hook_ctrl node
        tasset_hook_ctrl = tasset_hook.createOutputNode(
            "null",
            tasset_hook.name() + "_ctrl")
        tasset_hook_ctrl.setPosition(tasset_hook.position() +
                                     hou.Vector2(0.0, -1))
        tasset_hook_ctrl.parm("geoscale").set(0.05)
        tasset_hook_ctrl.parm("controltype").set(1)

        clearWorldRotates(tasset_hook_ctrl)
示例#29
0
    def create_box_subnet():
        obj = hou.node('/obj')
        box_geo = obj.createNode('geo', 'box_geo', run_init_scripts=False)

        box1 = box_geo.createNode('box', 'box1')
        box1.parm('scale').set(0.8)

        box2 = box_geo.createNode('box', 'box2')
        box2.parmTuple('size').set((0.5, 0.5, 0.5))

        copy = box_geo.createNode('copytopoints', 'copy')
        copy.parm('transform').set(False)
        copy.setInput(0, box2)
        copy.setInput(1, box1)

        hou.appendSessionModuleSource('volume_size = 100')
        hou.appendSessionModuleSource('volume_amp = 10')

        python_code = """
                      node = hou.pwd()
                      geo = node.geometry()
                      temp = hou.Geometry()
                      sops = hou.sopNodeTypeCategory()
                      box = sops.nodeVerb("box")
                      box.setParms({'scale':1.2})
                      box.execute(temp, [])
                      vdb = sops.nodeVerb("vdbfrompolygons")
                      vdb.setParms({'builddistance':0,'buildfog':1,'voxelsize':0.02})
                      vdb.execute(temp, [temp])
                      geo.merge(temp)
                      """
        python = box_geo.createNode('python', 'python')
        python.parm('python').set(textwrap.dedent(python_code))
        python.setInput(0, copy)

        xform = box_geo.createNode('xform', 'xform')
        xform.setInput(0, python)
        xform.setDisplayFlag(True)
        xform.setRenderFlag(True)

        note = box_geo.createStickyNote('test_note')
        note.setText('This is a test note')

        box_geo.layoutChildren()
        note.setPosition(xform.position() + hou.Vector2((2, 0)))

        children = (box1, box2, copy, python, xform, note)
        box_subnet = box_geo.collapseIntoSubnet(children,
                                                subnet_name='box_subnet')
        return box_subnet
示例#30
0
文件: ruler.py 项目: mokchira/ruler
def createArcGeometry(angle, radius):
    divs_per_degree = 0.12  #arbitary. works out to 12 divs every 90 degrees
    geo = hou.Geometry()
    circle_verb = hou.sopNodeTypeCategory().nodeVerb("circle")
    hou.SopVerb.setParms(
        circle_verb, {
            'type': 1,
            'arc': 1,
            'angle': hou.Vector2(0, angle),
            'divs': divs_per_degree * angle,
            'scale': radius
        })
    hou.SopVerb.execute(circle_verb, geo, [])
    return geo