Search Unity

Welding Vertices after using CombineMesh

Discussion in 'Editor & General Support' started by DazBailey, Oct 22, 2014.

  1. DazBailey

    DazBailey

    Joined:
    Jul 7, 2014
    Posts:
    14
    Hi there,

    I've looked around to find an answer regarding this on here, there are a few threads, but most don't really lead on to what I'm trying to achieve.

    Essentially I work for a groundworks company, and our kit is very repetitive / modular.. but there is ALOT of it!

    I've been trying to work out the best way i can create the models inside the engine, going from creating each model as a single mesh, right down to chopping it up into little pieces per item, and reusing the mini mesh's to create prefabs of the finished product.

    The second option, chopping it up into little parts seems to most efficient in terms of the texture space and ease of recreating the component inside Unity, as I can just create a new prefab and combine it using the pieces again, but when I'm doing it this way, my draw calls go through the roof!

    I looked into combine mesh, which does a great job at collapsing my mesh down, greatly reducing the draw calls, but it has a slight issue with the placement of the new collider mesh at the moment, also when there is more than one of these prefabs in the scene, it just removes all the models! Anyway, that's the back story, I'll go onto the technical part below with pictures! Below is an example, where this piece of kit may only have 2 holes or another may have 22, hence the modular approach.

    1.jpg 2.jpg

    The mesh parts are designed in Max, and will 'tile' next to each other, but is there a way i can weld those vertices on the mesh seams? I don't think they are giving me any problems currently (Shown in the second image) but there is alot of wasted resource I can imagine with those vertices being double up. All elements also share the same normals map.

    So to summarize...

    1. Is there a way I can weld those edges?

    2. How can I have more control over the generated Collider mesh?

    3. Why do they disappear when there is more than 1!?

    Many Thanks!

    Darren
     
  2. DazBailey

    DazBailey

    Joined:
    Jul 7, 2014
    Posts:
    14
    Upon closer inspection, it seems to the CombinedMesh that is moving, not the collider! No idea why that is!
     

    Attached Files:

    • 3.jpg
      3.jpg
      File size:
      759.2 KB
      Views:
      961
    • 4.jpg
      4.jpg
      File size:
      649.3 KB
      Views:
      977
  3. DazBailey

    DazBailey

    Joined:
    Jul 7, 2014
    Posts:
    14
    Hmm the problems continue.. seems this one is flipped, despite not actually using any flipping methods (negative scale value) They both are using the same texture, but it just isn't right >.< Must be something or someone on here that can offer some insight!? Pretty please!? :)

    6.jpg 5.jpg
     
  4. steinbitglis

    steinbitglis

    Joined:
    Sep 22, 2011
    Posts:
    254
    I seem to be in the same situation. Did you ever figure out how to weld those vertices?
     
  5. steinbitglis

    steinbitglis

    Joined:
    Sep 22, 2011
    Posts:
    254
    I'm not entirely sure that we have the same situations, but here's my experience.
    I was trying to combine tile models along their seams.
    Their vertices never seemed to combine completely, and on the opengl backend, pixels would occasionally leak through.
    Our solution... we snapped all vertices to a virtual grid, to ensure that corresponding vertices end up at the exact same positions. This made the meshes merge properly, with no light leaking through the seam.
     
  6. hgupta9

    hgupta9

    Joined:
    Mar 28, 2016
    Posts:
    1
    Do any of these libs do what you want?

    Mesh Toolkit v1.10 (C#)
    http://forum.unity3d.com/threads/mesh-toolkit-mesh-geometry-editor.260634/

    - Share double vertices
    - Remove unused vertices

    trimesh (JS)
    https://www.npmjs.com/package/trimesh#mesh-repair-and-validation

    - fuse_vertices
    Welds nearby vertices together, removing small cracks and sliver faces within a mesh.
    The "fuse" function is located at this file : https://github.com/mikolalysenko/Tr...30179dfd1d6f8ab94b6ec6cf057cf7e/src/repair.js
     
    Last edited: Mar 28, 2016
  7. steinbitglis

    steinbitglis

    Joined:
    Sep 22, 2011
    Posts:
    254
    When I analyzed my script, I used Mesh Toolkit, but my problem was my understanding of whether or not I could get vertices to merge. They did, I just had to be accurate enough with their positions.
     
  8. HonoraryBob

    HonoraryBob

    Joined:
    May 26, 2011
    Posts:
    1,214
    I'm running into the same problem. Why doesn't CombineMeshes just leave welded vertices as welded?