Ejemplo n.º 1
0
        public override Asset Import(string path)
        {
            Material material;

            string name = Path.GetFileNameWithoutExtension(path);

            ToxicRagers.Generics.Material m = null;

            switch (Path.GetExtension(path).ToLower())
            {
            case ".mt2":
                m = MT2.Load(path);
                break;

            case ".mtl":
                m = MTL.Load(path);
                break;
            }

            if (m != null)
            {
                var    mat      = (m as MT2);
                string fileName = (mat != null ? mat.Texture : (m as MTL).Textures[0]);

                if (fileName == null || fileName == "")
                {
                    material = new Material {
                        Name = name, Texture = new Texture()
                        {
                            Name = fileName
                        }
                    };
                }
                else
                {
                    material = new Material {
                        Name = name, Texture = SceneManager.Current.Content.Load <Texture, TDXImporter>(fileName, Path.GetDirectoryName(path))
                    };
                }

                material.SupportingDocuments["Source"] = m;
            }
            else
            {
                material = new Material();
            }

            return(material);
        }
Ejemplo n.º 2
0
        public override Asset Import(string path)
        {
            string   name     = Path.GetFileNameWithoutExtension(path);
            Material material = new Material {
                Name = name
            };

            MT2 mat = MT2.Load(path);

            foreach (string file in mat.FileNames)
            {
                material.Texture = SceneManager.Current.Content.Load <Texture, TDXImporter>(file, Path.GetDirectoryName(path));
            }

            material.SupportingDocuments["Source"] = mat;

            return(material);
        }