Tuesday, February 28, 2006

Finding edge directions for MFnMesh::split factors

Category: API

The docs for MFnMesh::split explains edgeFactors as:

"edgeFactors array of factors in the range [0,1] that represent how far along each edge must the split be done. This array must have the same number of elements as the edgeList array."

However, it doesn't explain how the order of the vertices are determined. This creates a problem where the way the edges are split becomes unpredictable when the function is used directly with factors other than 0.5.

The way to determine which vertex is 0 and which is 1 can be found as follows:

The order of the vertex is determined by how Maya stores the vertices internally. This order can be retrieve by using MFnMesh::getEdgeVertices( int edgeId, int2 &vertexList ).
The order the verticies appear in the int2 array is the way the edgeFactor should be determined. Where int2[0] is 0 and int2[1] is 1.


No comments: