如何表示顶点-顶点网格并使用 openGL 绘制它?

发布于 2024-12-09 04:32:00 字数 1167 浏览 0 评论 0原文

我被要求更改 Maya apiMeshShape 插件中的网格数据结构。所以现在我想绘制一个以顶点-顶点结构表示的 3D 网格(正如您在 en.wikipedia.org 中看到的那样) /wiki/Polygon_mesh)使用opengl。

1)首先,我不知道如何准确地表示顶点-顶点网格。请问下面的数据结构可以吗?

MPointArray vertices;    //the position of all the vertices
MIntArray vertices_connects_counts;    //how many other vertices each vertex connect with
MIntArray vertices_connects;    //the index array storing each the vertices' index connected with all the vertices

http://en.wikipedia.org/wiki/Polygon_mesh 中的立方体示例作为例子。

vertices_connects_counts = {5,5,5,5,5,5,5,5,4,4};
vertices_connects = {1,5,4,3,9,
                    2,6,5,0,9,
                    3,7,6,1,9,
                    2,6,7,4,9,
                    5,0,3,7,8,
                    6,1,0,4,8,
                    7,2,1,5,8,
                    4,3,2,6,8,
                    5,6,7,8,                                       
                    0,1,2,3 };

2)其次,如果上面的数据结构是正确的我想知道如何使用openGL绘制网格?我应该将哪个参数传递给 glBegin()?

i am asked to change the mesh data structure in the apiMeshShape plug-in of Maya. So now I wanna draw a 3D mesh represented in Vertex-vertex structure (as you can see in en.wikipedia.org/wiki/Polygon_mesh) using opengl.

1)First, i don't know exactly how to represent the Vertex-vertex mesh. I wonder if the data structure as follow is ok?

MPointArray vertices;    //the position of all the vertices
MIntArray vertices_connects_counts;    //how many other vertices each vertex connect with
MIntArray vertices_connects;    //the index array storing each the vertices' index connected with all the vertices

take the cube example in the http://en.wikipedia.org/wiki/Polygon_mesh as the example.

vertices_connects_counts = {5,5,5,5,5,5,5,5,4,4};
vertices_connects = {1,5,4,3,9,
                    2,6,5,0,9,
                    3,7,6,1,9,
                    2,6,7,4,9,
                    5,0,3,7,8,
                    6,1,0,4,8,
                    7,2,1,5,8,
                    4,3,2,6,8,
                    5,6,7,8,                                       
                    0,1,2,3 };

2)Secondly, if the data structure above is right i wonder how to draw the mesh using openGL? Which parameter should i pass into glBegin()?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终止放荡 2024-12-16 04:32:00

1)这是一个满足您所描述的需求的功能数据结构。

2)请允许我引用您链接的维基百科文章:

但并未广泛使用,因为面部和边缘信息是隐式的。因此,需要遍历数据以生成用于渲染的人脸列表。

这就是你必须做的。如果您坚持保留此数据结构(我不会),那么您将必须遍历连接图并构建顶点面列表。然后您将有数据发送到 OpenGL。

1) That's a functional data structure for your needs as described.

2) Allow me to quote the Wikipedia article that you linked:

but not widely used since the face and edge information is implicit. Thus, it is necessary to traverse the data in order to generate a list of faces for rendering.

That's what you have to do. If you insist on keeping this data structure (and I wouldn't), then you're going to have to walk the connectivity graph and build a list of vertex faces. Then you'll have the data to send to OpenGL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文