Search code examples
c++geometrysimplygon

Get Simplygon UV Index


I am currently converting our custom mesh format to simplygon, running a mesh reduction then converting back. The problem at the moment is that the UV number is skyrocketing after converting back to our format. I believe that the UVS are becoming unwelded.

I am using:

spRealArray texcoords = inGeom->GetTexCoords(i);

to get the texture coordinates, I am then using:

spRealData texcoords_xy = g_simplygonSDK->CreateRealData();
texcoords->GetTuple(j, texcoords_xy);

to get each texture coordinate.

But now I need to create a channel of each shared uv index instead of exporting everything as a seperate vertex. How do I find the UV index given a face and a vertex index.


Solution

  • Turns out you need to call: spPackedGeometryData PackedGeom = inGeom->NewPackedCopy();

    This will pack the data for you. You can then use your code as normal.

    spRidArray PackedVertexIds = PackedGeom->GetVertexIds();
    

    will contain the properly packed indices now.