绘制边缘光滑的立方体的最佳方法?贝塞尔曲线,加载 .3ds 或其他?
我需要使用 OpenGL 在 C++ 中制作一个具有平滑角和平滑边缘的立方体。 据我所知,我有三个选择:贝塞尔曲线(也许,可能吗?),一个带有圆柱体作为边缘和球体作为角的立方体,或者加载一个 .3ds 的立方体。
有什么想法吗?
I need to make a cube with smooth corners and smooth edges in C++ with OpenGL.
For all I know I have three options: Bezier curves (maybe, is it possible?), a cube with cylinders for edges and spheres for corners or load a .3ds of a cube.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
伪代码:
pseduocode:
您可以通过将法线直接从中心指向外面来模拟具有平滑光照的立方体(模拟 8 角球体)。这完全取决于您到底想做什么。使用上述方法可能已经足够好了。
如果您想定义一个带有弯角(近距离)的立方体,那么您将必须细分该立方体。事实上,如果你在拐角处强烈细分但忽略平面,你会得到很好的效果。
归根结底就是考虑如何在边缘进行细分。想想如何解决这个问题,你肯定会想出一个很好的解决方案:)
You can simulate a cube with smooth lighting by pointing the normals directly out from the center (simulating an 8 cornered sphere). It totally depends on what exactly you are trying to do. Using the above method may be perfectly good enough.
If you want to define a cube with curved corners (up close) then you are going to have to subdivide the cube. In fact if you subdivide strongly around corners but ignore the flat faces you will get a good effect.
All it comes down to is thinking about how you subdivide at edges. Think about how you could smooth it out and you'll, surely, come up with a fine solution :)