public CLARTE.Backport.Tuple <Texture, uint> GetAssimpTexture(uint index) { CLARTE.Backport.Tuple <Texture, uint> result = null; foreach (KeyValuePair <string, CLARTE.Backport.Tuple <Texture, uint> > pair in assimpTextures) { if (pair.Value.Item2 == index) { result = pair.Value; break; } } return(result); }
private static void FromAssimpAlphaTexture(Module.Import.Assimp.Context context, Material material, aiMaterial material_data, aiScene scene, string unity_property, aiTextureType texture_type, Color default_color, Func <Color, float> op) { if (material_data.GetTextureCount(texture_type) > 0) { using (aiString texture_name = new aiString()) { if (material_data.GetTexturePath(texture_type, 0, texture_name)) { Texture alpha = new Texture(context, texture_name.ToString(), scene); Texture base_tex = null; Material.TextureParams param = material.GetTextureParams(unity_property); if (param != null) { CLARTE.Backport.Tuple <Texture, uint> res = context.scene.GetAssimpTexture(param.index); if (res != null) { base_tex = res.Item1; } else { Debug.LogErrorFormat("Invalid texture index. '{0}' was registered for material '{1}' as texture with index '{2}'. However no texture was found with this index.", unity_property, material.Name, param.index); } } else { CLARTE.Backport.Tuple <Texture, uint> assimp_tex = context.scene.GetAssimpTexture(Guid.NewGuid().ToString(), () => new Texture("**E", alpha.width, alpha.height, default_color)); material.AddTextureParams(unity_property, new Material.TextureParams(assimp_tex.Item2)); base_tex = assimp_tex.Item1; } if (base_tex != null) { base_tex.AddToAlpha(alpha, op); base_tex.filename = string.Format("**A{0}|{1}", base_tex.filename, texture_name.C_Str()); } } } } }