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;
			}
		}
	}
	//------------------------------
	bool LibraryEffectsLoader::handleTexture( const texture__AttributeData& attributeData )
	{
		bool success = true;
		switch ( mCurrentProfile )
		{
		case PROFILE_COMMON:
			{
                // Get the current color or texture element.
				COLLADAFW::ColorOrTexture* colorOrTexture = getCurrentColorOrTexture ( true );

                // Check if the texture is referenced.
                String textureSid = (const char *)attributeData.texture;
				SidSamplerInfoMap::const_iterator it = mEffectProfileSidSamplerInfoMap.find(textureSid);
				if ( it == mEffectProfileSidSamplerInfoMap.end() )
                {
                    it = mEffectSidSamplerInfoMap.find((const char*)attributeData.texture);
                    if ( it == mEffectSidSamplerInfoMap.end() )
                    {
						String msg("Texture with sid \"" + textureSid + "\" not found");
						if ( mCurrentEffect )
						{
							msg += " in effect with id \"" + mCurrentEffect->getOriginalId() + "\"";
						}
						msg += ".";
                        success = handleFWLError ( SaxFWLError::ERROR_UNRESOLVED_REFERENCE, msg );
                        break;
                    }
                }

				// Push the texture sid of the current sampler in the list of used samplers
				// of the current effect profile. 
				size_t samplerIndex = 0;
				StringIndexMap::const_iterator samplerIt = mEffectProfileSamplersMap.find(textureSid);
				if ( samplerIt == mEffectProfileSamplersMap.end() )
				{
					// This sid has not been used before. Add to map with next index
					samplerIndex = mNextSamplerIndex;
					mEffectProfileSamplersMap.insert(std::make_pair(textureSid, mNextSamplerIndex++));
				}
				else
				{
					// This sid is already in the map. Use its index
					samplerIndex = samplerIt->second;
				}

				// Initialize the texture element.
				/* const SamplerInfo& samplerInfo = it->second; */ /* UNUSED */
				colorOrTexture->setType(COLLADAFW::ColorOrTexture::TEXTURE);
				COLLADAFW::Texture& texture = colorOrTexture->getTexture();
                texture.setUniqueId ( createUniqueId(COLLADAFW::Texture::ID()) );
				texture.setSamplerId( samplerIndex );
				if ( attributeData.texcoord )
				{
					texture.setTextureMapId( getTextureMapIdBySematic( attributeData.texcoord) );
                    texture.setTexcoord(attributeData.texcoord);
                }

				break;
			}
            /*
                PROFILE_BRIDGE,
                PROFILE_CG,
                PROFILE_GLES,
                PROFILE_GLES2,
                PROFILE_GLSL,
                PROFILE_COMMON,
                PROFILE_NONE
              */
            default:
                break;
		}
		return success;

	}