コード例 #1
0
    def set_frame_range(self,
                        start_frame=1,
                        end_frame=100,
                        adjust_frame_range=False):
        """sets the frame range
        """
        # --------------------------------------------
        # set the timeline
        current_frame = hou.frame()
        if current_frame < start_frame:
            hou.setFrame(start_frame)
        elif current_frame > end_frame:
            hou.setFrame(end_frame)

        # for now use hscript, the python version is not implemented yet
        hou.hscript('tset `(' + str(start_frame) + '-1)/$FPS` `' +
                    str(end_frame) + '/$FPS`')

        # --------------------------------------------
        # Set the render nodes frame ranges if any
        # get the out nodes
        output_nodes = self.get_output_nodes()

        for output_node in output_nodes:
            output_node.setParms({
                'trange': 0,
                'f1': start_frame,
                'f2': end_frame,
                'f3': 1
            })
コード例 #2
0
    def testParticlePrimitive(self):
        obj = hou.node("/obj")
        geo = obj.createNode("geo", run_init_scripts=False)
        popnet = geo.createNode("popnet")
        location = popnet.createNode("location")
        detailAttr = popnet.createOutputNode("attribcreate",
                                             exact_type_name=True)
        detailAttr.parm("name").set("float3detail")
        detailAttr.parm("class").set(0)  # detail
        detailAttr.parm("type").set(0)  # float
        detailAttr.parm("size").set(3)  # 3 elements
        detailAttr.parm("value1").set(1)
        detailAttr.parm("value2").set(2)
        detailAttr.parm("value3").set(3)
        pointAttr = detailAttr.createOutputNode("attribcreate",
                                                exact_type_name=True)
        pointAttr.parm("name").set("float3point")
        pointAttr.parm("class").set(2)  # point
        pointAttr.parm("type").set(0)  # float
        pointAttr.parm("size").set(3)  # 3 elements
        pointAttr.parm("value1").set(1)
        pointAttr.parm("value2").set(2)
        pointAttr.parm("value3").set(3)

        hou.setFrame(5)
        converter = IECoreHoudini.FromHoudiniPolygonsConverter(pointAttr)
        self.assertRaises(RuntimeError, converter.convert)

        add = pointAttr.createOutputNode("add")
        add.parm("keep").set(1)  # deletes primitive and leaves points

        m = IECoreHoudini.FromHoudiniPolygonsConverter(add).convert()
        self.failUnless(isinstance(m, IECoreScene.MeshPrimitive))
        self.assertEqual(m, IECoreScene.MeshPrimitive())
コード例 #3
0
ファイル: PandoraSubmitter.py プロジェクト: luisfos/Pandora
	def houGetExternalFiles(self):
		hou.setFrame(hou.playbar.playbackRange()[0])
		whitelist = ['$HIP/$OS-bounce.rat', '$HIP/$OS-fill.rat', '$HIP/$OS-key.rat', '$HIP/$OS-rim.rat']
		houdeps = hou.fileReferences()
		extFiles = []
		extFilesSource = []
		for x in houdeps:
			if "/Redshift/Plugins/Houdini/" in x[1]:
				continue

			if x[0] is None:
				continue

			if x[1] in whitelist:
				continue

			if not os.path.isabs(hou.expandString(x[1])):
				continue

			if os.path.splitext(hou.expandString(x[1]))[1] == "":
				continue

			if x[0] is not None and x[0].name() in ["RS_outputFileNamePrefix", "vm_picture"]:
				continue

			if x[0] is not None and x[0].name() in ["filename", "dopoutput", "copoutput", "sopoutput"] and x[0].node().type().name() in ["rop_alembic", "rop_dop", "rop_comp", "rop_geometry"]:
				continue

			extFiles.append(hou.expandString(x[1]).replace("\\", "/"))
			extFilesSource.append(x[0])

		#return [extFiles, extFilesSource]
		return extFiles
コード例 #4
0
	def testMultipleParticlePrimitives( self ) :
		
		obj = hou.node("/obj")
		geo = obj.createNode( "geo", run_init_scripts=False )
		popnet = geo.createNode( "popnet" )
		fireworks = popnet.createNode( "fireworks" )
		
		hou.setFrame( 15 )
		converter = IECoreHoudini.FromHoudiniPointsConverter( popnet )
		points = converter.convert()
		
		self.assertEqual( type(points), IECore.PointsPrimitive )
		self.assertEqual( points.variableSize( IECore.PrimitiveVariable.Interpolation.Vertex ), 24 )
		self.assertEqual( points["accel"].interpolation, IECore.PrimitiveVariable.Interpolation.Vertex )
		self.assertEqual( type(points["accel"].data), IECore.V3fVectorData )
		self.assertEqual( points["accel"].data.getInterpretation(), IECore.GeometricData.Interpretation.Vector )
		self.assertEqual( points["nextid"].interpolation, IECore.PrimitiveVariable.Interpolation.Constant )
		self.assertEqual( points["nextid"].data, IECore.IntData( 25 ) )
		self.assertTrue( points.arePrimitiveVariablesValid() )
		
		add = popnet.createOutputNode( "add" )
		add.parm( "keep" ).set( 1 ) # deletes primitive and leaves points
		
		converter = IECoreHoudini.FromHoudiniPointsConverter( add )
		points2 = converter.convert()
		# showing that prim attribs don't get converted because the interpolation size doesn't match
		self.assertEqual( points2, points )
コード例 #5
0
def setFrameRangeData():

    start_frame = float(os.getenv('FS'))
    end_frame = float(os.getenv('FE'))
    shot_id = os.getenv('FTRACK_SHOTID')
    shot = ftrack.Shot(id=shot_id)
    fps = shot.get('fps')
    if 'handles' in shot.keys():
        handles = float(shot.get('handles'))
    else:
        handles = 0.0

    print 'setting timeline to %s %s ' % (start_frame, end_frame)

    # add handles to start and end frame
    hsf = (start_frame - 1) - handles
    hef = end_frame + handles

    hou.setFps(fps)
    hou.setFrame(start_frame)

    try:
        if start_frame != end_frame:
            hou.hscript("tset {0} {1}".format((hsf) / fps, hef / fps))
            hou.playbar.setPlaybackRange(start_frame, end_frame)
    except IndexError:
        pass
コード例 #6
0
	def testPrimitiveGroupModeWithTransformAttribute( self ) :
		cache = self.cacheSop( file="test/IECoreHoudini/data/torusWithVertexNormals.bgeo" )
		cache.parm( "groupingMode" ).set( 0 )
		hou.parm( "/obj/geo1/group1/entity" ).set( 0 )
		hou.setFrame( 2 )
		orig = IECoreHoudini.FromHoudiniPolygonsConverter( cache ).convert()
		cache.parm( "transformAttribute" ).set( "transform" )
		result = IECoreHoudini.FromHoudiniPolygonsConverter( cache ).convert()
		self.assertNotEqual( orig, result )
		self.assertNotEqual( orig['P'], result['P'] )
		self.assertNotEqual( orig['N'], result['N'] )
		self.assertEqual( orig['P'].data.size(), result['P'].data.size() )
		self.assertEqual( orig['N'].data.size(), result['N'].data.size() )
		self.assertEqual( orig['Cs'], result['Cs'] )
		self.assertEqual( orig['pointId'], result['pointId'] )
		
		i = IECore.InterpolatedCache( cache.parm( "cacheSequence" ).eval(), IECore.InterpolatedCache.Interpolation.Linear, IECore.OversamplesCalculator( 24, 1 ) )
		matrix = i.read( 2, "torus", "transform" ).value.transform
		origP = orig["P"].data
		origN = orig["N"].data
		resultP = result["P"].data
		resultN = result["N"].data
		for i in range( 0, origP.size() ) :
			self.assertNotEqual( resultP[i], origP[i] )
			self.assertNotEqual( resultN[i], origN[i] )
			self.assertEqual( resultP[i], matrix.multVecMatrix( origP[i] ) )
			self.failUnless( resultN[i].equalWithAbsError( matrix.multDirMatrix( origN[i] ), 1e-6 ) )
コード例 #7
0
	def testPrimitiveGroupModeWithMultipleObjects( self ) :
		hou.setFrame( 3 )
		cache = self.cacheSop( file="test/IECoreHoudini/data/torusWithVertexNormals.bgeo" )
		cache.parm( "groupingMode" ).set( 0 )
		hou.parm( "/obj/geo1/group1/entity" ).set( 0 )
		torus = cache.parent().createNode( "file" )
		torus.parm( "file" ).set( "test/IECoreHoudini/data/torusWithVertexNormals.bgeo" )
		group = torus.createOutputNode( "group" )
		group.parm( "crname" ).set( "torus2" )
		merge = cache.inputs()[0].createOutputNode( "merge" )
		merge.setInput( 1, group )
		cache.setInput( 0, merge )
		result = IECoreHoudini.FromHoudiniPolygonsConverter( cache ).convert()
		numTorusPoints = len(torus.geometry().points())
		for key in [ "P", "Cs" ] :
			self.assert_( key in result )
			self.assertEqual( result[key].data.size(), 2 * numTorusPoints )
		
		for i in range( 0, numTorusPoints ) :
			self.assertNotEqual( result['P'].data[i], result['P'].data[numTorusPoints+i] )
			self.assertEqual( result['Cs'].data[i], result['Cs'].data[numTorusPoints+i] )
		
		numTorusVerts = sum( [ len(x.vertices()) for x in torus.geometry().prims() ] )
		self.assert_( "N" in result )
		self.assertEqual( result["N"].data.size(), 2 * numTorusVerts )
		for i in range( 0, numTorusVerts ) :
			self.assertNotEqual( result['N'].data[i], result['N'].data[numTorusPoints+i] )
