[Closed] Get geometry Vert ID from map Vert ID?
The best way to picture this is, how would you select a vert in UVUnwrap, and have it select in the viewport? Map verts and Geo verts don’t have the same ID…
There is no way to know how many vertices correspond to a mapping vert, or the other way round. All you can find is what map faces reference that map vert, then get the geo face with the same index as each map face and get the vertices of that face. The geometry vertex at the same position as the map vertex in the map face (either .x, .y or .z) will be a potential candidate.
So you
- Grab the map vertex index
- Call meshop.getMapFacesUsingMapVert() to find out what map faces use that vert.
- For each map face,
- Find where the map vertex is inside the map face definition (.x, .y or .z)
- Get the geometry Face with the same index as the map face being processed
- Get the .x, .y or .z of the geometry face according to the finding in 4.
- Repeat from 3. for any other map faces
In 6., you will have to append the index of the vertex you discovered in that step to some temp. array. At the end of the loop 3 to 7, you will have an array of all possible geometry vertices that match the map vertex. Then you can grab their positions or select them or whatever.
Same applies to the other direction – finding a map vertex by mesh vertex.
I wrote this function:
function getMapVerts object channel = -- return array of map IDs coresponding to mesh verts
(
if( meshOp.getMapSupport object channel ) then
(
-- prepare array for each verteice
local mapVerts = for i=1 to object.numverts collect #()
local mapFace, meshFace, mVert
for i=1 to (meshOp.getNumMapFaces object channel) do
(
mapFace = meshOp.getMapFace object channel i
mapFace = #( (mapFace.x as integer), (mapFace.y as integer), (mapFace.z as integer) )
meshFace = getFace object i
meshFace = #( (meshFace.x as integer), (meshFace.y as integer), (meshFace.z as integer) )
for j=1 to 3 do
(
if( (findItem mapVerts[meshFace[j]] mapFace[j]) == 0 ) do -- isn't this map vert already added?
(
append mapVerts[meshFace[j]] mapFace[j] -- store index
--append mapVerts[meshFace[j]] (meshop.getMapVert object channel mapFace[j]) -- vertex, index need less memory than map vertex
)
)
)
mapVerts -- return
)
else
undefined -- return
)
It returns array of arrays. It’s one array peer each mesh vertice, it contains IDs of map verts this vert is using.
Search for your map vert id in my function return, to get know which mesh verts are using it.
Hey MiranDMC, why is it that changing this line:
local mapVerts = for i=1 to object.numverts collect #()
…to:
local mapVerts = for i=1 to 5 collect #()
…results in me getting the error “No ““findItem”” function for undefined”, where undefined is mapVerts. It’s a bit odd.