OpenGL 中可表示的曲线

发布于 2024-12-13 04:23:25 字数 421 浏览 7 评论 0原文

我是 CAD 开发和设计的初学者。想了解一些关于OpenGL的事情。 我的主要目标是表示圆锥曲线、摆线、外摆线、内摆线、渐开线等 我可以使用一些 三角函数 直接表示它们吗?我需要将这些曲线转换为 B 样条曲线? 实际上我目前正在开发内核和内核。想要开发内核,这样我就无法显示上述曲线。(如果我无法以图形方式表示它们,那么在内核中支持这些曲线是没有用的!) 我对OpenGL不太了解,所以如果我的问题真的很愚蠢,请原谅我! 我尝试在此处进行搜索,但找不到任何有用的内容。

I am a beginner in CAD development & want to know some things about OpenGL.
My main objective is to represent conics, cycloid, epicycloid, hypocycloid, involutes, etc
Can i directly represent them using some trigonometry, or do i need to convert these curves into B-Spline?
Actually i am currently developing the kernel & want to develop the kernel so that i cant display the above mentioned curves.(there is no use in supporting these curves in kernel if i cant graphically represent them!)
I dont know much about OpenGL, so please pardon me if my question is really stupid!
I tried searching over here but could not find anything useful.

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

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

发布评论

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

评论(2

鹤舞 2024-12-20 04:23:25

OpenGL 可以使用评估器直接渲染 Bezier 曲线和曲面,甚至可以使用 GLU API 渲染 NURBS。有关详细信息,请参阅 OpenGL 编程指南。所以你可以将这些曲线和曲面转换成这种形式。

但我强烈建议您不要使用这些功能,因为它们已被弃用(从较新的 OpenGL 版本的核心中删除),并且现在可能在软件而不是硬件中实现。

相反,您应该为此类曲线和曲面实现自己的评估例程,以指定的采样率评估相应的方程并生成一个简单的顶点数组(也许还有索引数组)。这样您就可以为未来做好准备,因为它们可以使用 VBO 渲染为标准线带或三角形网格(这是在现代 OpenGL 中渲染某些内容的唯一方法)。

您甚至可以与 API 无关,因为通用顶点数组也可以使用 Direct3D 或其他方式进行渲染。这样您就不会因为绘图调用而污染您的 CAD 内核。它所需要的只是一个将参数曲线和曲面转换为顶点数组(可能还有索引)的函数,并且内核的客户端/用户负责使用他喜欢的任何 API 来绘制这些曲线和曲面。

OpenGL can directly render Bezier curves and surfaces using evaluators and even NURBS using the GLU API. See the OpenGL Programming Guide for more information. So you could transform those curves and surfaces into this form.

But I highly recommend you not to use these features, as they are deprecated (dropped from the core of newer OpenGL versions) and nowadays likely to be implemented in software and not in hardware.

Instead you should rather implement your own evaluation routines for such curves and surfaces, that evaluate the corresponding equations at a specified sampling rate and generate a simple vertex array (and maybe and index array). This way you stay future-ready as these can be rendered as standard line strips or triangular meshes using VBOs (the only way to render something in modern OpenGL).

And you even stay API agnostic, as a general vertex array can also be rendered using Direct3D or whatever. So this way you don't pollute your CAD kernel with draw calls. All it needs is a function to transform parametric curves and surfaces into arrays of vertices (and maybe indices) and the client/user of the kernel is responsible for drawing these with whatever API he likes.

溺孤伤于心 2024-12-20 04:23:25

如果我没记错的话,OpenGL 只适用于平面多边形。尽管如此,您可以检查 GLUT 库是否有任何方法来绘制上述图形,或者通过 google 搜索这些图形的 .obj,然后缩放、旋转并将它们平移到所需的位置。

If I am not wrong, OpenGL only works with flat polygons. Even though, you can check if the GLUT libraries have any method to draw the aforementioned figures, or google for a .obj of those figures, and scale, rotate and translate them to the desired position.

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