コード例 #8
0
	def testPrimitiveGroupModeWithVertexAttribs( self ) :
		
		# N defaults to a Point attrib
		hou.setFrame( 4 )
		cache = self.cacheSop()
		self.failUnless( isinstance( cache.geometry().findPointAttrib( "N" ), hou.Attrib ) )
		self.failUnless( cache.geometry().findVertexAttrib( "N" ) is None )
		result = IECoreHoudini.FromHoudiniPolygonsConverter( cache ).convert()
		self.failUnless( "N" in result.keys() )
		self.assertEqual( result["N"].interpolation, IECore.PrimitiveVariable.Interpolation.Vertex )
		self.assertEqual( len(result["N"].data), result.variableSize( IECore.PrimitiveVariable.Interpolation.Vertex ) )
		
		# Since N actually has more values than points should, N becomes a Vertex attrib if we use PrimitiveGroup mode
		group = hou.node( "/obj/geo1/group1" )
		group.parm( "entity" ).set( 0 )
		cache.parm( "groupingMode" ).set( 0 )
		self.failUnless( cache.geometry().findPointAttrib( "N" ) is None )
		self.failUnless( isinstance( cache.geometry().findVertexAttrib( "N" ), hou.Attrib ) )
		result = IECoreHoudini.FromHoudiniPolygonsConverter( cache ).convert()
		self.failUnless( "N" in result.keys() )
		self.assertEqual( result["N"].interpolation, IECore.PrimitiveVariable.Interpolation.FaceVarying )
		self.assertEqual( len(result["N"].data), result.variableSize( IECore.PrimitiveVariable.Interpolation.FaceVarying ) )
		
		# Even if we create N as a Point attrib before the cache, it remains a Vertex attrib since the sizes do not match
		facet = group.createOutputNode( "facet" )
		facet.parm( "postnml" ).set( True )
		cache.setInput( 0, facet )
		self.failUnless( isinstance( facet.geometry().findPointAttrib( "N" ), hou.Attrib ) )
		self.failUnless( facet.geometry().findVertexAttrib( "N" ) is None )
		self.failUnless( cache.geometry().findPointAttrib( "N" ) is None )
		self.failUnless( isinstance( cache.geometry().findVertexAttrib( "N" ), hou.Attrib ) )
		result = IECoreHoudini.FromHoudiniPolygonsConverter( cache ).convert()
		self.failUnless( "N" in result.keys() )
		self.assertEqual( result["N"].interpolation, IECore.PrimitiveVariable.Interpolation.FaceVarying )
		self.assertEqual( len(result["N"].data), result.variableSize( IECore.PrimitiveVariable.Interpolation.FaceVarying ) )
コード例 #9
0
    def _onNewHoudiniFile(self, name: str,
                          file_dialog: re_project_manager.NewFileDialogUI):
        default_ext = HoudiniProjectManagerUI.getExtension()
        if not name.lower().endswith(default_ext):
            name = name + default_ext

        new_file_name = Path(name)

        if new_file_name.exists():
            QtWidgets.QMessageBox.question(
                self, "File already exists!",
                "File with this name already exists!",
                QtWidgets.QMessageBox.Ok)
        else:
            hou.hipFile.clear()
            hou.hipFile.setName(new_file_name.as_posix())

            hou.hscript("set -g HRES={}".format(
                re_project.get_project_default_rez()['x']))
            hou.hscript("set -g VRES={}".format(
                re_project.get_project_default_rez()['y']))

            hou.setFps(re_project.get_project_default_fps())

            if file_dialog.asset_type == re_project_manager.NewFileDialogUI.ASSET_TYPE_SHOT:
                hou.playbar.setFrameRange(1001, 1200)
                hou.playbar.setPlaybackRange(1001, 1200)
                hou.setFrame(1001)

            hou.hscript("set -g NAME={}".format(file_dialog.asset_main_name))

            hou.hipFile.save()
            self.statusBar.showMessage("New Houdini file {} created".format(
                new_file_name.name))
コード例 #10
0
    def testPrimitiveGroupModeWithMultipleObjects(self):
        hou.setFrame(3)
        cache = self.cacheSop(
            file="test/IECoreHoudini/data/torusWithVertexNormals.bgeo")
        cache.parm("groupingMode").set(0)
        hou.parm("/obj/geo1/group1/entity").set(0)
        torus = cache.parent().createNode("file")
        torus.parm("file").set(
            "test/IECoreHoudini/data/torusWithVertexNormals.bgeo")
        group = torus.createOutputNode("group")
        group.parm("crname").set("torus2")
        merge = cache.inputs()[0].createOutputNode("merge")
        merge.setInput(1, group)
        cache.setInput(0, merge)
        result = IECoreHoudini.FromHoudiniPolygonsConverter(cache).convert()
        numTorusPoints = len(torus.geometry().points())
        for key in ["P", "Cs"]:
            self.assert_(key in result)
            self.assertEqual(result[key].data.size(), 2 * numTorusPoints)

        for i in range(0, numTorusPoints):
            self.assertNotEqual(result['P'].data[i],
                                result['P'].data[numTorusPoints + i])
            self.assertEqual(result['Cs'].data[i],
                             result['Cs'].data[numTorusPoints + i])

        numTorusVerts = sum(
            [len(x.vertices()) for x in torus.geometry().prims()])
        self.assert_("N" in result)
        self.assertEqual(result["N"].data.size(), 2 * numTorusVerts)
        for i in range(0, numTorusVerts):
            self.assertNotEqual(result['N'].data[i],
                                result['N'].data[numTorusPoints + i])
コード例 #11
0
    def testPrimitiveGroupModeWithTransformAttribute(self):
        cache = self.cacheSop(
            file="test/IECoreHoudini/data/torusWithVertexNormals.bgeo")
        cache.parm("groupingMode").set(0)
        hou.parm("/obj/geo1/group1/entity").set(0)
        hou.setFrame(2)
        orig = IECoreHoudini.FromHoudiniPolygonsConverter(cache).convert()
        cache.parm("transformAttribute").set("transform")
        result = IECoreHoudini.FromHoudiniPolygonsConverter(cache).convert()
        self.assertNotEqual(orig, result)
        self.assertNotEqual(orig['P'], result['P'])
        self.assertNotEqual(orig['N'], result['N'])
        self.assertEqual(orig['P'].data.size(), result['P'].data.size())
        self.assertEqual(orig['N'].data.size(), result['N'].data.size())
        self.assertEqual(orig['Cs'], result['Cs'])
        self.assertEqual(orig['pointId'], result['pointId'])

        i = IECore.InterpolatedCache(
            cache.parm("cacheSequence").eval(),
            IECore.InterpolatedCache.Interpolation.Linear,
            IECore.OversamplesCalculator(24, 1))
        matrix = i.read(2, "torus", "transform").value.transform
        origP = orig["P"].data
        origN = orig["N"].data
        resultP = result["P"].data
        resultN = result["N"].data
        for i in range(0, origP.size()):
            self.assertNotEqual(resultP[i], origP[i])
            self.assertNotEqual(resultN[i], origN[i])
            self.assertEqual(resultP[i], matrix.multVecMatrix(origP[i]))
            self.failUnless(resultN[i].equalWithAbsError(
                matrix.multDirMatrix(origN[i]), 1e-6))
コード例 #12
0
def play_scrub(multiplier):
    import time
    from PySide2.QtGui import QCursor

    mouse_last = hou.getenv("mouse", "0")
    mouse_last = float(mouse_last)
    mouse_now = QCursor().pos()

    time_now = time.time()
    time_last = hou.getenv("time", "0")
    time_last = float(time_last)
    time_diff = time_now - time_last

    mouse_now = round(mouse_now.x() / 10)

    if time_diff > 0.1:
        mouse_last = mouse_now

    skip = mouse_last - mouse_now
    skip = skip * multiplier
    if abs(skip) > 20:
        skip = skip * 2

    frame_now = hou.frame()
    frame_now = hou.frame() - skip
    hou.setFrame(frame_now)

    hou.putenv("mouse", str(mouse_now))
    hou.putenv("time", str(time_now))
コード例 #13
0
	def testNoFileForFrame( self ) :
		cache = self.cacheSop()
		cache.parm( "cacheSequence" ).set( "test/IECoreHoudini/data/torusVertCache.####.fio" )
		hou.setFrame( 5 )
		cache.cook( force=True )
		self.failUnless( cache.warnings() )
		self.assertEqual( len(cache.geometry().points()), 0 )
コード例 #14
0
ファイル: houdini.py プロジェクト: theomission/anima
    def set_frame_range(self, start_frame=1, end_frame=100, adjust_frame_range=False):
        """sets the frame range
        """
        # --------------------------------------------
        # set the timeline
        current_frame = hou.frame()
        if current_frame < start_frame:
            hou.setFrame(start_frame)
        elif current_frame > end_frame:
            hou.setFrame(end_frame)

        # for now use hscript, the python version is not implemented yet
        hou.hscript(
            'tset `(' + str(start_frame) + '-1)/$FPS` `' + str(
                end_frame) + '/$FPS`'
        )

        # --------------------------------------------
        # Set the render nodes frame ranges if any
        # get the out nodes
        output_nodes = self.get_output_nodes()

        for output_node in output_nodes:
            output_node.setParms(
                {'trange': 0, 'f1': start_frame, 'f2': end_frame, 'f3': 1}
            )
