int AttributeIndex<GDVAT_TEXCOORDS_0>(MItMeshPolygon &polyIt, unsigned int polyVertNum, const char* pAttributeName) { MStatus result; int index; result = polyIt.getUVIndex(polyVertNum, index, &MString(pAttributeName)); if( result == MS::kFailure ) return -1; return index; }
// -------------------------------------------------------- void GeometryPolygonExporter::writeVertexIndices ( COLLADASW::PrimitivesBase* primitivesBasePoly, PolygonSource *polygon, const int vertexIndex, const MIntArray &normalIndices, const int iteratorVertexIndex, MItMeshPolygon &meshPolygonsIter, MFnMesh &fnMesh, const int polyIndex ) { // Dump the indices size_t numAttributes = polygon->getVertexAttributes().size(); // Output each vertex attribute we need for ( size_t kk=0; kk<numAttributes; ++kk ) { const SourceInput& vertexAttributes = polygon->getVertexAttributes()[kk]; COLLADASW::InputSemantic::Semantics type = vertexAttributes.getType(); switch ( vertexAttributes.getType() ) { case COLLADASW::InputSemantic::VERTEX: case COLLADASW::InputSemantic::POSITION: primitivesBasePoly->appendValues ( vertexIndex ); break; case COLLADASW::InputSemantic::NORMAL: case COLLADASW::InputSemantic::TANGENT: case COLLADASW::InputSemantic::BINORMAL: { if (mHasFaceVertexNormals) { // The tangent and the binormal can use the index of the normal int currentVertexIndex = normalIndices [iteratorVertexIndex]; primitivesBasePoly->appendValues ( currentVertexIndex ); } else { // Assert, if we don't have initialized the normal indices, // but want to read them out here! MGlobal::displayError("No face vertex normals to proceed!"); COLLADABU_ASSERT ( mHasFaceVertexNormals ); return; } } break; case COLLADASW::InputSemantic::TEXTANGENT: case COLLADASW::InputSemantic::TEXBINORMAL: { // The texture binormal can use the index of the texture tangent. unsigned int texTangentIndex2 = meshPolygonsIter.tangentIndex ( iteratorVertexIndex ); primitivesBasePoly->appendValues ( texTangentIndex2 ); } break; case COLLADASW::InputSemantic::TEXCOORD: { int uvIndex = 0; int idx = vertexAttributes.getIdx(); meshPolygonsIter.getUVIndex ( iteratorVertexIndex, uvIndex, &mUvSetNames[idx] ); primitivesBasePoly->appendValues ( uvIndex ); } break; case COLLADASW::InputSemantic::COLOR: { MString& colorSetName = mColorSetNames[vertexAttributes.getIdx()]; int colorIndex = 0; { #if MAYA_API_VERSION >= 700 fnMesh.getColorIndex ( polyIndex, iteratorVertexIndex, colorIndex, &colorSetName ); #else fnMesh.getFaceVertexColorIndex ( polyIndex, iteratorVertexIndex, colorIndex ); #endif } primitivesBasePoly->appendValues ( colorIndex ); } break; case COLLADASW::InputSemantic::UNKNOWN: case COLLADASW::InputSemantic::UV: // case COLLADASW::EXTRA: default: break; // Not exported/supported } } }