Exemplo n.º 1
0
        public static Bone ToBones(BVHNode bvhNode, Bone parent, BVHMotionData bvhMotionData, MotionData resultMotionData)
        {
            Bone result = new Bone(parent, name: bvhNode.Name, offset: bvhNode.Offset);

            if (bvhNode.Type != BVHNodeTypes.EndSite)
            {
                resultMotionData.Data.Add(result, bvhMotionData.Data[bvhNode].ToList());
            }

            foreach (BVHNode item in bvhNode.Children)
            {
                result.Children.Add(ToBones(item, result, bvhMotionData, resultMotionData));
            }

            return(result);
        }
Exemplo n.º 2
0
        public static BVHNode ReadBVH(FileInfo file, out BVHMotionData motionData)
        {
            BVHNode       root;
            BVHMotionData motion;

            using (var fr = file.OpenRead())
            {
                using (var reader = new StreamReader(fr))
                {
                    var line = reader.ReadLine().ToLower().Trim();
                    if (line != "hierarchy")
                    {
                        throw new FileFormatException("File has to start with HIERARCHY keyword");
                    }

                    root   = ReadNode(reader, reader.ReadLine(), 0);
                    motion = ReadMotionData(reader, root);
                }
            }

            motionData = motion;
            return(root);
        }