コード例 #15
0
def processMesh(nodes, nodePieces, numPieces):
    PARMS = ["tx", "ty", "tz", "rx", "ry", "rz", "px", "py", "pz"]
    RFSTART = int(hou.expandString('$RFSTART'))
    RFEND = int(hou.expandString('$RFEND'))

    initialParmData = []

    #GET INITIAL TRANSFORMS
    hou.setFrame(frame)
    for objectToProcess in range(0, len(numPieces)):
        initialParmData.append(objectToProcess)

        for index in range(0, numPieces[objectToProcess]):
            initialParmData[objectToProcess].append(index)

            for index_parm in range(0, 3):
                #Get original tx,ty,tz
                initialParmData[objectToProcess][index].append(
                    nodes[objectToProcess].points()[index].attribValue(
                        'P')[index_parm])

            for index_parm in range(0, 3):
                #Get original rx,ry,rz
                initialParmData[objectToProcess][index].append(
                    nodes[objectToProcess].points()[index].attribValue(
                        'R')[index_parm])
コード例 #16
0
	def testParticlePrimitive( self ) :
		obj = hou.node("/obj")
		geo = obj.createNode( "geo", run_init_scripts=False )
		popnet = geo.createNode( "popnet" )
		location = popnet.createNode( "location" )
		detailAttr = popnet.createOutputNode( "attribcreate", exact_type_name=True )
		detailAttr.parm("name").set( "float3detail" )
		detailAttr.parm("class").set( 0 ) # detail
		detailAttr.parm("type").set( 0 ) # float
		detailAttr.parm("size").set( 3 ) # 3 elements
		detailAttr.parm("value1").set( 1 )
		detailAttr.parm("value2").set( 2 )
		detailAttr.parm("value3").set( 3 )
		pointAttr = detailAttr.createOutputNode( "attribcreate", exact_type_name=True )
		pointAttr.parm("name").set( "float3point" )
		pointAttr.parm("class").set( 2 ) # point
		pointAttr.parm("type").set( 0 ) # float
		pointAttr.parm("size").set( 3 ) # 3 elements
		pointAttr.parm("value1").set( 1 )
		pointAttr.parm("value2").set( 2 )
		pointAttr.parm("value3").set( 3 )
		
		hou.setFrame( 5 )
		converter = IECoreHoudini.FromHoudiniPolygonsConverter( pointAttr )
		self.assertRaises( RuntimeError, converter.convert )
		
		add = pointAttr.createOutputNode( "add" )
		add.parm( "keep" ).set( 1 ) # deletes primitive and leaves points
		
		m = IECoreHoudini.FromHoudiniPolygonsConverter( add ).convert()
		self.failUnless( isinstance( m, IECore.MeshPrimitive ) )
		self.assertEqual( m, IECore.MeshPrimitive() )
コード例 #17
0
	def testMultipleParticlePrimitives( self ) :
		
		obj = hou.node("/obj")
		geo = obj.createNode( "geo", run_init_scripts=False )
		popnet = geo.createNode( "popnet" )
		fireworks = popnet.createNode( "fireworks" )
		
		hou.setFrame( 15 )
		converter = IECoreHoudini.FromHoudiniPointsConverter( popnet )
		points = converter.convert()
		
		self.assertEqual( type(points), IECore.PointsPrimitive )
		self.assertEqual( points.variableSize( IECore.PrimitiveVariable.Interpolation.Vertex ), 24 )
		self.assertEqual( points["accel"].interpolation, IECore.PrimitiveVariable.Interpolation.Vertex )
		self.assertEqual( type(points["accel"].data), IECore.V3fVectorData )
		self.assertEqual( points["accel"].data.getInterpretation(), IECore.GeometricData.Interpretation.Vector )
		self.assertEqual( points["nextid"].interpolation, IECore.PrimitiveVariable.Interpolation.Constant )
		self.assertEqual( points["nextid"].data, IECore.IntData( 25 ) )
		self.assertTrue( points.arePrimitiveVariablesValid() )
		
		add = popnet.createOutputNode( "add" )
		add.parm( "keep" ).set( 1 ) # deletes primitive and leaves points
		
		converter = IECoreHoudini.FromHoudiniPointsConverter( add )
		points2 = converter.convert()
		# showing that prim attribs don't get converted because the interpolation size doesn't match
		self.assertEqual( points2, points )
コード例 #18
0
    def render(self, preview=True):
        renderFolder = hou.getenv('HIP') + '/render'
        if not os.path.exists(renderFolder):
            os.makedirs(renderFolder)

        prevFrame = hou.frame()
        prevDelay = self.pane.delay()
        prevUpdateTime = self.pane.updateTime()
        prevPreview = self.pane.isPreviewOn()

        self.pane.setDelay(0)
        self.pane.setUpdateTime(0.2)
        self.pane.setPreview(preview)

        start = self.frames[0]
        end = self.frames[1] + 1
        inc = self.frames[2]

        for frame in range(start, end, inc):
            hou.setFrame(frame)
            self.pane.resumeRender()
            time.sleep(self.renderTime)
            self.pane.pauseRender()
            self.saveFrame(frame)

        hou.setFrame(prevFrame)
        self.pane.setDelay(prevDelay)
        self.pane.setUpdateTime(prevUpdateTime)
        self.pane.setPreview(prevPreview)
コード例 #19
0
def bakeObjectToWorld(startFrame, endFrame):
    selectedNode = hou.selectedNodes()
    selectedNodeName = selectedNode[0].name()
    parent = selectedNode[0].parent()
    bakeNode = hou.copyNodesTo(selectedNode, parent)
    bakeNode[0].setName(selectedNodeName + "_bake")
    bakeNode[0].parm("keeppos").set(0)
    fetchNode = hou.node(parent.path()).createNode("fetch",
                                                   "fetch_" + selectedNodeName)
    hou.node(fetchNode.path()).parm("fetchobjpath").set(selectedNode[0].path())
    hou.node(fetchNode.path()).parm("useinputoffetched").set(1)
    nullNode = hou.node(parent.path()).createNode("null")
    nullNode.setFirstInput(fetchNode)
    nullNodeName = nullNode.name()

    parms = ["tx", "ty", "tz", "rx", "ry", "rz"]
    constant = ["TX", "TY", "TZ", "RX", "RY", "RZ"]

    bakeNode[0].setInput(0, None)

    #delete expresssion in parms and set to 0
    for p in parms:
        bakeNode[0].parm(p).deleteAllKeyframes()
        hou.hscript('objextractpretransform ' + bakeNode[0].path())
        bakeNode[0].parm(p).set(0)

    for p, c in zip(parms, constant):
        #bakeNode[0].parm(p).deleteAllKeyframes()
        hou.node(bakeNode[0].path()).parm(p).setExpression('origin("","../' +
                                                           nullNodeName +
                                                           '",' + c + ')')

    #add dict for hou.Keyframe and values
    key = dict([(x, hou.Keyframe()) for x in parms])
    values = dict([(x, []) for x in constant])

    #bake time range
    timeRange = xrange(startFrame, endFrame + 1)

    #fill values dict
    for t in timeRange:
        hou.setFrame(t)
        for v, p in zip(constant, parms):
            values[v].append(bakeNode[0].parm(p).eval())

    for p in parms:
        bakeNode[0].parm(p).deleteAllKeyframes()
        bakeNode[0].parm(p).set(0)

    #set key by keyframes

    for t in timeRange:
        hou.setFrame(t)
        for v, p, k in zip(constant, parms, key):
            key[k].setValue(values[v][t - startFrame])
            bakeNode[0].parm(p).setKeyframe(key[k])

    fetchNode.destroy()
    nullNode.destroy()
