Search Unity

Moving a point (several vertecies)

Discussion in 'Scripting' started by MentalFish, Mar 31, 2008.

  1. MentalFish

    MentalFish

    Joined:
    Nov 2, 2005
    Posts:
    282
    2 triangles forming a square consists of 4 points where 2 of the points are shared by the triangles. That would normally end up as 6 vertecies.

    So if I want to move a certain point of a mesh I have to move all the vertecies it consists of. What would be the best way for doing this?

    My initial thought was to go through the mesh and map up which vertecies has the same position, and take it from there. Just asking in case there is a better/simpler way.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    For a typical square, that normally would be 4 vertices, actually. It would take six points to define the two triangles, so the triangle array would have six items, but the vertex array would have 4 items in it. There are cases where the shared vertices might be split, though.

    With a square you'd probably just need to move 1 vertex. If this is going to be more robust (dealing with cases where the vertices might be split), then yeah, I guess you'd go through the vertex array and move any points that have the same value.

    --Eric
     
  3. MentalFish

    MentalFish

    Joined:
    Nov 2, 2005
    Posts:
    282
    The square was to illustrate the problem, the model I am working on has 98 points (in LightWave) and 170 vertecies in Unity. Moving each vertex ended up in a "cracked" model.

    I have made a script now that evaluates the vertex list and finds the matching vertecies, so its working, but I think I will spit out the result of this into a text file so it doesn't have to do this for each time the model is instanciated.