예제 #1
0
        internal string GetModelPath(string name, GltfModelEntryType type = GltfModelEntryType.Base)
        {
            name = name.ToLowerInvariant();

            if (ModelLookup.ContainsKey(name))
            {
                GltfModelEntry entry = ModelLookup[name];
                if (entry.Types.Contains(type))
                {
                    int index = entry.Types.IndexOf(type);
                    return(entry.Files[index]);
                }
                else
                {
                    if (entry.Types.Contains(GltfModelEntryType.Unknown))
                    {
                        int index = entry.Types.IndexOf(GltfModelEntryType.Unknown);
                        return(entry.Files[index]);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        internal void BuildModelList()
        {
            ModelLookup.Clear();

            List <string> files = new List <string>();

            files.AddRange(Directory.GetFiles(BaseModelFolder, "*.gltf", SearchOption.AllDirectories));
            files.AddRange(Directory.GetFiles(BaseModelFolder, "*.glb", SearchOption.AllDirectories));

            for (int i = 0; i < files.Count; i++)
            {
                string name = Path.GetFileName(Path.GetFileNameWithoutExtension(files[i])).ToLowerInvariant();

                if (ModelLookup.ContainsKey(name))
                {
                    GltfModelEntry entry = ModelLookup[name];

                    var type = GetEntryTypeFromFile(files[i]);
                    if (entry.Types.Contains(type))
                    {
                        continue;
                    }

                    entry.Files.Add(files[i]);
                    entry.Types.Add(type);
                }
                else
                {
                    GltfModelEntry entry = new GltfModelEntry();

                    var type = GetEntryTypeFromFile(files[i]);

                    entry.Files.Add(files[i]);
                    entry.Types.Add(type);

                    ModelLookup.Add(name, entry);
                }
            }
        }