コード例 #20
0
	def testExpressions( self ) :
		
		obj = hou.node( "/obj" )
		geo = obj.createNode( "geo", run_init_scripts=False )
		node = geo.createNode( "attribcreate", exact_type_name=True )
		node.parm( "class" ).setExpression( "$F" )
		node.parm( "writevalues" ).setExpression( "$F" )
		node.parm( "size" ).setExpression( "$F+1" )
		node.parm( "default1" ).setExpression( "$FF*5" )
		node.parm( "string" ).setExpression( 'opfullpath( "." )' )
		nodePath = node.path()
		
		context = IECoreHoudini.TemporaryParameterValues(
			{
				nodePath + "/class" : 3,
				nodePath + "/writevalues" : False,
				nodePath + "/size" : 3,
				nodePath + "/default1" : 20.5,
				nodePath + "/string" : "bye",
			}
		)

		hou.setFrame( 1 )
		
		self.assertEqual( node.parm( "class" ).eval(), 1 )
		self.assertEqual( node.parm( "writevalues" ).eval(), True )
		self.assertEqual( node.parm( "size" ).eval(), 2 )
		self.assertEqual( node.parm( "default1" ).eval(), 5.0 )
		self.assertEqual( node.parm( "string" ).eval(), nodePath )
		
		with context :

			self.assertEqual( node.parm( "class" ).eval(), 3 )
			self.assertEqual( node.parm( "writevalues" ).eval(), False )
			self.assertEqual( node.parm( "size" ).eval(), 3 )
			self.assertEqual( node.parm( "default1" ).eval(), 20.5 )
			self.assertEqual( node.parm( "string" ).eval(), "bye" )
		
		self.assertEqual( node.parm( "class" ).eval(), 1 )
		self.assertEqual( node.parm( "writevalues" ).eval(), True )
		self.assertEqual( node.parm( "size" ).eval(), 2 )
		self.assertEqual( node.parm( "default1" ).eval(), 5.0 )
		self.assertEqual( node.parm( "string" ).eval(), nodePath )
		
		hou.setFrame( 0 )
		
		with context :

			self.assertEqual( node.parm( "class" ).eval(), 3 )
			self.assertEqual( node.parm( "writevalues" ).eval(), False )
			self.assertEqual( node.parm( "size" ).eval(), 3 )
			self.assertEqual( node.parm( "default1" ).eval(), 20.5 )
			self.assertEqual( node.parm( "string" ).eval(), "bye" )
		
		self.assertEqual( node.parm( "class" ).eval(), 0 )
		self.assertEqual( node.parm( "writevalues" ).eval(), False )
		self.assertEqual( node.parm( "size" ).eval(), 1 )
		self.assertEqual( node.parm( "default1" ).eval(), 0.0 )
		self.assertEqual( node.parm( "string" ).eval(), nodePath )
コード例 #21
0
def set_stock_timeLine(node):
    """ get frame in frame out from shotgun"""
    in_frame = float(node.parm('start_s_frame').evalAsString())
    out_frame = float(node.parm('end_s_frame').evalAsString())
    """ set the timeline """
    hou.hscript("tset `((%s-1)/$FPS)` `(%s/$FPS)`" % (in_frame, out_frame))
    hou.playbar.setPlaybackRange(in_frame, out_frame)
    hou.setFrame(in_frame)
コード例 #22
0
	def testLongP( self ) :
		hou.setFrame( 3 )
		cache = self.cacheSop()
		group = cache.inputs()[0]
		group.parm( "crname" ).set( "badObject" )
		cache.parm( "attributeFixes1" ).set( "long" )
		cache.cook( force=True )
		self.failUnless( "Geometry/Cache mismatch" in cache.warnings() )
コード例 #23
0
	def testWrongP( self ) :
		hou.setFrame( 3 )
		cache = self.cacheSop()
		group = cache.inputs()[0]
		group.parm( "crname" ).set( "badObject" )
		cache.parm( "attributeFixes1" ).set( "wrong" )
		result = IECoreHoudini.FromHoudiniPolygonsConverter( cache ).convert()
		self.assert_( "P" in result )
コード例 #24
0
def init_setup_the_scene(fps, in_frame, out_frame):
    """ set the scene in Manual """
    hou.setUpdateMode(hou.updateMode.Manual)
    """ set the timeline """
    hou.setFps(fps)
    hou.hscript("tset `((%s-1)/$FPS)` `(%s/$FPS)`" % (in_frame, out_frame))
    hou.playbar.setPlaybackRange(in_frame, out_frame)
    hou.setFrame(in_frame)
コード例 #25
0
 def testNoFileForFrame(self):
     cache = self.cacheSop()
     cache.parm("cacheSequence").set(
         "test/IECoreHoudini/data/torusVertCache.####.fio")
     hou.setFrame(5)
     cache.cook(force=True)
     self.failUnless(cache.warnings())
     self.assertEqual(len(cache.geometry().points()), 0)
コード例 #26
0
 def testLongP(self):
     hou.setFrame(3)
     cache = self.cacheSop()
     group = cache.inputs()[0]
     group.parm("crname").set("badObject")
     cache.parm("attributeFixes1").set("long")
     cache.cook(force=True)
     self.failUnless("Geometry/Cache mismatch" in cache.warnings())
コード例 #27
0
 def testWrongP(self):
     hou.setFrame(3)
     cache = self.cacheSop()
     group = cache.inputs()[0]
     group.parm("crname").set("badObject")
     cache.parm("attributeFixes1").set("wrong")
     result = IECoreHoudini.FromHoudiniPolygonsConverter(cache).convert()
     self.assert_("P" in result)
コード例 #28
0
 def points(self):
     points = self.geo().createNode("popnet")
     points.createNode("location")
     color = points.createOutputNode("color")
     color.parm("colortype").set(2)
     name = color.createOutputNode("name")
     name.parm("name1").set("pointsGroup")
     hou.setFrame(50)
     return name
コード例 #29
0
	def testTimeDependency( self ) :
		cache = self.cacheSop()
		orig = IECoreHoudini.FromHoudiniPolygonsConverter( cache ).convert()
		hou.setFrame( 1.5 )
		result = IECoreHoudini.FromHoudiniPolygonsConverter( cache ).convert()
		self.assertNotEqual( orig, result )
		self.assertNotEqual( orig['P'], result['P'] )
		self.assertNotEqual( orig['Cs'], result['Cs'] )
		self.assertEqual( orig['pointId'], result['pointId'] )
コード例 #30
0
	def points( self ) :
		points = self.geo().createNode( "popnet" )
		points.createNode( "location" )
		color = points.createOutputNode( "color" )
		color.parm( "colortype" ).set( 2 )
		name = color.createOutputNode( "name" )
		name.parm( "name1" ).set( "pointsGroup" )
		hou.setFrame( 50 )
		return name
コード例 #31
0
 def testTimeDependency(self):
     cache = self.cacheSop()
     orig = IECoreHoudini.FromHoudiniPolygonsConverter(cache).convert()
     hou.setFrame(1.5)
     result = IECoreHoudini.FromHoudiniPolygonsConverter(cache).convert()
     self.assertNotEqual(orig, result)
     self.assertNotEqual(orig['P'], result['P'])
     self.assertNotEqual(orig['Cs'], result['Cs'])
     self.assertEqual(orig['pointId'], result['pointId'])
コード例 #32
0
    def testParticlePrimitive(self):
        obj = hou.node("/obj")
        geo = obj.createNode("geo", run_init_scripts=False)
        popnet = geo.createNode("popnet")
        location = popnet.createNode("location")
        detailAttr = popnet.createOutputNode("attribcreate",
                                             exact_type_name=True)
        detailAttr.parm("name").set("float3detail")
        detailAttr.parm("class").set(0)  # detail
        detailAttr.parm("type").set(0)  # float
        detailAttr.parm("size").set(3)  # 3 elements
        detailAttr.parm("value1").set(1)
        detailAttr.parm("value2").set(2)
        detailAttr.parm("value3").set(3)
        pointAttr = detailAttr.createOutputNode("attribcreate",
                                                exact_type_name=True)
        pointAttr.parm("name").set("float3point")
        pointAttr.parm("class").set(2)  # point
        pointAttr.parm("type").set(0)  # float
        pointAttr.parm("size").set(3)  # 3 elements
        pointAttr.parm("value1").set(1)
        pointAttr.parm("value2").set(2)
        pointAttr.parm("value3").set(3)

        hou.setFrame(5)
        converter = IECoreHoudini.FromHoudiniPointsConverter(pointAttr)
        points = converter.convert()

        self.assertEqual(type(points), IECore.PointsPrimitive)
        self.assertEqual(
            points.variableSize(IECore.PrimitiveVariable.Interpolation.Vertex),
            21)
        self.assertEqual(points["float3detail"].interpolation,
                         IECore.PrimitiveVariable.Interpolation.Constant)
        self.assertEqual(type(points["float3detail"].data), IECore.V3fData)
        self.assert_(points["float3detail"].data.value.equalWithRelError(
            IECore.V3f(1, 2, 3), 1e-10))
        self.assertEqual(type(points["float3point"].data),
                         IECore.V3fVectorData)
        self.assertEqual(points["float3point"].interpolation,
                         IECore.PrimitiveVariable.Interpolation.Vertex)
        for p in points["float3point"].data:
            self.assert_(p.equalWithRelError(IECore.V3f(1, 2, 3), 1e-10))

        self.assert_(points.arePrimitiveVariablesValid())

        add = pointAttr.createOutputNode("add")
        add.parm("keep").set(1)  # deletes primitive and leaves points

        converter = IECoreHoudini.FromHoudiniPointsConverter(add)
        points2 = converter.convert()
        del points['generator']
        del points['generatorIndices']
        del points['born']
        del points['source']
        self.assertEqual(points2, points)
コード例 #33
0
    def test_bake_values_sets_right_values(self):
        parm = self.geo.parm('rx')
        values = [1.0, 3.0, 5.0, 3.0, 7.0, 5.0, 9.0, 1.0]

        for k, frame in enumerate(values):
            bakeparm.bake_values(1, len(values) + 1, parm, values)

        for i in range(len(values) + 1):
            hou.setFrame(i)
            self.assertAlmostEqual(values[i - 1], parm.eval())
コード例 #34
0
    def _set_frame_range(self, frame_range_start, frame_range_end):
        """Set the Houdini frame range and playback range to the input data."""

        # set the frame range to frameRangeStart - frameRangeEnd
        hou.playbar.setFrameRange(frame_range_start, frame_range_end)

        # set the playback range to frameRangeStart - frameRangeEnd
        hou.playbar.setPlaybackRange(frame_range_start, frame_range_end)

        # set the timeline to the first frame
        hou.setFrame(frame_range_start)
