First of all, copy-pasting the code I found there, I got a triangle which isn’t not like the one represented there. Here’s my triangle:
I tried to change every
vertexColors.Add(FColor(100,100,100,100));
with
vertexColors.Add(FColor::Red);
but the triangle still looked the same.
Plus, it’s not also very clear to me how UV co-ordinates works. For an example, if I had a vertex at (100, 0, 0) what should be its UV co-ordinates? (-10, 0) maybe?
You need to apply a material that uses the vertex colour in order to see it on the mesh. Use the VertexColor input and link it straight to the diffuse.
UVs map to texture coordinates. If you wanted to create a square mesh that 1:1 mapped a texture you would use something like this
Ok thanks, I actually don’t know how to apply the material in c++ but probably I can search before doing further questions.
But I still have a little problem with the UV. I’ve got your explanation, but let’s assume I just have two triangles. One lies in the XY plane, the other in the XZ.
For the material you probably want a UMaterial pointer in your C++ class and use a blueprint wrapper to set it.
UVs are the coordinates on a square texture 1 unit tall and 1 unit wide. If your texture is a vertical gradient starting at the top with yellow and fading to red at the bottom, UV (0,0) is going to sample the red at the bottom. UV (1,1) or (0,1) or (0.3245f, 1) will all be yellow. UV (0.5, 0.5) will be orange, as will UV(1, 0.5) and UV (0, 0.5);
It’s easier to explain with images but once you get it it’s pretty straightforward.