Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Correspondence between Quad and Triangulated Meshes

Discussion in 'General Graphics' started by ferretnt, Mar 12, 2018.

  1. ferretnt

    ferretnt

    Joined:
    Apr 10, 2012
    Posts:
    355
    We have a number of meshes that are quads in Maya. We export them as Quads to Unity, i.e. no triangulation on FBX export.

    Because of our app's special behaviour, we have some runtime calculations that we do based on the quad mesh. However, we then want to apply the results of those operations to a tri mesh (our targets include mobile, which can only render tri-meshes.)

    If we import a quad-containing mesh twice, once with "Keep Quads" and once without, does unity make any guarantees about the correspondence between the meshes such that we can generate a mapping table between faces of the quad-mesh and faces of the tri-mesh.

    Alternatively, we could write our own quad-ification algorithms and run them on the triangle meshes at runtime, but we'd way rather let the art team define the quads in maya.
     
  2. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    How are you going to supply quads to the GPU?
     
  3. ferretnt

    ferretnt

    Joined:
    Apr 10, 2012
    Posts:
    355
    I'm not, I'm going to draw the triangle version of the same mesh. But I want to perform some additional mesh processing against the artist-defined quads, and then want to copy the results of that processing (which requires a quad-mesh) to the tri-mesh, which is why I'd like a correspondence. Does that make more sense to you? I'm being somewhat intentionally vague about exactly what processing we want to do on the quad topology.
     
  4. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    As far as I can tell, you won't have access to quads using Unity Mesh API as it only stores triangles (so naturally it only gives access to triangles). So you need to either write a custom importer with custom data that will parse and store quads as quads, or do some marking of quads using triangles in maya at export time. I imagine storing additional info like colors-per-quad or something like that, so while you're only accessing triangles, you will still have additional info about the original quads that came from maya.
    If you will explain in more details what do you want to achieve, people here may be able to advise something more specific
     
  5. ferretnt

    ferretnt

    Joined:
    Apr 10, 2012
    Posts:
    355
    OK, so on further investigation, mesh.GetIndices and GetTriangles can be used with meshtopology.quads for exactly what I want. Note that 5-sided shapes are always subdivided to triangles, which was the cause of my confusion, because I had a "quad" in maya that actually had 5 verts and two co-linear edges on one side...
     
    Kumo-Kairo likes this.
unityunity