コード例 #35
0
 def startElement(self, _name, _attrs):
     # this is important the characters method may be called many times so we
     # clear the char data each start element then append each time we read it
     self.m_charData = ""
     # if we have a vertex start tag process and extract the offset
     if _name == "Vertex":
         self.m_offset = int(_attrs.get("number"))
     # if we have the Frame we grab the number attribute
     elif _name == "Frame":
         hou.setFrame(int(_attrs.get("number")))
         self.m_currentFrame = int(_attrs.get("number"))
コード例 #36
0
 def testAnimatingGeometry(self):
     curves = self.createCurves(4)
     mountain = curves.createOutputNode("mountain")
     mountain.parm("offset1").setExpression("$FF")
     converter = IECoreHoudini.FromHoudiniCurvesConverter(mountain)
     hou.setFrame(1)
     result1 = converter.convert()
     hou.setFrame(2)
     converter = IECoreHoudini.FromHoudiniCurvesConverter(mountain)
     result2 = converter.convert()
     self.assertNotEqual(result1["P"].data, result2["P"].data)
     self.assertNotEqual(result1, result2)
コード例 #37
0
	def testAnimatingGeometry( self ) :
		curves = self.createCurves( 4 )
		mountain = curves.createOutputNode( "mountain" )
		mountain.parm("offset1").setExpression( "$FF" )
		converter = IECoreHoudini.FromHoudiniCurvesConverter( mountain )
		hou.setFrame( 1 )
		result1 = converter.convert()
		hou.setFrame( 2 )
		converter = IECoreHoudini.FromHoudiniCurvesConverter( mountain )
		result2 = converter.convert()
		self.assertNotEqual( result1["P"].data, result2["P"].data )
		self.assertNotEqual( result1, result2 )
コード例 #38
0
ファイル: ProceduralHolder.py プロジェクト: boberfly/cortex
	def testProceduralReloadParameters(self):
		sphere = IECoreHoudini.FnProceduralHolder.create( "cortex_sphere", "sphereProcedural", 1 )

		# check the reload button doesn't clear expressions
		sphere.parm("parm_radius").setExpression("sin($FF)")
		hou.setFrame(0)
		rad = sphere.evalParm("parm_radius")
		self.assert_( rad > 0 )
		hou.setFrame(100)
		rad = sphere.evalParm("parm_radius")
		self.assert_( rad > 0.984 )
		self.assert_( rad < 0.985 )
		sphere.parm( "__classReloadButton" ).pressButton()
		rad = sphere.evalParm("parm_radius")
		self.assert_( rad > 0.984 )
		self.assert_( rad < 0.985 )
		self.assertEqual( sphere.parm("parm_radius").expression(), "sin($FF)" )
		hou.setFrame(0)
		rad = sphere.evalParm("parm_radius")
		self.assert_( rad > 0 )

		# now change the version to v2 and check things are still ok
		sphere.parm( "__classVersion" ).set( "2" )
		# if we're changing the menu programatically then we need to call pressButton()!!
		sphere.parm( "__classVersion" ).pressButton()
		self.assert_( not sphere.evalParm("parm_extra") )
		sphere.parm("parm_extra").set(True)
		self.failUnless( sphere.evalParm("parm_extra") )
		rad = sphere.evalParm("parm_radius")
		self.assert_( rad < 0.015 )
		hou.setFrame(100)
		rad = sphere.evalParm("parm_radius")
		self.assert_( rad > 0.984 )
		self.assert_( rad < 0.985 )
コード例 #39
0
ファイル: ProceduralHolder.py プロジェクト: ruba/cortex-vfx
    def testProceduralReloadParameters(self):
        sphere = IECoreHoudini.FnProceduralHolder.create(
            "cortex_sphere", "sphereProcedural", 1)

        # check the reload button doesn't clear expressions
        sphere.parm("parm_radius").setExpression("sin($FF)")
        hou.setFrame(0)
        rad = sphere.evalParm("parm_radius")
        self.assert_(rad > 0)
        hou.setFrame(100)
        rad = sphere.evalParm("parm_radius")
        self.assert_(rad > 0.984)
        self.assert_(rad < 0.985)
        sphere.parm("__classReloadButton").pressButton()
        rad = sphere.evalParm("parm_radius")
        self.assert_(rad > 0.984)
        self.assert_(rad < 0.985)
        self.assertEqual(sphere.parm("parm_radius").expression(), "sin($FF)")
        hou.setFrame(0)
        rad = sphere.evalParm("parm_radius")
        self.assert_(rad > 0)

        # now change the version to v2 and check things are still ok
        sphere.parm("__classVersion").set("2")
        # if we're changing the menu programatically then we need to call pressButton()!!
        sphere.parm("__classVersion").pressButton()
        self.assert_(not sphere.evalParm("parm_extra"))
        sphere.parm("parm_extra").set(True)
        self.failUnless(sphere.evalParm("parm_extra"))
        rad = sphere.evalParm("parm_radius")
        self.assert_(rad < 0.015)
        hou.setFrame(100)
        rad = sphere.evalParm("parm_radius")
        self.assert_(rad > 0.984)
        self.assert_(rad < 0.985)
コード例 #40
0
    def testPrimitiveGroupModeWithVertexAttribs(self):

        # N defaults to a Point attrib
        hou.setFrame(4)
        cache = self.cacheSop()
        self.failUnless(
            isinstance(cache.geometry().findPointAttrib("N"), hou.Attrib))
        self.failUnless(cache.geometry().findVertexAttrib("N") is None)
        result = IECoreHoudini.FromHoudiniPolygonsConverter(cache).convert()
        self.failUnless("N" in result.keys())
        self.assertEqual(result["N"].interpolation,
                         IECore.PrimitiveVariable.Interpolation.Vertex)
        self.assertEqual(
            len(result["N"].data),
            result.variableSize(IECore.PrimitiveVariable.Interpolation.Vertex))

        # Since N actually has more values than points should, N becomes a Vertex attrib if we use PrimitiveGroup mode
        group = hou.node("/obj/geo1/group1")
        group.parm("entity").set(0)
        cache.parm("groupingMode").set(0)
        self.failUnless(cache.geometry().findPointAttrib("N") is None)
        self.failUnless(
            isinstance(cache.geometry().findVertexAttrib("N"), hou.Attrib))
        result = IECoreHoudini.FromHoudiniPolygonsConverter(cache).convert()
        self.failUnless("N" in result.keys())
        self.assertEqual(result["N"].interpolation,
                         IECore.PrimitiveVariable.Interpolation.FaceVarying)
        self.assertEqual(
            len(result["N"].data),
            result.variableSize(
                IECore.PrimitiveVariable.Interpolation.FaceVarying))

        # Even if we create N as a Point attrib before the cache, it remains a Vertex attrib since the sizes do not match
        facet = group.createOutputNode("facet")
        facet.parm("postnml").set(True)
        cache.setInput(0, facet)
        self.failUnless(
            isinstance(facet.geometry().findPointAttrib("N"), hou.Attrib))
        self.failUnless(facet.geometry().findVertexAttrib("N") is None)
        self.failUnless(cache.geometry().findPointAttrib("N") is None)
        self.failUnless(
            isinstance(cache.geometry().findVertexAttrib("N"), hou.Attrib))
        result = IECoreHoudini.FromHoudiniPolygonsConverter(cache).convert()
        self.failUnless("N" in result.keys())
        self.assertEqual(result["N"].interpolation,
                         IECore.PrimitiveVariable.Interpolation.FaceVarying)
        self.assertEqual(
            len(result["N"].data),
            result.variableSize(
                IECore.PrimitiveVariable.Interpolation.FaceVarying))
コード例 #41
0
	def testParticlePrimitive( self ) :
		obj = hou.node("/obj")
		geo = obj.createNode( "geo", run_init_scripts=False )
		popnet = geo.createNode( "popnet" )
		location = popnet.createNode( "location" )
		detailAttr = popnet.createOutputNode( "attribcreate", exact_type_name=True )
		detailAttr.parm("name").set( "float3detail" )
		detailAttr.parm("class").set( 0 ) # detail
		detailAttr.parm("type").set( 0 ) # float
		detailAttr.parm("size").set( 3 ) # 3 elements
		detailAttr.parm("value1").set( 1 )
		detailAttr.parm("value2").set( 2 )
		detailAttr.parm("value3").set( 3 )
		pointAttr = detailAttr.createOutputNode( "attribcreate", exact_type_name=True )
		pointAttr.parm("name").set( "float3point" )
		pointAttr.parm("class").set( 2 ) # point
		pointAttr.parm("type").set( 0 ) # float
		pointAttr.parm("size").set( 3 ) # 3 elements
		pointAttr.parm("value1").set( 1 )
		pointAttr.parm("value2").set( 2 )
		pointAttr.parm("value3").set( 3 )
		
		hou.setFrame( 5 )
		converter = IECoreHoudini.FromHoudiniGeometryConverter.create( pointAttr )
		self.assert_( converter.isInstanceOf( IECore.TypeId( IECoreHoudini.TypeId.FromHoudiniPointsConverter ) ) )
		points = converter.convert()
		
		self.assertEqual( type(points), IECore.PointsPrimitive )
		self.assertEqual( points.variableSize( IECore.PrimitiveVariable.Interpolation.Vertex ), 21 )
		self.assertEqual( points["float3detail"].interpolation, IECore.PrimitiveVariable.Interpolation.Constant )
		self.assertEqual( type(points["float3detail"].data), IECore.V3fData )
		self.assert_( points["float3detail"].data.value.equalWithRelError( IECore.V3f( 1, 2, 3 ), 1e-10 ) )
		self.assertEqual( type(points["float3point"].data), IECore.V3fVectorData )
		self.assertEqual( points["float3point"].interpolation, IECore.PrimitiveVariable.Interpolation.Vertex )
		for p in points["float3point"].data :
			self.assert_( p.equalWithRelError( IECore.V3f( 1, 2, 3 ), 1e-10 ) )
		
		self.assert_( points.arePrimitiveVariablesValid() )
		
		add = pointAttr.createOutputNode( "add" )
		add.parm( "keep" ).set( 1 ) # deletes primitive and leaves points
		
		converter = IECoreHoudini.FromHoudiniPointsConverter( add )
		points2 = converter.convert()
		del points['generator']
		del points['generatorIndices']
		del points['born']
		del points['source']
		self.assertEqual( points2, points )
