So I want to distort a static mesh with PMC or RMC, I use RMC but can copy the code from PMC and adapt to RMC so either of these two would be good. I want to distort a Static Mesh with noise in PMC or RMC. What must I do to get the mesh converted so it can become procedural, from Static to Dynamic ? I have to read the vertex data from it ? is there any other way. What are the steps, I know how to use PMC and RMC to create procedural planes, meshes and so on, but I want a static mesh that is already a shape to distort it, so I don’t understand this part, how do I read the Static Mesh ? are there different ways of importing a static mesh in PMC ? I searched google but there is nothing on this at all. So one way is to read the buffer of the mesh and then what, is there an example on this. I have to get a vector with x and y on it with the vertexes, how do I do that, or maybe there is another way.
Edit.
I got some code here.
//This is in my constructor
static ConstructorHelpers::FObjectFinder<UStaticMesh>
CubeVisualAsset(TEXT("/Game/Geometry/Meshes/1M_Cube.1M_Cube"));
if (CubeVisualAsset.Succeeded())
{
staticMesh = CubeVisualAsset.Object;
}
//These two have the types inside the header file declared so they are availible across my page in loops and so on.
//They are declared as FPositionVertexBuffer positionBuffer; FStaticMeshVertexBuffer vertexBuffer;
positionBuffer = staticMesh->RenderData->LODResources[0].VertexBuffers.PositionVertexBuffer;
vertexBuffer = staticMesh->RenderData->LODResources[0].VertexBuffers.StaticMeshVertexBuffer;
This is part of my transform and construct function (const FTransform& Transform)**
const int32 VertexCount = positionBuffer.GetNumVertices();
for (int32 index = 0; index < VertexCount; index++ )
{
FVector position = positionBuffer.VertexPosition(index);
Vertices.Add(position);
Colors.Add(FColor(100, 100, 100, 100));
const int32 VertexBuf = vertexBuffer.GetNumTexCoords();
for(int32 uvIndex = 0; uvIndex < VertexBuf; uvIndex++)
{
FVector2D UV = vertexBuffer.GetVertexUV(index, uvIndex);
TexCoords.Add(UV);
}
}
FRawStaticIndexBuffer* IndexBuffer = &staticMesh->RenderData >LODResources[0].IndexBuffer;
for (int32 i = 0; i < IndexBuffer->GetNumIndices(); i++)
{
Triangles.Add(IndexBuffer->GetArrayView()[i]);
// Triangles.Add(staticMesh->RenderData->LODResources[0].IndexBuffer.GetArrayView()[i]);
}
StaticProvider->CreateSectionFromComponents(0, 0, 0, Vertices, Triangles, Normals, TexCoords, Colors, Tangents, ERuntimeMeshUpdateFrequency::Infrequent, true);
StaticProvider->SetupMaterialSlot(0, TEXT("CylinderMaterial"), Material);
}
There are the arrays that are connected to the types the Vertex array and so on and the RMC component
URuntimeMeshProviderStatic* StaticProvider = NewObject(this, TEXT(“RuntimeMeshProvider-Static”));
GetRuntimeMeshComponent()->Initialize(StaticProvider);
These work fine as long as I’m building meshes, planes, landscapes with vectors, but I can’t import static meshes. So why is it not displaying my static mesh, I just want to display it first with RMC and then do other things to it, for now just make it appear. The static mesh with costructor helper works becaue it has a property tag in the header file with editanywhere so I can see an icon of it in the editor tab, it’s there, so it is imported properly in c++ as a variable “staticMesh” . Code compiles but I get nothing.