예제 #1
0
        List <Texture> loadMaterialTextures(Assimp.Material mat, Assimp.TextureType type, string typeName)
        {
            List <Texture> textures = new List <Texture>();

            for (int i = 0; i < mat.GetMaterialTextureCount(type); i++)
            {
                bool        skip = false;
                TextureSlot textureSlot;
                mat.GetMaterialTexture(type, i, out textureSlot);
                for (int j = 0; j < texturesLoaded.Count; j++)
                {
                    if (texturesLoaded[j].path.CompareTo(textureSlot.FilePath) == 0)
                    {
                        skip = true;
                        textures.Add(texturesLoaded[j]);
                        break;
                    }
                }

                if (!skip)
                {
                    Texture texture = new Texture();
                    texture.id   = TextureFromFile(textureSlot.FilePath, directory);
                    texture.type = typeName;
                    texture.path = textureSlot.FilePath;
                    textures.Add(texture);
                    texturesLoaded.Add(texture);
                }
            }
            return(textures);
        }
예제 #2
0
        private ImageTexture[] loadMaterialTextures(ai.Material material, ai.TextureType type, TextureType textureType)
        {
            ImageTexture[] textures = new ImageTexture[material.GetMaterialTextureCount(type)];

            for (int i = 0; i < textures.Length; i++)
            {
                ai.TextureSlot slot;
                material.GetMaterialTexture(type, i, out slot);

                string path = directory + slot.FilePath;

                ImageTexture texture;

                ImageTexture loaded = loadedTextures.Find(x => x.path == path);

                if (loaded != null)
                {
                    texture = loaded;
                }
                else
                {
                    texture = new ImageTexture(gl, path, textureType);
                    loadedTextures.Add(texture);
                    Console.WriteLine($"Texture file path: {path}");
                }

                textures[i] = texture;
            }

            return(textures);
        }
예제 #3
0
        private static Ai.TextureSlot ConvertTextureSlotFromTextureId(int textureId, Ai.TextureType type, TextureSet textureList)
        {
            if (textureId == -1 || textureList == null)
            {
                return(default(Ai.TextureSlot));
            }

            var texture = textureList.Textures.FirstOrDefault(x => x.Id == textureId);

            if (texture != null)
            {
                return(new Ai.TextureSlot(TextureUtilities.GetFileName(texture), type, 0, Ai.TextureMapping.FromUV, 0, 0, Ai.TextureOperation.Add, Ai.TextureWrapMode.Wrap, Ai.TextureWrapMode.Wrap, 0));
            }

            return(default(Ai.TextureSlot));
        }
예제 #4
0
 private static Ai.TextureSlot ConvertTextureSlotFromTextureId(int textureId, Ai.TextureType type,
                                                               TextureSet textureList)
 {
     if (textureId == -1 || textureList == null)
     {
         return(default);