コード例 #42
0
	def testNonConvertableAttr( self ) :
		hou.setFrame( 3 )
		cache = self.cacheSop()
		torus = cache.parent().createNode( "file" )
		torus.parm( "file" ).set( TestInterpolatedCacheReader.__torusTestFile )
		group = torus.createOutputNode( "group" )
		group.parm( "crname" ).set( "badObject" )
		group.parm( "entity" ).set( 1 )
		merge = cache.inputs()[0].createOutputNode( "merge" )
		merge.setInput( 1, group )
		cache.setInput( 0, merge )
		i = IECore.InterpolatedCache( cache.parm( "cacheSequence" ).eval(), IECore.InterpolatedCache.Interpolation.Linear, IECore.OversamplesCalculator( 24, 1 ) )
		self.assert_( "splineColor4fData" in i.attributes( 3, 'badObject' ) )
		result = IECoreHoudini.FromHoudiniPolygonsConverter( cache ).convert()
		self.assert_( "splineColor4fData" not in result )
コード例 #43
0
ファイル: ProceduralHolder.py プロジェクト: victorvfx/cortex
	def testAnimatedValues( self ) :
		
		sphere = IECoreHoudini.FnProceduralHolder.create( "test", "sphereProcedural", 1 )
		fn = IECoreHoudini.FnProceduralHolder( sphere )
		sphere.parm( "parm_radius" ).setExpression( "$FF" )
		hou.setFrame( 1 )
		self.assertEqual( sphere.evalParm( "parm_radius" ), 1 )
		self.assertEqual( fn.getProcedural().parameters()["radius"].getTypedValue(), 1 )
		hou.setFrame( 12.25 )
		self.assertEqual( sphere.evalParm( "parm_radius" ), 12.25  )
		# values haven't been flushed yet
		self.assertAlmostEqual( fn.getProcedural().parameters()["radius"].getTypedValue(), 1 )
		# so we flush them
		fn.setParameterisedValues()
		self.assertAlmostEqual( fn.getProcedural().parameters()["radius"].getTypedValue(), 12.25 )
コード例 #44
0
ファイル: OpHolder.py プロジェクト: ruba/cortex-vfx
	def testAnimatedValues( self ) :
		
		noise = IECoreHoudini.FnOpHolder.create( "test", "noiseDeformer", 1 )
		fn = IECoreHoudini.FnOpHolder( noise )
		noise.parm( "parm_magnitude" ).setExpression( "$FF" )
		hou.setFrame( 1 )
		self.assertEqual( noise.evalParm( "parm_magnitude" ), 1 )
		self.assertEqual( fn.getOp().parameters()["magnitude"].getTypedValue(), 1 )
		hou.setFrame( 12.25 )
		self.assertEqual( noise.evalParm( "parm_magnitude" ), 12.25  )
		# values haven't been flushed yet
		self.assertAlmostEqual( fn.getOp().parameters()["magnitude"].getTypedValue(), 1 )
		# so we flush them
		fn.setParameterisedValues()
		self.assertAlmostEqual( fn.getOp().parameters()["magnitude"].getTypedValue(), 12.25 )
コード例 #45
0
def run():
    hou.hipFile.addEventCallback(scene_event_callback)
    hou.hipFile.clear(suppress_save_prompt=False)
    with hou.undos.group("Demo"):
        hou.setUpdateMode(hou.updateMode.Manual)
        demobox.DemoBox()
        create_cam()
        hou.setUpdateMode(hou.updateMode.AutoUpdate)
        hou.playbar.setRealTime(True)
        hou.setFrame(25)
        create_mantra()
        create_cop()
        hou.node('/obj').layoutChildren()
    hou.hipFile.removeEventCallback(scene_event_callback)
    hou.hipFile.save(hou.hscriptExpandString('$TEMP') + '/demo.hip')
コード例 #46
0
ファイル: OpHolder.py プロジェクト: Shockspot/cortex
	def testAnimatedValues( self ) :
		
		noise = IECoreHoudini.FnOpHolder.create( "test", "noiseDeformer", 1 )
		fn = IECoreHoudini.FnOpHolder( noise )
		noise.parm( "parm_magnitude" ).setExpression( "$FF" )
		hou.setFrame( 1 )
		self.assertEqual( noise.evalParm( "parm_magnitude" ), 1 )
		self.assertEqual( fn.getOp().parameters()["magnitude"].getTypedValue(), 1 )
		hou.setFrame( 12.25 )
		self.assertEqual( noise.evalParm( "parm_magnitude" ), 12.25  )
		# values haven't been flushed yet
		self.assertAlmostEqual( fn.getOp().parameters()["magnitude"].getTypedValue(), 1 )
		# so we flush them
		fn.setParameterisedValues()
		self.assertAlmostEqual( fn.getOp().parameters()["magnitude"].getTypedValue(), 12.25 )
コード例 #47
0
def cacheWrite(startFrame, endFrame, subFrame, format, mode):
    #expected format abc(Alembic), bgeo(Houdini bgeo)
    #expected mode add,

    selectedNodes = hou.selectedNodes()
    parent = selectedNodes[0].parent()
    ropnet = hou.node(parent.path()).createNode("ropnet")

    hou.setFrame(startFrame)

    message = ''

    for n in selectedNodes:

        if mode == 'version': cachePath = makeCachePath(n, 'add')
        if mode == 'overwrite': cachePath = makeCachePath(n, 'get')[-1]

        if format == 'abc':
            cacheProperty = ['abc', 'alembic', 'filename', '.abc', 'objects']
        if format == 'bgeo':
            cacheProperty = [
                '$F4.bgeo', 'geometry', 'sopoutput', '.$F4.bgeo', 'soppath'
            ]

        message += 'NODE' + ' - ' + n.path(
        ) + ' > ' + 'CACHE - $DATA/geo/' + cachePath.split(
            'geo/')[1] + '/' + n.name() + '.' + cacheProperty[0] + '\n'

        ropNode = hou.node(ropnet.path()).createNode(cacheProperty[1])

        ropNode.setName(n.name() + "_ropNode")

        hou.node(ropNode.path()).parm("trange").set(1)
        hou.node(ropNode.path()).parm("f1").set(startFrame)
        hou.node(ropNode.path()).parm("f2").set(endFrame)
        hou.node(ropNode.path()).parm("f3").set(1.0 / subFrame)

        hou.node(ropNode.path()).parm(cacheProperty[2]).set(
            os.path.join(cachePath,
                         n.name() + cacheProperty[3]))

        hou.node(ropNode.path()).parm(cacheProperty[4]).set(n.path())

        submitButton = ropNode.parm("execute")
        hou.Parm.pressButton(submitButton)

    hou.ui.displayMessage(message)
    ropnet.destroy()
コード例 #48
0
	def testEmptyGroup( self ) :
		hou.setFrame( 3 )
		cache = self.cacheSop()
		groupA = cache.inputs()[0]
		null = cache.parent().createNode( "null" )
		groupB = null.createOutputNode( "group" )
		groupB.parm( "crname" ).set( "torus2" )
		groupB.parm( "entity" ).set( 1 )
		merge = groupA.createOutputNode( "merge" )
		merge.setInput( 1, groupB )
		cache.setInput( 0, merge )
		result = IECoreHoudini.FromHoudiniPolygonsConverter( cache ).convert()
		numTorusPoints = len(groupA.geometry().points())
		for key in [ "P", "Cs" ] :
			self.assert_( key in result )
			self.assertEqual( result[key].data.size(), numTorusPoints )
