【问题标题】:how to represent a vertex-vertex mesh and draw it using openGL?如何表示顶点-顶点网格并使用openGL绘制它?
【发布时间】:2011-10-08 06:48:07
【问题描述】:

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

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()?

【问题讨论】:

    标签: opengl plugins data-structures mesh maya


    【解决方案1】:

    1) 如所述,这是满足您需求的功能性数据结构。

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

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

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

    【讨论】:

    • 那么第二个“面-顶点”结构呢?更容易实现吗?谢谢!
    • @yvetterowe:这不是什么更容易或更难实现的问题。这是一个你需要它做什么的问题。这完全是一个不同的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-22
    • 1970-01-01
    • 2011-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多