Pergunta

Okay, this has been driving me crazy for 4 days now. I don't have a problem with generating the vertices/points, but how to make a closed polygon or a wire frame from them in a reasonably efficient/elegant way?

Another problem is how to store the vertices? In what order should I store the vertices of a 3D object? I really can't think anymore and I've looked for solutions online but couldn't find any.

Something that I thought of is storing the vertices in a 2D array with the horizontal(x and z) edge loops as rows, and the vertical(y) as columns but I doubt that this is a good way to do it.

Foi útil?

Solução

Create an 1D array of vertices, and put them in the order you prefer (although for performance is much better to keep them sorted for examples in strips...). Create an array of indexes (por example an array of shorts) and each element in the array of indexes should point to an index of vertex in the vertices array. The reason to build them as 1D array is that this is the way OpenGL handles things internally.

If your problem is that you don't have an elements array but just a set of points you want to draw as a mesh, you first need to generate such array. First understand basics of triangle topologies: http://gamma.cs.unc.edu/COMP770/LECTURES/11trimesh.pdf and then think on a way to generate a mesh from a set of points.

Outras dicas

There is no standard order when it comes to 3d vertices. You may order them however you like or which fits how you work with them.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top