Esempio n. 1
0
        private void Add(Element child)
        {
            RootElement root = child as RootElement;

            if (root != null)
            {
                m_root = root;
                return;
            }

            FramesElement frames = child as FramesElement;

            if (frames != null)
            {
                m_frames = frames;
                return;
            }

            FrameTimeElement frame_time = child as FrameTimeElement;

            if (frame_time != null)
            {
                m_frame_time = frame_time;
                return;
            }

            FrameElement frame = child as FrameElement;

            if (frame != null)
            {
                m_frame_list.Add(frame);
                return;
            }

            throw new NotSupportedException();
        }
Esempio n. 2
0
        public void Load(Stream stream)
        {
            using (StreamReader reader = new StreamReader(stream))
            {
                Element         current = null;
                Stack <Element> stack   = new Stack <Element>();

                while (!reader.EndOfStream)
                {
                    string   line   = reader.ReadLine().Trim();
                    string[] fields = line.Split(' ', '\t');
                    switch (fields[0])
                    {
                    case "":
                        continue;

                    case "{":
                        stack.Push(current);
                        continue;

                    case "}":
                        stack.Pop();
                        continue;

                    case "HIERARCHY":
                        continue;

                    case "ROOT":
                        current = new RootElement(this, fields[1]);
                        break;

                    case "JOINT":
                        current = new JointElement(this, fields[1]);
                        break;

                    case "End":
                        current = new EndSiteElement(this, fields[1]);
                        break;

                    case "OFFSET":
                        current = new OffsetElement(fields[1], fields[2], fields[3]);
                        break;

                    case "CHANNELS":
                        current = new ChannelsElement(fields);
                        break;

                    case "MOTION":
                        continue;

                    case "Frames:":
                        current = new FramesElement(fields[1]);
                        break;

                    case "Frame":
                        current = new FrameTimeElement(fields[2]);
                        break;

                    default:
                        current = new FrameElement(this, fields);
                        break;
                    }

                    if (stack.Count == 0)
                    {
                        this.Add(current);
                    }
                    else
                    {
                        CompositeElement parent = stack.Peek() as CompositeElement;
                        parent.Add(current);
                    }
                }
            }
        }