How to slide a vertex or edge in houdini?
4058 6 0- _udo_
- Member
- 18 posts
- Joined: Feb. 2019
- Offline
- animatrix_
- Member
- 4517 posts
- Joined: Feb. 2012
- Offline
Hi,
I wrote a Python SOP node that does this, back in the day before VEX had half edges:
Just add a string parameter for the Edge Group and a float parameter for the Amount locked to -1 to 1 value range.
I wrote a Python SOP node that does this, back in the day before VEX had half edges:
Just add a string parameter for the Edge Group and a float parameter for the Amount locked to -1 to 1 value range.
node = hou.pwd ( ) geo = node.geometry ( ) def filterEdgeGroup ( edgeGroup ): group = [] names = edgeGroup.split ( ' ' ) for name in names: try: edges = geo.globEdges ( name ) except hou.OperationFailed: edges = ( ) for edge in edges: p0 = edge.points ( ) [ 0 ] p1 = edge.points ( ) [ 1 ] try: isValidEdge = geo.findEdge ( p0, p1 ) except: isValidEdge = False if not isValidEdge: continue if len ( edge.prims ( ) ): group.append ( edge ) return group def getPolysFromEdges ( edges ): polys = [] for edge in edges: polys += edge.prims ( ) return polys def getPointsFromEdges ( edges ): points = set ( ) for edge in edges: points.add ( edge.points ( ) [ 0 ] ) points.add ( edge.points ( ) [ 1 ] ) return points def getPointsFromPolys ( polys ): points = set ( ) for poly in polys: verts = poly.vertices ( ) for vert in verts: points.add ( vert.point ( ) ) return points def isValidEdge ( point1, point2 ): try: group = geo.globEdges ( "p{0}-{1} ".format ( point1, point2 ) ) except hou.OperationFailed: return False for edge in group: p0 = edge.points ( ) [ 0 ] p1 = edge.points ( ) [ 1 ] try: return geo.findEdge ( p0, p1 ) != None except: return False def getEdgePointsOfPoint ( point ): points = hou.hscriptExpression ( "pointneighbours(\"" + node.inputs ( ) [ 0 ].path ( ) + "\", " + str ( point ) + ", 1)" ) points = points.split ( ' ' ) points = map ( int, points ) edgePoints = set ( ) for pt in points: if isValidEdge ( point, pt ): edgePoints.add ( geo.iterPoints ( ) [ pt ] ) return edgePoints group = hou.evalParm ( "group" ) amount = hou.evalParm ( "amount" ) edges = filterEdgeGroup ( group ) if not edges: raise hou.NodeWarning ( "No valid edges were found in the group." ) polys = getPolysFromEdges ( edges ) points = getPointsFromEdges ( edges ) outerPoints = getPointsFromPolys ( polys ) outerPoints -= points if not outerPoints: raise hou.NodeWarning ( "No valid edges were found in the group." ) first = outerPoints.pop ( ) source = { first } innerPoints = { first } while source: edgePoints = getEdgePointsOfPoint ( source.pop ( ).number ( ) ) shared = edgePoints.intersection ( outerPoints ) source = source.union ( shared ) innerPoints = innerPoints.union ( shared ) outerPoints = outerPoints.difference ( edgePoints ) goals = outerPoints if ( amount < 0 ): goals = innerPoints for point in points: edgePoints = getEdgePointsOfPoint ( point.number ( ) ) target = edgePoints.intersection ( goals ) if target: p0 = target.pop ( ).position ( ) p1 = point.position ( ) point.setPosition ( p1 + ( p0 - p1 ) * abs ( amount ) )
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
- lewis_T
- Member
- 238 posts
- Joined: March 2013
- Offline
- TangheStudent
- Member
- 88 posts
- Joined: Feb. 2021
- Offline
- Island
- Member
- 340 posts
- Joined: June 2017
- Offline
- TangheStudent
- Member
- 88 posts
- Joined: Feb. 2021
- Offline
- _udo_
- Member
- 18 posts
- Joined: Feb. 2019
- Offline
-
- Quick Links