Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

UProceduralMeshComponent: Creating mesh from spheres

Edit: TL;DR All of the objects in the picture should be spheres, but they triangles are messed up for some reason.

I'm using the UProceduralMeshComponent to create a large mass out of spheres. The way I went about it is by taking a sphere that has been imported into the engine and reading all of the vertex and index data out of it. Then I use that list of verts and indices as a template to create small spheres in specific locations, but all as one mesh. When it renders to the screen though, I get this:

alt text

Here are the code snippet for moving the vertices to where I need them:

void UModelLoader::MoveSphere(FVector& centerpoint) {

 if (uAssetSphere)

     for (uint32 i = 0; i < uAssetSphere->RenderData->LODResources[0].PositionVertexBuffer.GetNumVertices(); ++i)
         sphere.vertices.Add(uAssetSphere->RenderData->LODResources[0].PositionVertexBuffer.VertexPosition(i) + centerpoint);
         //sphere.UV0.Add(uAssetSphere->RenderData->LODResources[0].VertexBuffer.GetVertexUV(i, 0));
         //sphere.vertexColors.Add(FLinearColor(1, 1, 1, 1));
         //sphere.tangents.Add(FProcMeshTangent(uAssetSphere->RenderData->LODResources[0].VertexBuffer.VertexTangentX(i).X, uAssetSphere->RenderData->LODResources[0].VertexBuffer.VertexTangentX(i).Y, uAssetSphere->RenderData->LODResources[0].VertexBuffer.VertexTangentX(i).Z));

     for (int i = 0; i < uAssetSphere->RenderData->LODResources[0].IndexBuffer.GetNumIndices(); ++i)


This is the code snippet for creating the submesh based on my stored vert data:

 for (auto iter : atomGroups->GetAtoms())
     int totalNumberOfTris = 0;

     for (int i = 0; i < iter.Value.Num(); ++i)
         //thisModel.normals += iter.Value[i].atomMesh.normals;
         //thisModel.tangents += iter.Value[i].atomMesh.tangents;
         thisModel.vertices += iter.Value[i].atomMesh.vertices;
         //thisModel.vertexColors += iter.Value[i].atomMesh.vertexColors;
         //thisModel.UV0 += iter.Value[i].atomMesh.UV0;

         for (int eachTri = 0; eachTri < iter.Value[i].atomMesh.Triangles.Num(); ++eachTri)
             thisModel.Triangles.Add(iter.Value[i].atomMesh.Triangles[eachTri] + totalNumberOfTris);
         totalNumberOfTris = thisModel.Triangles.Num();

     mesh->CreateMeshSection_LinearColor(counter, thisModel.vertices, thisModel.Triangles, TArray<FVector>(), TArray<FVector2D>(), TArray<FLinearColor>(), TArray<FProcMeshTangent>(), false);
     mesh->SetMaterial(counter, materials[counter]);

     /*if (counter != 0)

     mesh->SetMeshSectionVisible(counter, false);*/

Product Version: UE 4.18
problem.png (3.1 MB)
more ▼

asked Mar 12 '18 at 04:27 PM in Rendering

avatar image

1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question