public void Add(Element child) { OffsetElement offset = child as OffsetElement; if (offset != null) { m_offset = offset; return; } ChannelsElement channels = child as ChannelsElement; if (channels != null) { m_channels = channels; m_bvh.JointList.Add(this); return; } CompositeElement joint = child as CompositeElement; if (joint != null) { m_joint_list.Add(joint); return; } throw new NotSupportedException(); }
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); } } } }