How to create an even sphere with triangles in OpenGL?

前端 未结 2 1414
一个人的身影
一个人的身影 2021-01-01 23:31

Is there a formula that generates a set of coordinates of triangles whose vertices are located on a sphere?

I am probably looking for something that does something s

相关标签:
2条回答
  • 2021-01-01 23:50

    To calculate the normals and the uv map.

    Fortunately there is an amazing trick for calculating the normals, on a sphere. If you think about it, the normals on a sphere are indeed nothing more than the direction from the centre of the sphere, to that point!! Furthermore, if you think it through, that means the normals literally equal the point! i.e., it's the same vector! - just don't forget to normalise the length, for the normal.

    You can win bar bets on that one: "is there a shape where all the normals happen to be exactly ... equal to the vertices?" At first glance you'd think, that's impossible, no such coincidental shape could exist. But of course the answer is simply "a sphere with radius one!" Heh!

    Regarding the UVs. It is relatively easy on a sphere, assuming you're projecting to 2D in the "obvious" manner, a "rectangle-style" map projection. In that case the u and v is basically just the longitude / latitude of any point, normalised to 0,1.

    Hope it helps!

    Here's the all-time-classic web page that beautifully explains how to build an icosphere .. http://blog.andreaskahler.com/2009/06/creating-icosphere-mesh-in-code.html

    0 讨论(0)
  • 2021-01-02 00:03

    Start with a unit icosahedron. Then apply muliple homogenous subdivisions of the triangles, normalizing the resulting vertices distance to the origin.

    0 讨论(0)
提交回复
热议问题