コード例 #49
0
ファイル: cache_utils.py プロジェクト: horitin/pipeline
def cacheWrite(startFrame, endFrame, subFrame, format, mode):
#expected format abc(Alembic), bgeo(Houdini bgeo)
#expected mode add,


    selectedNodes = hou.selectedNodes()
    parent = selectedNodes[0].parent()
    ropnet = hou.node(parent.path()).createNode("ropnet")

    hou.setFrame(startFrame)

    message = ''

    for n in selectedNodes:

        if mode == 'version': cachePath = makeCachePath(n, 'add')
        if mode == 'overwrite': cachePath = makeCachePath(n, 'get')[-1]
           
        if format == 'abc': cacheProperty = ['abc', 'alembic', 'filename', '.abc', 'objects']
        if format == 'bgeo': cacheProperty = ['$F4.bgeo', 'geometry', 'sopoutput', '.$F4.bgeo', 'soppath']


        message += 'NODE' + ' - ' + n.path() + ' > ' + 'CACHE - $DATA/geo/' + cachePath.split('geo/')[1] + '/' + n.name() + '.' + cacheProperty[0] + '\n'
        
        
        ropNode = hou.node(ropnet.path()).createNode(cacheProperty[1])

        ropNode.setName(n.name()+"_ropNode")
    
        hou.node(ropNode.path()).parm("trange").set(1)
        hou.node(ropNode.path()).parm("f1").set(startFrame)
        hou.node(ropNode.path()).parm("f2").set(endFrame)
        hou.node(ropNode.path()).parm("f3").set(1.0/subFrame)
        
        
        hou.node(ropNode.path()).parm(cacheProperty[2]).set(os.path.join(cachePath, n.name() + cacheProperty[3]))
        
        
        hou.node(ropNode.path()).parm(cacheProperty[4]).set(n.path())

        submitButton = ropNode.parm("execute")
        hou.Parm.pressButton(submitButton)

    hou.ui.displayMessage(message)
    ropnet.destroy()
コード例 #50
0
	def testAnimatingGeometry( self ) :
		obj = hou.node( "/obj" )
		geo = obj.createNode( "geo", run_init_scripts=False )
		torus = geo.createNode( "torus" )
		facet = geo.createNode( "facet" )
		facet.parm("postnml").set(True)
		mountain = geo.createNode( "mountain" )
		mountain.parm("offset1").setExpression( "$FF" )
		facet.setInput( 0, torus )
		mountain.setInput( 0, facet )
		converter = IECoreHoudini.FromHoudiniPolygonsConverter( mountain )
		hou.setFrame( 1 )
		mesh1 = converter.convert()
		hou.setFrame( 2 )
		converter = IECoreHoudini.FromHoudiniPolygonsConverter( mountain )
		mesh2 = converter.convert()
		self.assertNotEqual( mesh1["P"].data, mesh2["P"].data )
		self.assertNotEqual( mesh1, mesh2 )
コード例 #51
0
	def testTransformAttribute( self ) :
		cache = self.cacheSop()
		hou.setFrame( 2 )
		orig = IECoreHoudini.FromHoudiniPolygonsConverter( cache ).convert()
		cache.parm( "transformAttribute" ).set( "transform" )
		result = IECoreHoudini.FromHoudiniPolygonsConverter( cache ).convert()
		self.assertNotEqual( orig, result )
		self.assertNotEqual( orig['P'], result['P'] )
		self.assertEqual( orig['P'].data.size(), result['P'].data.size() )
		self.assertEqual( orig['Cs'], result['Cs'] )
		self.assertEqual( orig['pointId'], result['pointId'] )
		
		i = IECore.InterpolatedCache( cache.parm( "cacheSequence" ).eval(), IECore.InterpolatedCache.Interpolation.Linear, IECore.OversamplesCalculator( 24, 1 ) )
		matrix = i.read( 2, "torus", "transform" ).value.transform
		origP = orig["P"].data
		resultP = result["P"].data
		for i in range( 0, origP.size() ) :
			self.assertNotEqual( resultP[i], origP[i] )
			self.assertEqual( resultP[i], matrix.multVecMatrix( origP[i] ) )
コード例 #52
0
	def testMultipleObjects( self ) :
		hou.setFrame( 3 )
		cache = self.cacheSop()
		torus = cache.parent().createNode( "file" )
		torus.parm( "file" ).set( TestInterpolatedCacheReader.__torusTestFile )
		group = torus.createOutputNode( "group" )
		group.parm( "crname" ).set( "torus2" )
		group.parm( "entity" ).set( 1 )
		merge = cache.inputs()[0].createOutputNode( "merge" )
		merge.setInput( 1, group )
		cache.setInput( 0, merge )
		result = IECoreHoudini.FromHoudiniPolygonsConverter( cache ).convert()
		numTorusPoints = len(torus.geometry().points()) 
		for key in [ "P", "Cs" ] :
			self.assert_( key in result )
			self.assertEqual( result[key].data.size(), 2 * numTorusPoints )
		
		for i in range( 0, numTorusPoints ) :
			self.assertNotEqual( result['P'].data[i], result['P'].data[numTorusPoints+i] )
			self.assertEqual( result['Cs'].data[i], result['Cs'].data[numTorusPoints+i] )
コード例 #53
0
ファイル: CortexWriter.py プロジェクト: AtomicFiction/cortex
	def testRenderWriterCOB(self):
		cache_file = "test/cortexWriter_testData/test.$F4.cob"
		writer = self.testCreateWriter()
		# set to cob
		writer.parm("export_format").set(1)
		# set path
		writer.parm("export_path").set(cache_file)
		# render
		self.render(writer, (1,100) )
		# check files
		files = glob.glob( "test/cortexWriter_testData/test.????.cob" )
		self.assertEqual( len(files), 100 )
		# load cob
		geo_1 = IECore.Reader.create( "test/cortexWriter_testData/test.0001.cob" ).read()
		geo_2 = IECore.Reader.create( "test/cortexWriter_testData/test.0051.cob" ).read()
		geo_3 = IECore.Reader.create( "test/cortexWriter_testData/test.0100.cob" ).read()
		# compare with a converter
		hou.setFrame(1)
		converter = IECoreHoudini.FromHoudiniGeometryConverter.create( writer.inputs()[0] )
		self.assertEqual( geo_1, converter.convert() )
		self.assertNotEqual( geo_2, converter.convert() )
		hou.setFrame(51)
		converter = IECoreHoudini.FromHoudiniGeometryConverter.create( writer.inputs()[0] )
		self.assertEqual( geo_2, converter.convert() )
		hou.setFrame(100)
		converter = IECoreHoudini.FromHoudiniGeometryConverter.create( writer.inputs()[0] )
		self.assertEqual( geo_3, converter.convert() )
コード例 #54
0
	def keyParentTransformAnim_main(self, **connections):

		try:
			nodeToKey=str(connections["nodeToKey"])
		except:
			nodeToKey=""
		try:
			TMatrixNode=str(connections["TMatrixNode"])
		except:
			TMatrixNode=""	
		try:
			ntc=hou.node(nodeToKey)
			tn=hou.node(TMatrixNode)
			for val in ntc.parm("tx").keyframes():
				hou.setFrame(val.frame())
				ntc.parm("tx").set(val.value()*tn.parm("sx").eval()+tn.parm("tx").eval())
			for val in ntc.parm("ty").keyframes():
				hou.setFrame(val.frame())
				ntc.parm("ty").set(val.value()*tn.parm("sy").eval()+tn.parm("ty").eval())
			for val in ntc.parm("tz").keyframes():
				hou.setFrame(val.frame())
				ntc.parm("tz").set(val.value()*tn.parm("sz").eval()+tn.parm("tz").eval())
			return 1

		except:
			return 0
コード例 #55
0
	def testAnimatingGeometry( self ) :
		obj = hou.node("/obj")
		geo = obj.createNode("geo", run_init_scripts=False)
		torus = geo.createNode( "torus" )
		facet = geo.createNode( "facet" )
		facet.parm("postnml").set(True)
		mountain = geo.createNode( "mountain" )
		if hou.applicationVersion()[0] >= 16:
			mountain.parm( "offsetx" ).setExpression( "$FF" )
		else:
			mountain.parm("offset1").setExpression( "$FF" )
		points = geo.createNode( "scatter" )
		facet.setInput( 0, torus )
		mountain.setInput( 0, facet )
		points.setInput( 0, mountain )
		converter = IECoreHoudini.FromHoudiniPointsConverter( points )
		hou.setFrame(1)
		points_1 = converter.convert()
		hou.setFrame(2)
		converter = IECoreHoudini.FromHoudiniPointsConverter( points )
		points_2 = converter.convert()
		self.assertNotEqual( points_1["P"].data, points_2["P"].data )
コード例 #56
0
	def testAttributeMismatchBetweenFrames( self ) :
		cache = self.cacheSop()
		hou.setFrame( 1.5 )
		self.failUnless( isinstance( cache.geometry(), hou.Geometry ) )
		orig = IECoreHoudini.FromHoudiniPolygonsConverter( cache ).convert()
		hou.setFrame( 2.5 )
		self.assertEqual( cache.geometry(), None )
		self.failUnless( "Entry not found" in cache.errors() )
		hou.setFrame( 3 )
		result = IECoreHoudini.FromHoudiniPolygonsConverter( cache ).convert()
		self.failUnless( isinstance( cache.geometry(), hou.Geometry ) )
		self.assertNotEqual( orig, result )
