Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Moving Vertex of an Imported Mesh from Maya knowing the "vertex number"

Discussion in 'World Building' started by nachocgi, Sep 23, 2019.

  1. nachocgi

    nachocgi

    Joined:
    Mar 13, 2018
    Posts:
    18
    Hi there guys! a Probuilder noob here,
    I explain, I have a model in Maya and Im able to know the vertex index (what vertex is what).
    My question is, is the same index in Probuilder (once you have converted the object to probuilder mesh) as I see it in Maya?

    That way I would be able to move the vertex (or the face) i want, because I dont know how to know by script what vertex (or group of vertex) correspond to what part of the model.

    thanks!!!
     
  2. nachocgi

    nachocgi

    Joined:
    Mar 13, 2018
    Posts:
    18
    I mean, im used to build my models on Maya, and export to Unity as FBX.
    The examples I´ve seen of Probuilder API (the ones from Karl at GitHub), didnt clarify me how to catch a specific vertex (or group of them), so that I know "what part am I taking".

    Hope I explained well guys XD



    thanks!!!
     
  3. nachocgi

    nachocgi

    Joined:
    Mar 13, 2018
    Posts:
    18
    ok..so I continue investigating XD
    I found a script that allows me to see the vertex number in Unity (thanks to Luke Gane), so I was able to see the relatioship between the model in Maya Viewport and Unity Viewport, and it matchs:


    Now comes the interesting part, I convert that cube into a ProbuilderMesh and vertex index is changed:


    So as I far as I know I need to check the model in Unity to know the newest index...or am I missing something?

    thanks!!!!
     
  4. nachocgi

    nachocgi

    Joined:
    Mar 13, 2018
    Posts:
    18
    hi there, founded an editor inside Probuilder Editor that gives me the vertex number:



    thats great! but...


    int[] v = new int[] {2,3,5,7};
    VertexPositioning.TranslateVerticesInWorldSpace(mesh, v, new Vector3(50, 0, 0));


    wanted to move only the right face for testing, the vertex 2,3,5 and 7, and the result is this:



    only 2,3 and.... 4??? are moved.
    in a more complex mesh is a kaos, so I reduce the example to the cube to try to find how to manage the values via script.
    can someone pointed me what I´m doing wrong? maybe Probuilder works the index in another way? maybe I must grab faces number instead of vertex?

    thanks guys!!!


    EDIT: Update, Found that if I move the vertex via the Position Editor, it works nicely (the numbers are correct)...so maybe is the way I call the function TranslateVerticesInWorldSpace from script??
     
    Last edited: Sep 24, 2019
  5. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    548
    You're super close :)

    ProBuilder can represent vertices in 2 different ways. As a coincident indexes, or as plain old indices to the positions array. When showing vertices to a user, it's almost always as a coincident index. In short, a coincident index is just an integer that represents a collection of unique vertices that share a common point in space.

    So in your picture, the vertex labeled "1" is actually composed of 3 unique vertices. However, in most cases a user would want those vertices to behave as though they are a single point.

    Now, to work with coincident vertices ProBuilder has a number of methods to convert between the two representations. For example, to get all the vertices corresponding to the "1" coincident vertex, you would check the array in `mesh.sharedVertices[1]`. In the other direction, if you have an index to a position and want to get all coincident vertices, you could use `ProBuilderMesh.GetCoincidentVertices`.

    Docs for ProBuilderMesh class are here https://docs.unity3d.com/Packages/c...Engine.ProBuilder.ProBuilderMesh.html#methods
     
  6. nachocgi

    nachocgi

    Joined:
    Mar 13, 2018
    Posts:
    18
    I think this is similar to one thing I read from raywenderlich in this post, talking about "that hiden vertex" that needs to be take into acount to move a geometry (and share the same position):
    https://www.raywenderlich.com/5128-runtime-mesh-manipulation-with-unity

    the thing that makes me crazy was, after apply the Probuilder modificator ( I mean, convert a regular mesh into a Probuilder one), the vertex index was changed, so I cant stay with the index numbers that I see in Maya, which is where I model, I need to recheck the model inside unity with the Probuilder conversion made to get the final indexes.

    Is this correct or am I making a wrong step?

    thanks as always kaarrrlll !!