Change mesh vertex at runtime (Apply custom Transformation on mesh)

Hello Philip,

After few days of trying couple of things, your idea thanks anyway.

I’ll post my code and the “result on screen” for future starting point if someone wanna try.

First the code,

TArray<FVector> vec;
	FMatrix shearMatrix = FMatrix(FVector(1, 0, 0), 
		                           FVector(0, 1, 0.1), 
								   FVector(0, 0, 1), 
								   FVector(0, 0, 0));

if(!IsValidLowLevel()) return;
if(!_mesh) return;
if(!_mesh->StaticMesh) return;
if(!_mesh->StaticMesh->RenderData) return;

	if (_mesh->StaticMesh->RenderData->LODResources.Num() > 0)
	{
		FPositionVertexBuffer* vBuffer = &_mesh->StaticMesh->RenderData->LODResources[0].PositionVertexBuffer;

		if (vBuffer)
		{
			const int32 nbVertices = vBuffer->GetNumVertices();
			for (int32 index = 0; index < nbVertices; index++)
			{
				const FVector position = GetActorLocation() + GetTransform().TransformVector(vBuffer->VertexPosition(index));
				vec.Add(position);
			}
		}

		for (FVector& v : vec)
			v = MatrixMultiplication(shearMatrix, v);
		
		_mesh->StaticMesh->RenderData->LODResources[0].PositionVertexBuffer.Init(vec);
		_mesh->StaticMesh->RenderData->LODResources[0].PositionVertexBuffer.InitRHI();

		_mesh->MarkRenderStateDirty();
		_mesh->MarkRenderDynamicDataDirty();
		_mesh->MarkRenderTransformDirty();
	}

Before function call :

After function call :

Thanks again and if someones have an idea how to achieve mesh reconstruction at runtime, I’m open to everything.

In the mean time, I did a “pseudo shear and reflection” with the tranform even if not right.

gamer08