Beispiel #1
0
        private void MergeChildren(MDL0BoneNode parent, MDL0BoneNode child, ResourceNode res)
        {
            bool         found = false;
            MDL0BoneNode bone  = null;

            foreach (MDL0BoneNode b1 in parent.Children)
            {
                if (b1.Name == child.Name)
                {
                    found = true;
                    bone  = b1;
                    foreach (MDL0BoneNode b in child.Children)
                    {
                        MergeChildren(b1, b, res);
                    }

                    break;
                }
            }

            if (!found)
            {
                MDL0BoneNode b = child.Clone();
                parent.InsertChild(b, true, child.Index);
                bone = b;
            }
            else
            {
                found = false;
            }

            if (res is MDL0ObjectNode)
            {
                MDL0ObjectNode poly = res as MDL0ObjectNode;
                foreach (Vertex3 v in poly._manager._vertices)
                {
                    if (v.MatrixNode == child)
                    {
                        v.MatrixNode = bone;
                    }
                }
            }
            else if (res is MDL0Node)
            {
                MDL0Node mdl = res as MDL0Node;
                foreach (MDL0ObjectNode poly in mdl.FindChild("Objects", true).Children)
                {
                    foreach (Vertex3 v in poly._manager._vertices)
                    {
                        if (v.MatrixNode == child)
                        {
                            v.MatrixNode = bone;
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private void MergeChildren(MDL0BoneNode main, MDL0BoneNode ext, ResourceNode res)
        {
            bool found = false;

            if (res is MDL0PolygonNode)
            {
                MDL0PolygonNode poly = res as MDL0PolygonNode;
                foreach (Vertex3 v in poly._manager._vertices)
                {
                    if (v._influence == ext)
                    {
                        v._influence = main;
                        main.ReferenceCount++;
                    }
                }
            }
            else if (res is MDL0Node)
            {
                MDL0Node mdl = res as MDL0Node;
                foreach (MDL0PolygonNode poly in mdl.FindChild("Objects", true).Children)
                {
                    foreach (Vertex3 v in poly._manager._vertices)
                    {
                        if (v._influence == ext)
                        {
                            v._influence = main;
                            main.ReferenceCount++;
                        }
                    }
                }
            }
            foreach (MDL0BoneNode b2 in ext.Children)
            {
                foreach (MDL0BoneNode b1 in main.Children)
                {
                    if (b1.Name == b2.Name)
                    {
                        found = true;
                        MergeChildren(b1, b2, res);
                        break;
                    }
                }
                if (!found)
                {
                    if (b2.ReferenceCount > 0)
                    {
                        main.InsertChild(b2, true, b2.Index);
                    }
                }
                else
                {
                    found = false;
                }
            }
        }