// ---------------------------------------- bool GeometryPolygonExporter::verifyPolygonsForHoles( const MFnMesh &fnMesh ) { // If we want to export triangles, holes aren't of note. if ( triangulated ) return false; // Iterate through all polygons of the current mesh and // verify their polygons for holes. MItMeshPolygon meshPolygonsIter ( fnMesh.object() ); for ( meshPolygonsIter.reset(); !meshPolygonsIter.isDone(); meshPolygonsIter.next() ) { // Is this polygon shaded by this shader? int polyIndex = meshPolygonsIter.index(); uint realShaderCount = ( uint ) mShaders.length(); if ( mShaderPosition < realShaderCount && ( uint ) mShaderIndices[polyIndex] != mShaderPosition ) continue; if ( mShaderPosition >= realShaderCount && ( mShaderIndices[polyIndex] >= 0 && mShaderIndices[polyIndex] < ( int ) realShaderCount ) ) continue; // Look for holes in this polygon // ASSUMPTION: Holes are automatically removed by triangulation. // ASSUMPTION: The iterator gives the hole vertices at the end of the enumeration. // ASSUMPTION: Hole vertices are never used as surface vertices or repeated between holes or inside a hole. if ( meshPolygonsIter.isHoled() && !triangulated ) { return true; } } return false; }
// -------------------------------------------------------- void GeometryPolygonExporter::initializePolygonSource( const MFnMesh &fnMesh, MItMeshPolygon &meshPolygonsIter, PolygonSource &polygon, MIntArray &vertexIndices, uint &numPolygons, uint &numVertices ) { // Collect data in order to handle triangle-only export option // Retrieve the vertex indices and establish the number of polygons (in case of // triangulation more than one is possible) and the number of vertexes in the polygon. retrieveVertexIndices ( vertexIndices, meshPolygonsIter, numPolygons, numVertices ); // Iterate through the polygons (normally just one polygon, // just in case of triangulation it could be more than one) for ( uint polygonPosition=0; polygonPosition<numPolygons; ++polygonPosition ) { // Put the current face in the list of faces polygon.getFaceVertexCounts().push_back ( numVertices ); // Get the index of the current polygon int polyIndex = meshPolygonsIter.index(); // Iterate through the vertexes of the current polygon for ( uint vertexPosition=0; vertexPosition<numVertices; vertexPosition++ ) { // Handle front face vs back face by walking the vertexes backward on the back-face int iteratorVertexIndex = vertexIndices[polygonPosition * numVertices + vertexPosition]; int vertexIndex = meshPolygonsIter.vertexIndex ( iteratorVertexIndex ); // Look for holes in this polygon // ASSUMPTION: Holes are automatically removed by triangulation. // ASSUMPTION: The iterator gives the hole vertices at the end of the enumeration. // ASSUMPTION: Hole vertices are never used as surface vertices or repeated between holes or inside a hole. if ( meshPolygonsIter.isHoled() && !triangulated ) { handleHoledPolygon(polygon, polyIndex, vertexIndex, numVertices, iteratorVertexIndex); } } } }