Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static BKE Open(string filePath)
        {
            var bke = new BKE();

            using (FileStream stream = new FileStream(filePath, FileMode.Open))
                using (StreamReader r = new StreamReader(stream))
                {
                    BKENode current = null;
                    while (!r.EndOfStream)
                    {
                        var arg = r.ReadLine().TrimStart().Split(' ');

                        if (arg[0].Contains("{"))
                        {
                            while (!r.EndOfStream)
                            {
                                arg = r.ReadLine().TrimStart().Split(' ');

                                if (arg[0].Equals("}"))
                                {
                                    break;
                                }

                                if (current != null)
                                {
                                    float frame = float.Parse(arg[0]) - 1;

                                    var matrix = new OpenTK.Matrix4(
                                        float.Parse(arg[1]), float.Parse(arg[2]), float.Parse(arg[3]), float.Parse(arg[4]),
                                        float.Parse(arg[5]), float.Parse(arg[6]), float.Parse(arg[7]), float.Parse(arg[8]),
                                        float.Parse(arg[9]), float.Parse(arg[10]), float.Parse(arg[11]), float.Parse(arg[12]),
                                        float.Parse(arg[13]), float.Parse(arg[14]), float.Parse(arg[15]), float.Parse(arg[16]));

                                    current.Keys.Add(matrix);
                                }
                            }
                        }
                        else
                        {
                            current = bke.GetCreateNode(arg[0]);
                            if (arg.Length > 1)
                            {
                                current.Parent = bke.GetCreateNode(arg[1]);
                            }
                        }
                    }
                }

            return(bke);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public BKENode GetCreateNode(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(null);
            }

            var node = Nodes.Find(e => e.Name == name);

            if (node != null)
            {
                return(node);
            }

            node = new BKENode()
            {
                Name = name,
            };
            Nodes.Add(node);
            return(node);
        }