x

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

Hi!

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
Tags:
more ▼

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

avatar image

ViaCognita
25 12 12 18

(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

Nightmask3
27 5 7 12

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

(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