Example #1
0
        public static List <MatConTextura> parseFile(String fileName)
        {
            List <MatConTextura> materiales = new List <MatConTextura>();
            String line;

            String[]     lineSplit;
            StreamReader file = new StreamReader(fileName);

            line = file.ReadLine();
            while (line != null)
            {
                line = line.Trim();                                   //Saco espacios en blanco.
                if ((line.Length != 0) && (!line[0].Equals(COMMENT))) //Si no es comentario
                {
                    lineSplit = line.Split(SEPARATORS, StringSplitOptions.RemoveEmptyEntries);
                    if (lineSplit[0].Equals(NEWMTL))
                    {
                        MatConTextura material = new MatConTextura();
                        material.NombreMaterial = lineSplit[1];
                        materiales.Add(material);
                    }
                    else if (lineSplit[0].Equals(MAPKD))
                    {
                        parseMapkd(materiales, lineSplit);
                    }
                    else if (lineSplit[0].Equals(MAPBUMP))
                    {
                        parseMapbump(materiales, lineSplit);
                    }
                    else if (lineSplit[0].Equals(KA))
                    {
                        parseMatKa(materiales, lineSplit);
                    }
                    else if (lineSplit[0].Equals(KD))
                    {
                        parseMatKd(materiales, lineSplit);
                    }
                    else if (lineSplit[0].Equals(KS))
                    {
                        parseMatKs(materiales, lineSplit);
                    }
                    else if (lineSplit[0].Equals(Ns))
                    {
                        parseMatNs(materiales, lineSplit);
                    }
                }
                line = file.ReadLine();
            }
            file.Close();
            return(materiales);
        }
Example #2
0
        public static void parseMatNs(List <MatConTextura> materiales, String[] args)
        {
            if (materiales.Count() > 0)
            {
                MatConTextura material = materiales.Last();
                switch (args.Length)
                {
                case 2:
                    material.Shininess = float.Parse(args[1], CultureInfo.InvariantCulture);
                    break;

                default:
                    break;
                }
            }
        }
Example #3
0
        public static void parseMapbump(List <MatConTextura> materiales, String[] args)
        {
            if (materiales.Count() > 0)
            {
                MatConTextura material = materiales.Last();
                switch (args.Length)
                {
                case 2:
                    String imagenTex = args[1];
                    material.ImagenTexBump = imagenTex;
                    break;

                default:
                    break;
                }
            }
        }
Example #4
0
        public static void parseMatKd(List <MatConTextura> materiales, String[] args)
        {
            if (materiales.Count() > 0)
            {
                MatConTextura material = materiales.Last();
                switch (args.Length)
                {
                case 4:
                    float kdx = float.Parse(args[1], CultureInfo.InvariantCulture);
                    float kdy = float.Parse(args[2], CultureInfo.InvariantCulture);
                    float kdz = float.Parse(args[3], CultureInfo.InvariantCulture);
                    material.Kdiffuse = new Vector3(kdx, kdy, kdz);
                    break;

                default:
                    break;
                }
            }
        }
Example #5
0
        public static void parseMatKa(List <MatConTextura> materiales, String[] args)
        {
            if (materiales.Count() > 0)
            {
                MatConTextura material = materiales.Last();
                switch (args.Length)
                {
                case 4:
                    float kax = float.Parse(args[1], System.Globalization.NumberStyles.Number);
                    float kay = float.Parse(args[2], CultureInfo.InvariantCulture);
                    float kaz = float.Parse(args[3], CultureInfo.InvariantCulture);
                    material.Kambient = new Vector3(kax, kay, kaz);
                    break;

                default:
                    break;
                }
            }
        }