Exemple #1
0
        public static VpdMorph Parse(IEnumerable<string> block)
        {
            var rt = new VpdMorph();

            foreach (var i in block)
                if (i.StartsWith("Morph") && i.Contains("{"))
                    rt.MorphName = i.Split(new[] { '{' }, 2).Last();
                else if (i == "}")
                    continue;
                else
                    rt.Weight = float.Parse(i.Split(';').First().Trim());

            return rt;
        }
Exemple #2
0
        public static VpdDocument Parse(string text)
        {
            var rt = new VpdDocument();

            using (var sr = new StringReader(text))
            {
                var header = sr.ReadLine();

                if (header != DisplayName)
                {
                    throw new InvalidOperationException("invalid format");
                }

                sr.ReadLine();
                rt.ParentFileName = sr.ReadLine().Split(new[] { ';' }, 2).First();
                sr.ReadLine();

                for (var i = sr.ReadLine(); i != null; i = sr.ReadLine())
                {
                    if (i.Contains("{"))
                    {
                        if (i.StartsWith("Bone"))
                        {
                            rt.Bones.Add(VpdBone.Parse(new[] { i }
                                                       .Concat(Util.Repeat(sr)
                                                               .Select(_ => _.ReadLine())
                                                               .TakeWhile(_ => _.Trim() != "}"))));
                        }
                        else if (i.StartsWith("Morph"))
                        {
                            rt.Morphs.Add(VpdMorph.Parse(new[] { i }
                                                         .Concat(Util.Repeat(sr)
                                                                 .Select(_ => _.ReadLine())
                                                                 .TakeWhile(_ => _.Trim() != "}"))));
                        }
                    }
                }
            }

            return(rt);
        }
Exemple #3
0
        public static VpdMorph Parse(IEnumerable <string> block)
        {
            var rt = new VpdMorph();

            foreach (var i in block)
            {
                if (i.StartsWith("Morph") && i.Contains("{"))
                {
                    rt.MorphName = i.Split(new[] { '{' }, 2).Last();
                }
                else if (i == "}")
                {
                    continue;
                }
                else
                {
                    rt.Weight = float.Parse(i.Split(';').First().Trim());
                }
            }

            return(rt);
        }