Example #1
0
        public override Asset Import(string path)
        {
            Material material;

            string name     = Path.GetFileNameWithoutExtension(path);
            MTL    mat      = MTL.Load(path);
            string fileName = mat.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"] = mat;

            return(material);
        }
Example #2
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);
        }