Showing posts with label API. Show all posts
Showing posts with label API. Show all posts

Thursday, March 23, 2006

Indexing into MFnMesh::getBinormals?

Category: API


MFnMesh::getBinormals dumps a mesh's binormals into a MFloatVectorArray, but its length is different from getNormals'. How do you index into this array? You can't. There's one binormal for each vertex-face pair. So if a vertex is shared by 4 faces, then it will have 4 binormals. getBinormals will go through all the vertices in the mesh in order, and output all their binormals in this long one-dimensional array. Therefore there is no way to index into this array without knowing the mesh's topology beforehand.

Use getFaceVertexBinormals instead.

Then what's the purpose for this function? It can be handy to be use it to dump all the binormal data to a file for exporting.

The samething goes for getTangents.

Thursday, March 16, 2006

Tangent Space Calculation

Category: API


It’s possible to get mismatches ( seams ) due to doing normal averaging based on a tolerance of 30 degrees. Maya only share the normals if they are exactly the same.

Wednesday, March 08, 2006

MPxHwShaderNode::compute(writable) is not

Category: API

It seems that since Maya 6.5, the writable flag in

MPxHwShaderNode::geometry


is not supposed to be true, ever. No geometry from Maya should be writable anymore, this is when used in the hardware renderer, and in the regular viewport.

Wednesday, March 01, 2006

Don't use MFnMesh::object()

Category: api

It seems that MFnMesh::object() will not properly return the MObject to the node in the function set. So don't pass the function set object around functions, and pass the MObject instead. On more than one occasion I've found myself wanting to get the MObject to use on an iterator, but with no way to get to it.

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.