View Full Version : Find Faces

Sergio007

10-16-2016, 08:36 AM

I'm new to OpenGL and computer graphics.

I have only the coordinates of the vertices of the 3D object.

How to build or find triangular polygons (faces), as well as the texture coordinates?

GClements

10-16-2016, 10:28 AM

I have only the coordinates of the vertices of the 3D object.

Then you may be out of luck. You need the topology, i.e. which vertices form each face.

There are techniques for guessing the topology from the other data, but they're fairly complex, and how well they work depends upon the data.

The fact that you have texture coordinates as well as vertex coordinates suggests that the topology probably existed at some point (techniques which generate sets of points without any topology tend not to generate texture coordinates), so you'd be better off figuring out how to get it than trying to reconstruct it through guesswork.

As a last resort, the first approach to consider would probably be a Delaunay triangulation (https://en.wikipedia.org/wiki/Delaunay_triangulation) of the texture coordinates, discarding degenerate triangles (i.e. where the same vertex coordinates are used for more than one vertex).

Silence

10-16-2016, 11:07 PM

GClements, I'm not sure if the OP has texture coordinates:

I have only the coordinates of the vertices of the 3D object.

To, the OP, once you have the good topology of your model, you can use different algorithms to generate the texture-coordinates. One way to do it is to unroll or unfold the mesh on a plane. A common algorithm can be found here (http://www.cs.jhu.edu/~misha/Fall09/Levy02.pdf).

Sergio007

10-17-2016, 02:29 AM

Then you may be out of luck. You need the topology, i.e. which vertices form each face.

There are techniques for guessing the topology from the other data, but they're fairly complex, and how well they work depends upon the data.

The fact that you have texture coordinates as well as vertex coordinates suggests that the topology probably existed at some point (techniques which generate sets of points without any topology tend not to generate texture coordinates), so you'd be better off figuring out how to get it than trying to reconstruct it through guesswork.

As a last resort, the first approach to consider would probably be a Delaunay triangulation (https://en.wikipedia.org/wiki/Delaunay_triangulation) of the texture coordinates, discarding degenerate triangles (i.e. where the same vertex coordinates are used for more than one vertex).

I have a formula on which to build points. Helicoid rotation surface. Example:

X = 20 * Cos(Angle);

Y = 20 * Sin(Angle);

Z+=0.5;

Further I obtained at each iteration the vertices:

new Vector3(0.0f, 0.0f, Z);

new Vector3(X,Y,Z);

*but there are no polygons

How to see the result of this construction in opengl window?

Silence

10-17-2016, 03:17 AM

If you cannot guess any polygons, then I believe that the most easier thing would be to draw points.

Sergio007

10-17-2016, 03:34 AM

If you cannot guess any polygons, then I believe that the most easier thing would be to draw points.

i need to build normals and make lighting.

This can be done if the figure points to build?

Silence

10-17-2016, 04:07 AM

You can. But lit points are not very useful, except if you have a very dense set of points in a little area.

See this (http://www.cyberforum.ru/graphics/thread1005901.html) in order to have your polygons.

GClements

10-17-2016, 04:38 AM

I have a formula on which to build points. Helicoid rotation surface. Example:

X = 20 * Cos(Angle);

Y = 20 * Sin(Angle);

Z+=0.5;

Further I obtained at each iteration the vertices:

new Vector3(0.0f, 0.0f, Z);

new Vector3(X,Y,Z);

*but there are no polygons

How to see the result of this construction in opengl window?

In which case, the topology is simply a strip of quadrilaterals, i.e. each step adds 2 vertices with indices 2*n and 2*n+1, and each step after the first adds 2 triangles whose vertex indices are [2*n-2, 2*n-1, 2*n] and [2*n, 2*n-1, 2*n+1].

But in this specific case, you could just use glDrawArrays(GL_TRIANGLE_STRIP).

Sergio007

10-17-2016, 07:46 AM

In which case, the topology is simply a strip of quadrilaterals, i.e. each step adds 2 vertices with indices 2*n and 2*n+1, and each step after the first adds 2 triangles whose vertex indices are [2*n-2, 2*n-1, 2*n] and [2*n, 2*n-1, 2*n+1].

But in this specific case, you could just use glDrawArrays(GL_TRIANGLE_STRIP).

glDrawArrays(GL_TRIANGLE_STRIP) - this really works!)

Sergio007

10-17-2016, 08:19 AM

You can. But lit points are not very useful, except if you have a very dense set of points in a little area.

This work too)

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.