コード例 #57
0
ファイル: utils.py プロジェクト: horitin/pipeline
def bakeObjectToWorld(startFrame, endFrame):
    selectedNode=hou.selectedNodes()
    selectedNodeName=selectedNode[0].name()
    parent=selectedNode[0].parent()
    bakeNode=hou.copyNodesTo(selectedNode,parent)
    bakeNode[0].setName(selectedNodeName + "_bake")
    bakeNode[0].parm("keeppos").set(0)
    fetchNode=hou.node(parent.path()).createNode("fetch","fetch_"+selectedNodeName)
    hou.node(fetchNode.path()).parm("fetchobjpath").set(selectedNode[0].path())
    hou.node(fetchNode.path()).parm("useinputoffetched").set(1)
    nullNode=hou.node(parent.path()).createNode("null")
    nullNode.setFirstInput(fetchNode)
    nullNodeName=nullNode.name()
    
    
    parms=["tx","ty","tz","rx","ry","rz"]
    constant=["TX","TY","TZ","RX","RY","RZ"]
    
    
    bakeNode[0].setInput(0,None)
    
    #delete expresssion in parms and set to 0
    for p in parms:
      bakeNode[0].parm(p).deleteAllKeyframes()
      hou.hscript('objextractpretransform '+ bakeNode[0].path())
      bakeNode[0].parm(p).set(0)
    
    
    
    for p, c in zip(parms, constant):
        #bakeNode[0].parm(p).deleteAllKeyframes()
        hou.node(bakeNode[0].path()).parm(p).setExpression('origin("","../'+nullNodeName+'",'+c+')')
    
    
    
    #add dict for hou.Keyframe and values    
    key = dict([(x, hou.Keyframe()) for x in parms])
    values = dict([(x, []) for x in constant])
          
    #bake time range
    timeRange = xrange(startFrame,endFrame+1)
    
    
    #fill values dict
    for t in timeRange:
        hou.setFrame(t)
        for v, p in zip(constant,parms):
	    values[v].append(bakeNode[0].parm(p).eval())
	    
    
    for p in parms:
      bakeNode[0].parm(p).deleteAllKeyframes()
      bakeNode[0].parm(p).set(0)
    
    #set key by keyframes
    
    for t in timeRange:
	hou.setFrame(t)
	for v, p, k in zip(constant,parms,key):
	  key[k].setValue(values[v][t-startFrame])
	  bakeNode[0].parm(p).setKeyframe(key[k])
    
    fetchNode.destroy()
    nullNode.destroy()
コード例 #58
0
	def createTurntable_main(self, **connections):
		try:
			dbPath=connections["dbPath"]
		except:
			dbPath=""
		try:
			Type=connections["Type"]
		except:
			Type=""
		try:
			Name=str(connections["Name"])
		except:
			Name=""
		try:
			Version=str(connections["Version"])
		except:
			Version=""
		try:
			oas_output=connections["oas_output"]
		except:
			oas_output="hipFile"		

		if str(geT(dbPath))=="" or str(geT(dbPath))=="0":
			return 0

		vers=getVerFrompath(str(dbPath)+":Model@"+str(Version))
		vPath=gVP(str(dbPath)+":Model@"+str(vers))


		if Type=="Model":
			sure="01_Model"
		elif Type=="Material":
			sure="02_Material"
		else:
			sure="03_Misc"


		projj=ref(str(dbPath).split(":")[1])
		renderdir="/W/Projects/"+projj+"/60_PreRenders/Turntable/"+sure+"/"+str(Name)+"/"+str(vers)
		seqdir=renderdir+"/seq"
		movdir=renderdir+"/mov"

		if os.path.isdir(seqdir):
			pass
		else:
			os.makedirs(seqdir)
		if os.path.isdir(movdir):
			pass
		else:
			os.makedirs(movdir)

		if str(vPath)=="0" or vPath=="":
			return 0

		if os.path.isdir(vPath+'/hipFile'):
			pass
		else:
			os.makedirs(vPath+'/hipFile')
		if os.path.isdir(vPath+'/render'):
			pass
		else:
			os.makedirs(vPath+'/render')
		if os.path.isdir(vPath+'/mov'):
			pass
		else:
			os.makedirs(vPath+'/mov')

		hou.hipFile.clear()

		ret1=LHD(Name,"Model",Version,dbPath,"Turntable_Model")
		par=hou.node("/obj/Turntable_Model").parm("ry")
		hou.setFrame(1)
		par.setKeyframe(hou.Keyframe(0))
		hou.setFrame(101)
		par.setKeyframe(hou.Keyframe(720))
		hou.setFrame(1)

		coll=""
		for item in hou.node("/obj/Turntable_Model").children():
			coll+=str(item.path())+" "

		mat_pars=hou.node("/obj/Turntable_Model").parmsInFolder(("Materials",))

		for pa in mat_pars:
			try:
				pa.set("/obj/Turntable_Shader/turntableShop/out")
			except:
				pass
		
		ret2=LHD("LookdevLightRig","Lightrig","latest",":General:Assets:LightSetups:LookdevLightRig","Turntable_Lightrig")
		hou.node("/obj/"+"Turntable_Lightrig").parm("models").set(coll)
		ret3=LHD("modelTurntable","RenderSetup","latest",":General:Assets:RenderSetups:modelTurntable","Turntable_RenderSetup")

		rsobj=hou.node("/obj/Turntable_RenderSetup")
		rsobj.parm("tt_picture").set(seqdir+'/'+Name+".$F4.exr")
		rsobj.parm("tt_comment").set(Name+"_"+vers)

		ret4=LHD("autoscaleCamera","Camera","latest",":General:Assets:CameraSetups:autoscaleCamera","Turntable_LookdevCamera")
		hou.node("/obj/"+"Turntable_LookdevCamera").parm("models").set(coll)
		ret5=LHD("ModelTurntableShader","Shader","latest",":General:Assets:Shaders:ModelTurntableShader","Turntable_Shader")	


		hou.hipFile.save(vPath+'/hipFile/turntable.hip')

		hou.exit()
コード例 #59
0
ファイル: loadHDASets.py プロジェクト: ThaFresh/openassembler
	def loadHDASets_main(self, **connections):
		try:
			nameOverride=str(connections["nameOverride"])
		except:
			nameOverride=""
		try:
			dbPath=connections["dbPath"]
		except:
			dbPath=""
		try:
			Name=str(connections["Name"])
		except:
			Name=""
		try:
			Type=str(connections["Type"])
		except:
			Type=""
		try:
			Version=str(connections["Version"])
		except:
			Version=""
		try:
			oas_output=connections["oas_output"]
		except:
			oas_output="version"		

		if str(geT(dbPath))=="" or str(geT(dbPath))=="0":
			return 0


		if Type=="Model":
			return LHD(Name,Type,Version,dbPath,nameOverride)
		elif Type=="Engine":
			return LHD(Name,Type,Version,dbPath,nameOverride)
			#hou.node("/obj/"+nameOverride).setDisplayFlag(False)
			#hou.node("/obj/"+nameOverride).setDisplayFlag(True)
		elif Type=="Setup":
			ret=LHD(Name,"Model","latest",dbPath,Name+"_Model")
			try:
				ret2=LHD(Name,"Deform","latest",dbPath,Name+"_Deform")
			except:
				pass
			return LHD(Name,Type,Version,dbPath,Name+"_Setup")
		elif Type=="Material":
			hou.hipFile.clear()
			ret1=LHD(Name,"Model","latest",dbPath,Name+"_Model")
			par=hou.node("/obj/"+Name+"_Model").parm("ry")
			coll=""
			for item in hou.node("/obj/"+Name+"_Model").children():
				coll+=str(item.path())+" "

			for item in hou.node("/obj/"+Name+"_Model").parmsInFolder(("Materials",)):
				try:
					item.set("/obj/"+Name+"_Material/"+str(item.name().split("_shop")[0])+"/out")
				except:
					pass
			hou.setFrame(1)
			par.setKeyframe(hou.Keyframe(0))
			hou.setFrame(101)
			par.setKeyframe(hou.Keyframe(360))
			hou.setFrame(1)
			ret2=LHD("LookdevLightRig","Lightrig","latest",":General:Assets:LightSetups:LookdevLightRig","Lookdev_Lightrig")
			hou.node("/obj/"+"Lookdev_Lightrig").parm("models").set(coll)
			ret3=LHD("LookdevLightRig","RenderSetup","latest",":General:Assets:LightSetups:LookdevLightRig","Lookdev_RenderSetup")
			ret4=LHD("autoscaleCamera","Camera","latest",":General:Assets:CameraSetups:autoscaleCamera","Lookdev_LookdevCamera")
			hou.node("/obj/"+"Lookdev_LookdevCamera").parm("models").set(coll)
			return LHD(Name,Type,Version,dbPath,Name+"_Material")			
		elif Type=="everything":
			ret=LHD(Name,"Model","latest",dbPath,Name+"_Model")
			hou.node("/obj/"+Name+"_Model").setDisplayFlag(False)
			hou.node("/obj/"+Name+"_Model").matchCurrentDefinition()
			LHD(Name,"Setup","latest",dbPath,Name+"_Setup")
			hou.node("/obj/"+Name+"_Setup").setDisplayFlag(False)
			hou.node("/obj/"+Name+"_Setup").matchCurrentDefinition()
			for item in hou.node("/obj/"+Name+"_Model").parmsInFolder(("Materials",)):
				try:
					item.set("/obj/"+Name+"_Material/"+str(item.name().split("_shop")[0])+"/out")
				except:
					pass
			try:
				ret2=LHD(Name,"Deform","latest",dbPath,Name+"_Deform")
				hou.node("/obj/"+Name+"_Deform").matchCurrentDefinition()
				hou.node("/obj/"+Name+"_Deform").setDisplayFlag(False)
			except:
				pass

			LHD(Name,"Material","latest",dbPath,Name+"_Material")
			hou.node("/obj/"+Name+"_Material").matchCurrentDefinition()
			hou.node("/obj/"+Name+"_Material").setDisplayFlag(False)
			return "latest"