Getting the world position of skeletal mesh vertex

I’ll try and make this as clear as possible. I need to get the world coordinates of each vertex in a skeletal mesh. The mesh in question has physics enabled and twists, flexes and breaks under force. Because of this I need to get the vertex’s world position resulting from all of the meshes transformations. Thus far i’ve only been able to find this(Accessing Vertex Positions of static mesh - C++ - Epic Developer Community Forums) method for getting this data for a static mesh. Any help towards this goal is much appreciated

1 Like

Did you ever get an answer to this?

I have been trying to figure this out for months. I’ve chased so many dead ends, found unanswered posts, and the occasional “just paste this” answer that doesn’t seem to work.
In case anyone finds this I am going to start posting any progress I make until I get it solved or someone takes pity on me and posts the correct answer.
Lets start with baby steps:
The code below just creates a node with inputs for a skeletal mesh and an integer and a vector output.
It does not return actual vertex positions yet

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "Components/SkeletalMeshComponent.h"
#include "MyBlueprintFunctionLibrary.generated.h"

/**
 * 
 */
UCLASS()
class NEWCPPTESTING_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
    GENERATED_BODY()

        UFUNCTION(BlueprintCallable, Category = "SkeletalMeshStuff")
        static FVector GetVertexPosition(USkeletalMeshComponent* MyComponent, int32 MyVertexIndex);
};

.h file

// Fill out your copyright notice in the Description page of Project Settings.


#include "Components/SkeletalMeshComponent.h"
#include "MyBlueprintFunctionLibrary.h"


FVector UMyBlueprintFunctionLibrary::GetVertexPosition(USkeletalMeshComponent* Comp, int32 VertInd)
	 
{ 
	FVector MyVector = FVector (25.f, 27.f, 29.f);

	return MyVector;
	}

.cpp file

345290-print-vector.png

Making progress I think

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "Components/SkeletalMeshComponent.h"
#include "MyBlueprintFunctionLibrary.generated.h"

/**
 * 
 */
UCLASS()
class NEWCPPTESTING_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
    GENERATED_BODY()

        UFUNCTION(BlueprintCallable, Category = "SkeletalMeshStuff")
        static FVector GetVertexPosition(USkeletalMeshComponent* MyComponent, int32 MyVertexIndex);
};

.h file

// Fill out your copyright notice in the Description page of Project Settings.


#include "Components/SkeletalMeshComponent.h"
#include "Rendering/SkeletalMeshLODRenderData.h"
#include "Rendering/SkinWeightVertexBuffer.h"
#include "MyBlueprintFunctionLibrary.h"


FVector UMyBlueprintFunctionLibrary::GetVertexPosition(USkeletalMeshComponent* Component, int32 VertexIndex)
	 
{ 
	// MyVector = FVector (25.f, 27.f, 29.f);
	FSkeletalMeshLODRenderData Model;
	FSkinWeightVertexBuffer SkinWeightBuffer;
	FVector MyVector = USkeletalMeshComponent::GetSkinnedVertexPosition(Component,VertexIndex,Model,SkinWeightBuffer);

	return MyVector;
	}

.cpp file

Even though Virtual Studio shows no syntax errors, trying to compile results in unresolved externals errors.

I found a post that said I had to make a couple changes in the (projectname).Build.cs file of my game.
This file is located in the UnrealProjects(projectname)\Source(projectname)

Adding , “RHI”, “RenderCore” to the PublicDependencyModuleName line the code now compiles without errors.

Even though there are no errors. It still crashes the editor when I try to pay the level.

1 Like

So… I gave up. Well, gave up trying to figure this out myself anyway.
I hired someone on Fiverr who got this working in a couple of days.
They gave me permission to share the solution with the UE community.
It is now available on myGithub page as an UE Plugin:

Edited to give credit to Fiverr seller:
Their username is cynorthwyydd. If you need any help fixing your C++ UE issues I would very much recommend.

3 Likes

Do you have this for unreal 5 or can you give me some ideas how to make it work? Placing this in the Library folder fails to compile or something.

I don’t have experience with all this

Hello,thanks for sharing,one thing I want to ask you is could this plugin be applied on UE5?

Hello,I want to ask the same question as you,did you success?

Yes, but it was pointless for me as I needed the position of a vertex with the blendshapes applied which it was not able to do unless you bake the mesh and get it out of the GPU which tanks the frame rate when accessing it. It works but it drops the frame rate and you can’t do it every frame.

I don’t recall where I put the code, it must be in some folder. If I remember correctly I’ve had to modify the code plugin to upgrade it to UE5

In fact, I want to get all vertex locations of a metahuman face animation.You mean this plugin couldn’t do this,unless I bake the mesh and get it out of the GPU,right?

I’ve searched for the plugin with the changes I’ve made to make it work inside UE5 but I didn’t find it.

Could you please provide the source code of yours?

I didn’t find it, I was searching to post it here, I have so many archives of the project, looked at all those from that period but I didn’t found it. :person_shrugging: :face_with_symbols_over_mouth: