How to get the uvs of each vert in a mesh

How to get the uvs of each vert in a mesh

Anonymous
Not applicable
748 Views
4 Replies
Message 1 of 5

How to get the uvs of each vert in a mesh

Anonymous
Not applicable

Just a simple question that I can't seem to find a simple answer to, how exactly can I get all the uvs of all the verts in a mesh?  I guess another question I would have would be do the uvs come from the mesh?  Or the textures on the material of the mesh?  I need to save all the uvs out to a vector container of my own.  Thank you in advance~

0 Likes
749 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

See FBX SDK coding examples, ImportScene project, DisplayMesh.cxx, DisplayPolygons() function.  It prints out UVs.

0 Likes
Message 3 of 5

Anonymous
Not applicable

Okay I have looked over it, and I am a bit confused by what exactly the element is.  For instance, pMesh->GetElementUVCount() returns 1, but shouldn't it be returning all of the uvs of the entire mesh?  How does it only return 1?  Where are the rest of them?

0 Likes
Message 4 of 5

Anonymous
Not applicable

You can probably answer your own questions faster if you compile the ImportScene project and run the program.  It prints out text information to the command line prompt.

You didn't post a model, so how would I know if has more than one UV?  It might have one UV, or it might have more than one mesh.  Print it out, and you'll get your answer.

0 Likes
Message 5 of 5

Anonymous
Not applicable

I think there's some basic misunderstandings here. pMesh->GetElementUVCount() gives you the number of distinct sets of UV coordinates. You can then extract UV data for particular control points or polygon vertices. An example expression could be

 

FbxVector2 uv0 = pMesh->GetElementUV(0)->GetDirectArray()
.GetAt(pMesh->GetTextureUVIndex(polygonIx, polyVertexIx));

but this is a dramatic oversimplification for a specific circumstance; as samsonite151 has already suggested, you are much better off reading the sample code. Think of it as the secret handbook to decoding the otherwise cryptic documentation of FBX SDK methods. You will not get a complete answer here on the forums. 

 

In the 2018.1.1 SDK, samples/ImportScene/DisplayMesh.cxx lines 178-226 are particularly illustrative.

 

0 Likes