Hi all,
I'm trying to retrieve the vertices of a triangle on a skeletal mesh. I've managed to get the FaceIndex using a LineTrace, but I couldn't find out how to convert this FaceIndex to the actual vertices indexes.
Here is my current attempt to retrieve the vertexes :
Using the code above, I get three vertices but they are not at all at the position of the LineTrace's hit. My guess is that FaceIndex cannot be convert directly to the vertex index.
So if it's the case, how do I convert FaceIndex to the actual vertex index of the skeletal mesh ? Is it even possible?
Thank you for your help!
I'm trying to retrieve the vertices of a triangle on a skeletal mesh. I've managed to get the FaceIndex using a LineTrace, but I couldn't find out how to convert this FaceIndex to the actual vertices indexes.
Here is my current attempt to retrieve the vertexes :
Code:
bool GetTriangleVertex(const USkeletalMeshComponent* component, const int& faceIndex, FVector& v0, FVector& v1, FVector& v2) { if (!component || !component->SkeletalMesh) return false; auto* skeletalResource = component->SkeletalMesh->GetImportedResource(); if (!skeletalResource || skeletalResource->LODModels.Num() <= 0) return false; int vertexIndex = faceIndex * 3; v0 = component->GetSkinnedVertexPosition(vertexIndex); v1 = component->GetSkinnedVertexPosition(vertexIndex + 1); v2 = component->GetSkinnedVertexPosition(vertexIndex + 2); DrawDebugPoint(GetWorld(), component->ComponentToWorld.TransformPosition(v0), 30, FColor(100, 100, 0), false); DrawDebugPoint(GetWorld(), component->ComponentToWorld.TransformPosition(v1), 30, FColor(100, 100, 0), false); DrawDebugPoint(GetWorld(), component->ComponentToWorld.TransformPosition(v2), 30, FColor(100, 100, 0), false); return true; }
So if it's the case, how do I convert FaceIndex to the actual vertex index of the skeletal mesh ? Is it even possible?
Thank you for your help!
Comment