Hello,
(to moderators : I am not sure this is the best forum to post this, but as this involves some c++ code, I put that here, feel free to move it)
I am using a small piece of code, based on the ConvertMeshesToStaticMesh utility code, to dynamically convert from a SkeletalMesh to a StaticMesh.
Things are going OK for position and tangents, but it looks like I am missing something for UVs :
Once converted, I get bad UVs such as :
](filedata/fetch?id=1784904&d=1594040069)
While original skeletalMesh shows the right ones :
](filedata/fetch?id=1784905&d=1594040086)
https://forums.unrealengine.com/core/image/gif;base64
I tried a lot of things. In the piece of code above, I am using a LODSection of skeletalMesh, from a skeletalMesh, to convert it to a static mesh (one per lod).
All the commented lines have been tried and lead to the same UVs value, There is probably an abvious thing I am missing, but even by comparing with UE other use cases of WedgeTexCoords,
I did not find my mistake.
Any help would be appreciated !
Best regards
Sebastien
const int32 NumWedges = SkelMeshSection.NumTriangles * 3;
const uint32 NumTexCoords = FMath::Min(LODData.StaticVertexBuffers.StaticMeshVertexBuffer.GetNumTexCoords(), (uint32)MAX_MESH_TEXTURE_COORDS);
for (uint32 iTexCoordIndex = 0; iTexCoordIndex < NumTexCoords; iTexCoordIndex++)
{
RawMesh.WedgeTexCoords[iTexCoordIndex].Reserve(NumWedges);
}
for (int32 WedgeIndex = 0; WedgeIndex < NumWedges; WedgeIndex++)
{
const int32 VertexIndexForWedge = IndexBuffer.Get(SkelMeshSection.BaseIndex + WedgeIndex);
…]
//RawMesh.WedgeTexCoords[0].Add(FVector2D(SkinnedVertex.U, SkinnedVertex.V));
//RawMesh.WedgeTexCoords[0].Add(InSkeletalMeshComp->GetVertexUV(VertexIndexForWedge, 0));
for (uint32 iTexCoordIndex = 0; iTexCoordIndex < NumTexCoords; iTexCoordIndex++)
{
RawMesh.WedgeTexCoords[iTexCoordIndex].Add(InSkeletalMeshComp->GetVertexUV(VertexIndexForWedge, iTexCoordIndex));
//RawMesh.WedgeTexCoords[iTexCoordIndex].Add(LODData.StaticVertexBuffers.StaticMeshVertexBuffer.GetVertexUV(VertexIndexForWedge, iTexCoordIndex));
}
…]
}