用颜色填充弯曲的对象
我是 OpenGL 新手。 我想画一个有4个顶点的物体。它就像一个四边形对象,但对于底部,我需要绘制一个圆弧。其他边用直线连接。我想填充该对象。
有人可以指导我这样做吗?
I am new to OpenGL.
I want to draw an object which has 4 vertices. It is like a quad object, but for bottom side I need to draw an arc. Other sides are connected with straight lines. I want to fill the object.
Can anybody guide me to do this please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对形状进行三角测量并以您喜欢的任何方式渲染这些三角形(立即模式/VBO/VAO)。
将圆弧形状转换为线段。顶点数量取决于您想要实现的细节化/平滑度。
对形状进行三角测量。对于像这样的简单形状,您可以在代码中手动完成(像我一样在纸上绘制它并写下形成三角形的顶点索引)。对于更复杂的形状,您可以使用三角测量算法(可在网上找到)。当形状更加复杂时(即动物轮廓) - 您可能需要使用特殊的 2D/3D 建模软件来制作它们,它会在那里进行三角测量。
渲染三角形。
Triangulate your shape and render those triangles any way you prefer (immediate mode / VBO / VAO).
Convert your arc shape into segments. Number of vertices depends on detalization/smoothness you want to achieve.
Triangulate the shape. With simple shapes, like this one, you can do it manually in code (draw it on paper like I did and write down vertices indexes that form triangles). With more complicated shapes you could use a triangulation algorithms (available on Net). When shapes are even more complicated (i.e. animal outline) - you might need to use special 2D/3D modelling software just to make them, and it will do triangulation in there.
Render the triangles.