Exemplo n.º 1
0
        public T SeperatePolygonGroup <T>(STGenericMesh mesh, int index)
            where T : STGenericMesh, new()
        {
            T newMesh = new T();

            newMesh.Name = index == 0 ? mesh.Name : $"{mesh.Name}_{index}";

            Dictionary <STVertex, int> verticesNew = new Dictionary <STVertex, int>();

            STPolygonGroup group = new STPolygonGroup();

            group.Material      = this.Material;
            group.MaterialIndex = this.MaterialIndex;
            newMesh.PolygonGroups.Add(group);

            for (int i = 0; i < Faces.Count; i++)
            {
                if (!verticesNew.ContainsKey(mesh.Vertices[(int)Faces[i]]))
                {
                    verticesNew.Add(mesh.Vertices[(int)Faces[i]], verticesNew.Count);
                }

                group.Faces.Add(Faces[i]);
            }

            newMesh.Vertices = verticesNew.Keys.ToList();
            return(newMesh);
        }
Exemplo n.º 2
0
        private ObjectTreeNode LoadMesh(STGenericMesh mesh)
        {
            ObjectTreeNode node = new ObjectTreeNode(mesh.Name);

            node.ImageKey = "Mesh";
            node.Tag      = mesh;
            return(node);
        }
Exemplo n.º 3
0
        public static List <T> SeperatePolygonGroups <T>(STGenericMesh mesh)
            where T : STGenericMesh, new()
        {
            List <T> meshes = new List <T>(mesh.PolygonGroups.Count);

            for (int i = 0; i < mesh.PolygonGroups.Count; i++)
            {
                meshes.Add(mesh.PolygonGroups[i].SeperatePolygonGroup <T>(mesh, i));
            }

            return(meshes);
        }