Пример #1
0
        internal void Initialize(Importing.Conversion.Geometry.GeometryFrame frame)
        {
            Index  = frame.Source.Index;
            BoneId = frame.Source.HAnim != null ? (int)frame.Source.HAnim.NodeId : -1;
            Name   = frame.Name;

            if (frame.Source.HAnim == null)
            {
                return;
            }

            Flags = frame.Source.HAnim.Flags;
        }
        public HierarchyAnimation(SectionHeader header, Stream stream)
            : base(header, stream)
        {
            var reader = new BinaryReader(stream);

            Version   = reader.ReadUInt32();
            NodeId    = reader.ReadUInt32();
            NodeCount = reader.ReadUInt32();

            Nodes = new HierarchyAnimationNode[NodeCount];

            if (NodeCount > 0)
            {
                Flags        = (HierarchyAnimationFlags)reader.ReadUInt32();
                KeyFrameSize = reader.ReadUInt32();

                for (int i = 0; i < NodeCount; ++i)
                {
                    Nodes[i] = new HierarchyAnimationNode(reader);
                }

                var stack = new Stack <HierarchyAnimationNode>();
                stack.Push(Root = Nodes[0]);

                foreach (var node in Nodes.Skip(1))
                {
                    stack.Peek().AddChild(node);

                    if (node.Push)
                    {
                        stack.Push(node);
                    }
                    else if (node.Pop)
                    {
                        var n = node;
                        do
                        {
                            n = stack.Pop();
                        } while (n.Pop);
                    }
                }
            }
        }