1
\$\begingroup\$

My problem involves pro-gen meshes that I have no part in making and cannot make any changes to, but I need to be able to manipulate each separate piece of the mesh. The meshes do not have any "submeshes" but are made up of multiple parts not connected by any edges.

Using mesh.GetSubmesh(index) and related scripting does not work since the pieces are not explicitly "submeshes" in the way Unity expects them to be.

Is my only hope going to be to iterate over every vert and check if it shares edges with any other verts and group them?

Example, if I had blobs like this (black) that were all one mesh, I want to be able to group them (red): enter image description here

\$\endgroup\$
7
  • \$\begingroup\$ If it's all defined as a single mesh, it's just arrays of undistinguished verts and tris. Is there anything specific to the models themselves that might help? Eg are meshes spatially separated, or is there any animation/rigging information you could piggyback from to simplify? \$\endgroup\$
    – Basic
    Commented Nov 1, 2023 at 21:24
  • \$\begingroup\$ @Basic I added a paint example. Imagine it's some polygons that are blobs. Not even necessarily enclosed 3D meshes. I want a list of vectors to represent each group of verts. \$\endgroup\$
    – Ben Mora
    Commented Nov 1, 2023 at 21:36
  • \$\begingroup\$ I'm afraid I can't see any easy wins. Best I have is an alternative iteration method, if your meshes are generally built with sequential strips of triangles? If so, better than iterating verts and checking every edge may be to iterate triangles and bucketise every vert index you come across (store them in HashSets). Check if triangle n shares any verts with triangle n - 1, and if so, put them in the same bucket. When you come across a tri that has verts in multiple buckets, union/merge the buckets. (Should technically work for any triangle order, but very inefficient if not in strips). \$\endgroup\$
    – Basic
    Commented Nov 1, 2023 at 23:16
  • \$\begingroup\$ If your models are in a standard format like FBX and you have access to the files, you can separate the pieces into submeshes, or multiple meshes, using Blender. Blender might look intimidating, but this type of change is fairly easy to make. \$\endgroup\$
    – Kevin
    Commented Nov 2, 2023 at 1:46
  • \$\begingroup\$ @Basic, sadly not in strips, and no way to know exactly how they are arranged. \$\endgroup\$
    – Ben Mora
    Commented Nov 2, 2023 at 18:40

0

You must log in to answer this question.

Browse other questions tagged .