I want to control the vertex positon of a skeletonmeshcomponent instead of skeleton Anim to make the deformation of my object,like cloth simulation in UE,we can paint some of the vertexs in the mesh and then those will move in the running interface.
I had used these codes to get the vertexs positon information:
USkeletalMesh* SkeletalMesh = SkeletalMeshComponent->SkeletalMesh;
if (SkeletalMesh)
{
FSkeletalMeshRenderData* RenderData = SkeletalMesh->GetResourceForRendering();
if (RenderData && RenderData->LODRenderData.IsValidIndex(0))
{
FSkeletalMeshLODRenderData& LODData = RenderData->LODRenderData[0];
FStaticMeshVertexBuffers& VertexBuffers = LODData.StaticVertexBuffers;
FPositionVertexBuffer& PositionVertexBuffer = VertexBuffers.PositionVertexBuffer;
const int32 NumVertices = PositionVertexBuffer.GetNumVertices();
for (int32 VertexIndex = 0; VertexIndex < NumVertices; ++VertexIndex)
{
const FVector& VertexPosition = FVector(PositionVertexBuffer.VertexPosition(VertexIndex));
Vertices.Add(VertexPosition);
}
}
}
Clearly we cant modify this PositionVertexBuffer directly,so if I want to change my mesh vertex position in real time and show the effection,how can I do?