How to use Procedural Mesh Component in Blueprint?
I see Procedural Mesh Component in UE4.9 and I have studied this link:
but I dont know how to build triangle mesh like git example using Blueprint in UE4.9:
I post this as an answer becaus the comment section is too small and won't allow long comments...
Info: I'm on version 4.8.3
Here are some screenshots from my Blueprint setup. There is lots of other stuff there that is not so important and I will try to describe the basic setup:
In my setup, LeftEyeGeometry and RightEyeGeometry are both Procedural Mesh Components that both get a generated mesh. The mesh is generated in the function "Generate Geometry From Distortion", the Procedural Mesh Components are updated with the function "Create Mesh Section"
In my case I generate a mesh from an xml file that contains 2D data points. The function "Create Mesh Section" expects at least an array of vertices (the 3d data points that make up the mesh), an array of triangles (integer: the vertices that make up the faces of the mesh) and an array of UV-coordinates (2d vector: a 2D vector that maps a vertice into UV coordinates for texture mapping).
The function "Generate Geometry From Distortion" generates these three arrays. recommend reading some code about mesh generation, because my implementation is just a translation in blueprint code from existing implementations. Here is the link I used: link text
In the "Generate Vertices"-Comment I just map all vertices to coordinates from -1 to 1 (easyer to scale and my data points are not normalized) and map the X->Y and Y->Z (because I wanted my data points to be in the Y/Z plane).
Here I prepare some variables for the function. NumX is the horizontal vertice count, NumY the vertical count. Vertices is an array of vertices (upper-left to lower-right) in 2D coordinates.
(See picture in comment) Generate UV-Coordinates for each vertice
(See picture in comment) Compare this part with the implementation on link text!
Don't forget to provide a Material for your Procedural Mesh Components!
You can start with a simple example and build a mesh with 4 vertices by hand. The Vertices, Triangle und UV arrays can be build by hand and you can get comfortable with the function "Create Mesh Section". Note that you wont see a mesh if the triangles face the wrong direction.
I hope my explanation is not too reduced. If there are any questions, feel free to ask!
Follow this question
Once you sign in you will be able to subscribe for any updates here