How to get the direction of an edge?

How to get the direction of an edge?

futengda
Enthusiast Enthusiast
581 Views
2 Replies
Message 1 of 3

How to get the direction of an edge?

futengda
Enthusiast
Enthusiast

I'm using 3ds Max's `meshop.divideEdge` to split an edge, and the split ratio comes from calculating the edge's vector. This vector is determined by the two points A and B obtained via `meshop.getVertsFromEdge`. Therefore, the ratio I calculate matches the direction from A to B. However, since `getVertsFromEdge` returns a BitArray, the vertex IDs are always in ascending order. But the `divideEdge` method seems to use an edge direction that I can't determine to calculate the split position, which results in the `divideEdge` position being different from what I expected.

 

Therefore, I believe that only by knowing the true direction of the edge can I make the `divideEdge` function work as expected.

0 Likes
Accepted solutions (1)
582 Views
2 Replies
Replies (2)
Message 2 of 3

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

you need edge vertices in the direction order:

/*

--> get face index by edge index:
face = (edge - 1) / 3 + 1

--> get edge index in face:
n = (mod (edge - 1) 3) + 1

*/

-- get edge verts:

fn getMeshEdgeOrderedVerts mesh edge = 
(	
	face = (edge - 1) / 3 + 1
	n = (mod (edge - 1) 3) + 1

	face_verts = getface mesh face
	edge_verts = case n of
	(
			1: [face_verts[1], face_verts[2]] 
			2: [face_verts[2], face_verts[3]] 
	  default: [face_verts[3], face_verts[1]]
	)
)
0 Likes
Message 3 of 3

futengda
Enthusiast
Enthusiast
you are awesome!
0 Likes