Problems with Procedural Mesh and Materials
/// More Updates in the answers below!! ///
Currently i'm having a problem where my mesh isn't getting any sort of material. I've tried alot, and this last bit of code is based from the recent plugin SiggiG posted in the forums. But even like so i can't get it to work... This is all supposed to work during runtime.
Right now it looks like this:
I've changed the material while it's running so you can see that it isn't on the respective mesh.
And the code for that is like this:
I have placed the material interface as material, the "GenMesh->AttachTo(RootComponent)" after the set material, but it's still the same result.
The set material is for index 1, because in the part where i create the mesh section is for index 1 as well.
Am I doing something wrong? I have been trying to work around this problem for the whole week... I really don't see where the problem is. Can someone help me please?
I've discovered that the material is correctly being assigned to the mesh. The problem is that the material does not appear to be placed correctly on the mesh, as in, the edges of the object are not visible. Here you can see the mesh is the same (the left one is the import with editor, and the one on the right is the runtime import):
and the same material applied:
You can also see the size differences in each picture, on the first one is selected the mesh imported in runtime and on the second is the fbx imported in the editor... don't know if that might also be affecting something and is actually an error or not...
What might me causing this incorrect placement? Am I missing information in the mesh? Building the mesh wrong? Or maybe it's in the material?
Okay so I finally found the problem with the textures!!
Such a simple thing... and i missed it over and over again... x-x So much time wasted... I'm so sorry...
Well either way, i'm still failing a bit on the UVs. I have this now:
From what I understand, each index of UV Array corresponds to each index of Vertices Array. So now I know my problem has to do with reading the UV's from the Fbx file.
Either way I'll mark this as resolved since the problem is technically resolved and now it has to do with reading the Fbx.
The problem here is i'm not using the FRawMesh but the Procedural Mesh, so i'm just passing the arrays required for the UProceduralMeshComponent::CreateMeshSection()
I'm trying to avoid the classes in the Editor and Developer folders, so that i don't have to worry much with the copyright or EULA of UE.
Here is how it looks : GenMesh->ClearAllMeshSections();
with MeshData being a struct to save the information of the mesh arrays.
Here is my function to get the uvs from the fbx file:
with UVVertexIndex being Mesh->GetTextureUVIndex(i, j) with i being the current polygon and j the current vertex of the current polygon.
Here is how it is being processed:
Hmmm... This is a little hard without stepping through the code myself, but I think you're interpreting
Whereas you are improperly indexing into the
Also, beware the fallthrough in your
Follow this question
Once you sign in you will be able to subscribe for any updates here