Procedural Mesh Component Classes and Documentation

Greetings!

I’d like to try this new Procedural Mesh Component … “framework”?.. But the truth is I can’t find the classes nor the documentation to check to know what can I do for real.

Since it’s an experimental feature, I would understand if the docs are lacking. Still, does anyone know which classes are involved? So far I can’t find any UProceduralMeshComponent class… I might be missing an include here, as well.

I’m already working with the previous approach, but it would be nice to try and do it with this component.

Thanks!

At the moment I’m not able to access the new procedural mesh component directly from C++, but I’ve been able to get it working by:

  • Creating a C++ class which extends AActor. This should contain a TArray of FVector for your vertex positions, and a TArray of int32 to contain your face data (Indices 0,1,2 are the for first triangle, 3,4,5 for second and so on). There should also be a BP-callable UFUNCTION() to load the geometry arrays with the values.

  • Create a Blueprint extending the C++ class, and add a ‘Procedural Mesh’ component to it in the editor. Have the event graph call the function to load the geometry, and then the ‘Create Mesh Section’ node to set the geometry for the procedural mesh.

Interesting, That’s exactly what I’m talking about and the lead I was missing as well. I was so focused on C++ that completely overlooked everything Blueprint. I’ll give it a go and while I’m at it, I think I’ll try and dig a little deeper into this “Procdedural Mesh” component’s Blueprint code.

The documentation you can find here : Procedural Mesh | Unreal Engine Documentation

The procedural mesh component is consist of Four static functions and three member functions, which are all accessible in blueprints. the following is a short description :

Create Mesh Section : Clear all mesh sections and reset to empty state Target is Procedural Mesh Component ( mainly it means that it removes what you already have created.

Clear Mesh Section : Clear a section of the procedural mesh. Other sections do not change index. Target is Procedural Mesh Component ( it means that it remove a section of what you have created, if you have created your mesh in separate steps and with different section index )

Create Mesh Section : Create/replace a section for this procedural mesh component. Target is Procedural Mesh Component ( this is the main function which create your mesh, after which your mesh is visible. normally it is the last function call in your logic )

Regarding the remaining static function I will just tell the most important one

Calculate Tangents for Mesh : Automatically generate Normals and Tangent vector array for a mesh UVs are required for correct tangent generation. Target is Kismet Procedural Mesh Library ( this creates the normal and tangent array for you, and you need to pass them to “Clear Mesh Section” function for the lighting and mapping works and be accurate )

Some point to consider :

Calculate Tangents for Mesh : function is a very time consuming function, so be careful about when to use it. my advice is to use threading for calling this function.

you need to calculate the followings your self :
1 - An array of FVector that your data is in.
2 - An array for the indexed Trianlges
3 - An array of Vector2 for UV mapping

Other points :

If it is possible try to break your mesh in smaller sections and create them separately. for this you need to pass different SectionId to “Clear Mesh Section”. this helps your program to be faster.

In case you have a mesh which its size does not change but the value of its points changes, most probably you won’t need to calculate the Triangle index array and UV array in each time you wanna update the mesh.

in case you want some example leave me a comment to share an image of my blueprints.

plangton i would appreciate some of your examples. Actually i am trying to use this component but have some issues. For example, i am still not able to change normals and i am not sure why.

is sharing blueprint enough ? since I am using a blueprint for calculating the normal and tangents

the function you are searching to find to use in C++ is in is in KismetProceduralMeshLibrary.h

I have a simple example of using UProceduralMeshComponent purely in C++. You can view it here:

You likely cannot access it because you need to add it as a module. Why I don’t know. Your *.build.cs file will need to have a line that looks like this: PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "ProceduralMeshComponent" });

1 Like

I would also like some (non auto generated) documentation and examples how to use this in c++. And the old wiki is dead.