Пример #1
0
        private void AddUnique <T>(H3DDict <T> Src, H3DDict <T> Tgt, bool RenameDupes) where T : INamed
        {
            //We need to make sure that the name isn't already contained on the Tree.
            //Otherwise it would throw an exception due to duplicate Keys.
            foreach (T Value in Src)
            {
                string Name = Value.Name;

                if (RenameDupes)
                {
                    int Index = 0;

                    while (Tgt.Contains(Name))
                    {
                        Name = $"{Value.Name}_{++Index}";
                    }
                }
                else
                {
                    if (Tgt.Contains(Name))
                    {
                        Tgt.Remove(Tgt[Tgt.Find(Name)]);
                    }
                }

                Value.Name = Name;

                Tgt.Add(Value);
            }
        }
Пример #2
0
        public void CopyMaterials()
        {
            Materials.Clear();

            foreach (H3DModel Model in Models)
            {
                foreach (H3DMaterial Material in Model.Materials)
                {
                    //Note: The IF is a workaround for multiple models with same material names.
                    //This kind of problem doesn't happen on BCH, but may happen on converted formats.
                    if (!Materials.Contains(Material.Name))
                    {
                        Materials.Add(Material.MaterialParams);
                    }
                }
            }
        }