ModelMaterial::ModelMaterial(Model& model, aiMaterial* material)
        : mModel(model), mTextures()
    {
        InitializeTextureTypeMappings();

        aiString name;
        material->Get(AI_MATKEY_NAME, name);
        mName = name.C_Str();

        for (TextureType textureType = (TextureType)0; textureType < TextureTypeEnd; textureType = (TextureType)(textureType + 1))
        {
            aiTextureType mappedTextureType = (aiTextureType)sTextureTypeMappings[textureType];

            UINT textureCount = material->GetTextureCount(mappedTextureType);
            if (textureCount > 0)
            {
				std::shared_ptr<std::vector<std::wstring>> textures = std::shared_ptr<std::vector<std::wstring>>(new std::vector<std::wstring>());
				mTextures.insert(std::pair<TextureType, std::shared_ptr<std::vector<std::wstring>>>(textureType, textures));

                textures->reserve(textureCount);
                for (UINT textureIndex = 0; textureIndex < textureCount; textureIndex++)
                {
                    aiString path;
                    if (material->GetTexture(mappedTextureType, textureIndex, &path) == AI_SUCCESS)
                    {
                        std::wstring wPath;
                        Library::Utility::ToWideString(path.C_Str(), wPath);

                        textures->push_back(wPath);
                    }
                }
            }
        }
    }
	shared_ptr<ModelMaterial> ModelMaterialProcessor::LoadModelMaterial(Model& model, aiMaterial& material)
	{
		InitializeTextureTypeMappings();
		ModelMaterialData modelMaterialData;

		aiString name;
		material.Get(AI_MATKEY_NAME, name);
		modelMaterialData.Name = name.C_Str();

		for (TextureType textureType = (TextureType)0; textureType < TextureType::End; textureType = (TextureType)(static_cast<int>(textureType) + 1))
		{
			aiTextureType mappedTextureType = (aiTextureType)sTextureTypeMappings[textureType];

			UINT textureCount = material.GetTextureCount(mappedTextureType);
			if (textureCount > 0)
			{
				vector<string>* textures = new vector<string>();
				modelMaterialData.Textures.insert(pair<TextureType, vector<string>*>(textureType, textures));

				textures->reserve(textureCount);
				for (UINT textureIndex = 0; textureIndex < textureCount; textureIndex++)
				{
					aiString path;
					if (material.GetTexture(mappedTextureType, textureIndex, &path) == AI_SUCCESS)
					{
						textures->push_back(path.C_Str());
					}
				}
			}
		}

		return make_shared<ModelMaterial>(model, move(modelMaterialData));
	}
 ModelMaterial::ModelMaterial(Model& model)
     : mModel(model), mTextures()
 {
     InitializeTextureTypeMappings();
 }