Jump to content

[SOLVED] how to get vertex index for some triangle


photo

Recommended Posts

Posted

Hello

I need to do some analysis of geometry, and can't find how to get triangle vertex indices e.g. triangle[0].vert_a, triangle[0].vert_b, triangle[0].vert_c - I need vertex connections in triangle.

thanks

Posted

Hello, lightmap

If geometry is a triangle list, every three indices build one triangle. Vertex indices of the i-th triangle can be obtained as {indices[i * 3], indices[i * 3 + 1], indices[i * 3 + 2]}.

Posted

do Unigine give triangle vertex indices trough getCindex()?

triangle_i_vertex_a = mesh.getCindex(triangle_i + 0, surface);

triangle_i_vertex_b = mesh.getCindex(triangle_i + 1, surface);

triangle_i_vertex_c = mesh.getCindex(triangle_i + 2, surface);

right?

100% consecutive vertices for triangle

or I need to use getTIndex some way?

https://developer.unigine.com/en/docs/2.7.2/api/library/objects/class.objectmeshstatic?rlang=cpp&words=gettindex#getTIndex_int_int_int

getTIndex() Return value : Triangle index

Posted

getTIndex actually returns TVertex index which contains info that can't be shared between adjacent triangles in general case. Here you can find more information about it: https://developer.unigine.com/en/docs/2.7.2/api/library/rendering/class.mesh?rlang=cpp#indices

I suppose you need only vertex coordinates. Then you need work with only getCIndex method. Your snippet is correct except that triangle_i should be multiplied by 3 (if it doesn't contain multiplication already)

  • Like 1
  • silent changed the title to [SOLVED] how to get vertex index for some triangle
×
×
  • Create New...