• <small id='maPaN'></small><noframes id='maPaN'>

    <i id='maPaN'><tr id='maPaN'><dt id='maPaN'><q id='maPaN'><span id='maPaN'><b id='maPaN'><form id='maPaN'><ins id='maPaN'></ins><ul id='maPaN'></ul><sub id='maPaN'></sub></form><legend id='maPaN'></legend><bdo id='maPaN'><pre id='maPaN'><center id='maPaN'></center></pre></bdo></b><th id='maPaN'></th></span></q></dt></tr></i><div id='maPaN'><tfoot id='maPaN'></tfoot><dl id='maPaN'><fieldset id='maPaN'></fieldset></dl></div>

      • <bdo id='maPaN'></bdo><ul id='maPaN'></ul>
      1. <legend id='maPaN'><style id='maPaN'><dir id='maPaN'><q id='maPaN'></q></dir></style></legend><tfoot id='maPaN'></tfoot>

        在 OpenGL 中绘制球体而不使用 gluSphere()?

        时间:2023-09-18
        <legend id='S0XDk'><style id='S0XDk'><dir id='S0XDk'><q id='S0XDk'></q></dir></style></legend>
                <bdo id='S0XDk'></bdo><ul id='S0XDk'></ul>

                <tfoot id='S0XDk'></tfoot>

              • <small id='S0XDk'></small><noframes id='S0XDk'>

                  <tbody id='S0XDk'></tbody>
              • <i id='S0XDk'><tr id='S0XDk'><dt id='S0XDk'><q id='S0XDk'><span id='S0XDk'><b id='S0XDk'><form id='S0XDk'><ins id='S0XDk'></ins><ul id='S0XDk'></ul><sub id='S0XDk'></sub></form><legend id='S0XDk'></legend><bdo id='S0XDk'><pre id='S0XDk'><center id='S0XDk'></center></pre></bdo></b><th id='S0XDk'></th></span></q></dt></tr></i><div id='S0XDk'><tfoot id='S0XDk'></tfoot><dl id='S0XDk'><fieldset id='S0XDk'></fieldset></dl></div>

                1. 本文介绍了在 OpenGL 中绘制球体而不使用 gluSphere()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  是否有任何教程可以解释如何在 OpenGL 中绘制球体而不必使用 gluSphere()?

                  许多 OpenGL 的 3D 教程都是关于立方体的.我已经搜索过,但大多数绘制球体的解决方案是使用 gluSphere().在 的球体,您可以看到这种技术在起作用.这是一个十二面体,凸出的脸使它看起来更圆.

                  Are there any tutorials out there that explain how I can draw a sphere in OpenGL without having to use gluSphere()?

                  Many of the 3D tutorials for OpenGL are just on cubes. I have searched but most of the solutions to drawing a sphere are to use gluSphere(). There is also a site that has the code to drawing a sphere at this site but it doesn't explain the math behind drawing the sphere. I have also other versions of how to draw the sphere in polygon instead of quads in that link. But again, I don't understand how the spheres are drawn with the code. I want to be able to visualize so that I could modify the sphere if I need to.

                  解决方案

                  One way you can do it is to start with a platonic solid with triangular sides - an octahedron, for example. Then, take each triangle and recursively break it up into smaller triangles, like so:

                  Once you have a sufficient amount of points, you normalize their vectors so that they are all a constant distance from the center of the solid. This causes the sides to bulge out into a shape that resembles a sphere, with increasing smoothness as you increase the number of points.

                  Normalization here means moving a point so that its angle in relation to another point is the same, but the distance between them is different. Here's a two dimensional example.

                  A and B are 6 units apart. But suppose we want to find a point on line AB that's 12 units away from A.

                  We can say that C is the normalized form of B with respect to A, with distance 12. We can obtain C with code like this:

                  #returns a point collinear to A and B, a given distance away from A. 
                  function normalize(a, b, length):
                      #get the distance between a and b along the x and y axes
                      dx = b.x - a.x
                      dy = b.y - a.y
                      #right now, sqrt(dx^2 + dy^2) = distance(a,b).
                      #we want to modify them so that sqrt(dx^2 + dy^2) = the given length.
                      dx = dx * length / distance(a,b)
                      dy = dy * length / distance(a,b)
                      point c =  new point
                      c.x = a.x + dx
                      c.y = a.y + dy
                      return c
                  

                  If we do this normalization process on a lot of points, all with respect to the same point A and with the same distance R, then the normalized points will all lie on the arc of a circle with center A and radius R.

                  Here, the black points begin on a line and "bulge out" into an arc.

                  This process can be extended into three dimensions, in which case you get a sphere rather than a circle. Just add a dz component to the normalize function.

                  If you look at the sphere at Epcot, you can sort of see this technique at work. it's a dodecahedron with bulged-out faces to make it look rounder.

                  这篇关于在 OpenGL 中绘制球体而不使用 gluSphere()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:OpenGL 缩放单像素线 下一篇:OpenGL 线宽

                  相关文章

                  最新文章

                    • <bdo id='7Hqf9'></bdo><ul id='7Hqf9'></ul>

                  1. <legend id='7Hqf9'><style id='7Hqf9'><dir id='7Hqf9'><q id='7Hqf9'></q></dir></style></legend>
                  2. <i id='7Hqf9'><tr id='7Hqf9'><dt id='7Hqf9'><q id='7Hqf9'><span id='7Hqf9'><b id='7Hqf9'><form id='7Hqf9'><ins id='7Hqf9'></ins><ul id='7Hqf9'></ul><sub id='7Hqf9'></sub></form><legend id='7Hqf9'></legend><bdo id='7Hqf9'><pre id='7Hqf9'><center id='7Hqf9'></center></pre></bdo></b><th id='7Hqf9'></th></span></q></dt></tr></i><div id='7Hqf9'><tfoot id='7Hqf9'></tfoot><dl id='7Hqf9'><fieldset id='7Hqf9'></fieldset></dl></div>
                      <tfoot id='7Hqf9'></tfoot>

                      <small id='7Hqf9'></small><noframes id='7Hqf9'>