Esempio n. 1
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);
                    }
                }
            }
        }
Esempio n. 2
0
        private void AddUnique <T>(H3DDict <T> Src, H3DDict <T> Tgt) 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;

                int Index = 0;

                while (Tgt.Contains(Name))
                {
                    Name = $"{Value.Name}_{++Index}";
                }

                Value.Name = Name;

                Tgt.Add(Value);
            }
        }