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"

Understanding vertices in Procedural Mesh Component


I'm trying to understand how UProceduralMeshComponent works with this article.

I have found that I need to create the UProceduralMeshComponent in an actor to show it. My questions is about UProceduralMeshComponent's vertices parameter:

 @param    Vertices    Vertex buffer of all vertex positions to use for this mesh section.

Where are these vertex positions? From the actor or from the scene? I'm using a SpawnVolume (that inherits from ACharacter) to spawn the actor. I do it this way:

 World->SpawnActor<AMyActor>(WhatToSpawn, SpawnLocation, SpawnRotation, SpawnParams);

Here, there is also another location (SpawnLocation) that I'm not sure if it is the same than @vertices parameter.

Product Version: UE 4.10
more ▼

asked Aug 03 '16 at 01:17 PM in C++ Programming

avatar image

30 13 21 23

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

1 answer: sort voted first

Vertex positions: These are, as the parameter name suggests, the positions of each vertex within the procedural mesh.

They are defined in local space, meaning that the vertex (0, 0, 0) would be exactly at the location of where that actor appears in the world.

A vertex of (10, 10, 0) would be 10 units forward and 10 units to the right from the first vertex (0, 0, 0) and so forward.

The X axis is the forward axis, and the Y axis is the right axis in Unreal.

(10, 0, 0) ------------------------------------- (10, 10, 0)




(0,0,0) ---------------------------------------- (0, 10, 0)

In order to get a mesh to appear, you must define at least a minimum of 3 vertices (i.e. enough to create a single triangle).

The parameter that is mentioned as Triangles (which I personally find to be a bad name as it is somewhat confusing), is what is commonly called as the Index Buffer.

A bit of googling and other resources can explain this better than I can, but basically, it is a more efficient way of specifying the way in which your mesh is to be created.

If you had three vertices, say (0, 0, 0), (100, 0, 0) and (0, 100, 0), in order to draw a triangle with these vertices your index buffer would have to be [0, 2, 1], where each value in the index buffer defines the order in which those vertices in the vertex buffer are joined on the GPU.

Why [0, 2, 1] and not [0, 1, 2] ?

This is because it is a common convention in computer graphics that vertices of a triangle are ordered in counter-clockwise direction.

This also helps later when calculating normals, where a face that is ordered counter-clockwise is considered to have the normals "facing outwards".

Hope this helps!

more ▼

answered Aug 28 '16 at 08:16 PM

avatar image

57 6 11 15

avatar image ViaCognita Aug 30 '16 at 06:06 PM

Thanks!!! This is a very good explanation.

avatar image Nightmask3 Aug 31 '16 at 07:01 AM

If it helped answer your question, kindly mark it as the accepted answer using that 'tick' symbol to the left of it.


avatar image Abeysaurus Jun 10 '18 at 08:50 PM

Hey thanks for that detailed explanation! I understand the vertex ordering, but what I'm trying to do in my project is, using a spline to set the vertices and try and form a plane (fan triangle). Is there a way to arrange the Triangles array based on n number of spline points? I'm trying to do this using Blueprints

avatar image Stormrage256 Aug 09 '18 at 04:45 PM

That was a really detailed explanation. I had initially used the [0,1,2] approach and couldn't see the mesh, because it was inverted. Trying the counterclockwise approach fixed the issue, but I had no idea why it was required to be that away. Thanks for providing the reasoning behind that.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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