Get Static Mesh Vertex Locations Using PhysX
**Works in Packaged Games by using PhysX coding!**
**C++ Source Code For You! ♥ **
```
bool UVictoryBPFunctionLibrary::GetStaticMeshVertexLocations(UStaticMeshComponent* Comp, TArray<FVector>& VertexPositions)
{
VertexPositions.Empty();
if(!Comp || !Comp->IsValidLowLevel())
{
return false;
}
//Body Setup valid?
UBodySetup* BodySetup = Comp->GetBodySetup();
if(!BodySetup || !BodySetup->IsValidLowLevel())
{
return false;
}
//Get the Px Mesh!
PxTriangleMesh* TriMesh = BodySetup->TriMesh;
if(!TriMesh)
{
return false;
}
//~~~~~~~~~~~~~~~~
//Component Transform
FTransform RV_Transform = Comp->GetComponentTransform();
//Number of vertices
PxU32 VertexCount = TriMesh->getNbVertices();
//Vertex array
const PxVec3* Vertices = TriMesh->getVertices();
//For each vertex, transform the position to match the component Transform
for(PxU32 v = 0; v < VertexCount; v++)
{
VertexPositions.Add(RV_Transform.TransformPosition(P2UVector(Vertices[v])));
}
return true;
}
```
Download Link (7.8mb)
UE4 Wiki, Plugin Download Page