Notifications
Clear all

[Closed] Align Edge Rotation to Direction Vector?

Tried doing FaceNormal Checks, but if just the end is twisted, the Normal doesn’t change, so that won;t work in that case…

I was trying to do closest Vert now from 1 between the 2 new ones, but that isn’t the best choice always either. If the Edge is rotated, like it does, the wrong vert would be closer and get chosen more than likely.

Well, I decided to do a Connect Edge Operation between the 2 side edges, so I can check the distance between those verts. So if they are < the width/2 of the extruded edge, they are overlapped/twisted.

But… for some reason, when I go to use polyop.setVert on the twisted verts, if I try to set the verts to [0,0,0], instead of each vert being at 0, the edge center is at 0. Its like Im using MoveEdge or something instead of setVert… I don’t get it.


local connectedEdgeVerts = (polyop.getVertsUsingEdge selection[1] (polyop.getEdgeSelection selection[1] as array)) as array
	local dist =( distance (polyop.getVert selection[1] connectedEdgeVerts[1] node:Selection[1]) (polyop.getVert selection[1] connectedEdgeVerts[2] node:Selection[1]) )

	polyop.deleteVerts selection[1] connectedEdgeVerts
	selection[1].createFace #(reOrderedVerts[1],reOrderedVerts[2],newVerts[1],newVerts[2]) select:true
	
	if (dist < width/4) do 
	(
		print "twisted"
		local newVert1 = polyop.getVert selection[1] newVerts[1] node:selection[1]
		local newVert2 =  polyop.getVert selection[1] newVerts[2] node:selection[1]

		polyop.setVert selection[1] newVerts[1] [0,0,0] node:selection[1]
		polyop.setVert selection[1] newVerts[2] [0,0,0] node:selection[1]
	)	
	
	polyop.setEdgeSelection selection[1] theEdge

This code will Un-Twist an Edge using the method I described. It works outside of my Painter Interface. Maybe its messing up SetVert somehow…


(
	reOrderedVerts = #(35,36)  --Verts from which the edge was extruded 
	newVerts = #(39,40) --New Verts on new Edge
	width = 4
	theEdge = ((polyop.getEdgeSelection selection[1]) as array)[1]
	
	selection[1].GrowSelection selLevel:2
	local middleEdges = for edge in (polyop.getEdgeSelection selection[1] as array) where edge != theEdge collect edge
	polyop.setEdgeSelection selection[1] middleEdges

	selection[1].connectEdgeSegments = 1
	selection[1].connectEdgePinch = 0
	selection[1].connectEdgeSlide = 0
	selection[1].ConnectEdges edgeFlag:1

	local connectedEdgeVerts = (polyop.getVertsUsingEdge selection[1] (polyop.getEdgeSelection selection[1] as array)) as array
	local dist =( distance (polyop.getVert selection[1] connectedEdgeVerts[1] node:Selection[1]) (polyop.getVert selection[1] connectedEdgeVerts[2] node:Selection[1]) )

	polyop.deleteVerts selection[1] connectedEdgeVerts
	selection[1].createFace #(reOrderedVerts[1],reOrderedVerts[2],newVerts[1],newVerts[2]) select:true

	if (dist < width/2) do 
	(
		print "twisted"
		local newVert1 = polyop.getVert selection[1] newVerts[1] node:selection[1]
		local newVert2 =  polyop.getVert selection[1] newVerts[2] node:selection[1] 
		
		polyop.setVert selection[1] newVerts[1] newVert2 node:selection[1]
		polyop.setVert selection[1] newVerts[2] newVert1 node:selection[1]
	)	
	
	polyop.setEdgeSelection selection[1] theEdge
)

I’ve moved onto trying to use Vertex Normals, and if its < -0.8, then its flipped.

But for some reason, the Normal isnt being updated in my script. It reports 1.0, but then if I stop the tool and check, its actually -0.9 or something.

Well since no one else had anything to say, and since it was becoming a huge pain in the ass, I quickly changed from Painter to MouseTrack and got it setup to so I can use Ctl and Alt to flip the Last Edge or Remove it.

:argh:

Page 2 / 2