예제 #1
0
 internal static MQOAttribute parse(string str)
 {
     Match m = MQORegex.Attribute.Match(str);
     if (!m.Success) return null;
     MQOAttribute ma = new MQOAttribute();
     ma.Name = m.Groups[1].Value;
     MatchCollection mc = MQORegex.Decimal.Matches(m.Groups[2].Value);
     ma.Values = new Decimal[mc.Count];
     for (int i = 0; i < mc.Count; i++) ma.Values[i] = Decimal.Parse(mc[i].Value);
     return ma;
 }
예제 #2
0
        internal bool parse(TextReader tr, bool triangle_only = false)
        {
            while (true)
            {
                string str = tr.ReadLine().Trim();
                if (str.StartsWith("vertex "))
                {
                    if (!parseVertex(tr))
                    {
                        Dispose(); return(false);
                    }
                    continue;
                }
                else if (str.StartsWith("face "))
                {
                    if (!parseFace(tr, triangle_only))
                    {
                        Dispose(); return(false);
                    }

                    continue;
                }
                else if (str.EndsWith("{"))
                {
                    if (!MQOFile.skipBlock(tr))
                    {
                        Dispose(); return(false);
                    }
                    continue;
                }
                else if (str.EndsWith("}"))
                {
                    return(true);
                }
                else
                {
                    MQOAttribute ma = MQOAttribute.parse(str);
                    if (ma == null)
                    {
                        Dispose(); return(false);
                    }
                    Attribute.Add(ma);
                    continue;
                }
            }
        }
예제 #3
0
        internal static MQOAttribute parse(string str)
        {
            Match m = MQORegex.Attribute.Match(str);

            if (!m.Success)
            {
                return(null);
            }
            MQOAttribute ma = new MQOAttribute();

            ma.Name = m.Groups[1].Value;
            MatchCollection mc = MQORegex.Decimal.Matches(m.Groups[2].Value);

            ma.Values = new Decimal[mc.Count];
            for (int i = 0; i < mc.Count; i++)
            {
                ma.Values[i] = Decimal.Parse(mc[i].Value);
            }
            return(ma);
        }
예제 #4
0
        internal bool parse(TextReader tr)
        {
            int depth = 0;

            while (true)
            {
                if (depth < 0)
                {
                    return(false);
                }

                string str = tr.ReadLine().Trim();
                if (str.EndsWith("{")) // ライト設定などは読み飛ばす
                {
                    depth++;
                }
                else if (str.EndsWith("}"))
                {
                    if (depth > 0)
                    {
                        depth--;
                    }
                    else
                    {
                        return(true);
                    }
                }
                else if (depth == 0) // depth=0 の属性値だけ読み込む
                {
                    MQOAttribute ma = MQOAttribute.parse(str);
                    if (ma != null)
                    {
                        Attribute.Add(ma);
                    }
                }
                else
                {
                }
            }
        }