void setMaterialIdentifierMapChannel( const COLLADAFW::ColorOrTexture& colorOrTexture, const COLLADAFW::TextureCoordinateBindingArray& texCoordBindings, const DocumentImporter::SetMapChannelMap& setMapChannelMap, MaterialCreator::MaterialIdentifier::SlotFlags slot, unsigned char& slotFlags, unsigned char& mapChannel) { if ( !colorOrTexture.isTexture() ) { mapChannel = 0; return; } slotFlags |= slot; const COLLADAFW::Texture& texture = colorOrTexture.getTexture(); COLLADAFW::TextureMapId mapId = texture.getTextureMapId(); // find the map id in the list of bind texture coordinates size_t texCoordBindingsCount = texCoordBindings.getCount(); size_t setIndex; bool found = false; for ( size_t i = 0; i < texCoordBindingsCount; ++i) { const COLLADAFW::TextureCoordinateBinding& texCoordBinding = texCoordBindings[i]; if ( texCoordBinding.getTextureMapId () == mapId ) { setIndex = texCoordBinding.getSetIndex (); found = true; break; } } if ( !found || setMapChannelMap.empty() ) { // if we could not resolve we need to guess and chose 1.*/ mapChannel = 1; } else { DocumentImporter::SetMapChannelMap::const_iterator it = setMapChannelMap.find( setIndex ); if ( it == setMapChannelMap.end() ) { // could not find a map channel, take the first mapChannel = setMapChannelMap.begin()->second; } else { mapChannel = (unsigned char) it->second; } } }