简体   繁体   English

将圆柱模型绘制为3D粗线

[英]Drawing Cylinder Model as thick 3d line

I am working on an application that has to render a graph 3-dimensionally. 我正在开发一个必须三维渲染图形的应用程序。 Nodes are represented by spheres and in my first draft I just draw glLines as edges. 节点用球体表示,在我的初稿中,我只是将glLines绘制为边缘。

Now the lines need to be 现在需要

a) thick lines and a)粗线和

b) as it is a 3d application, they basically must have an cylindrical shape (It would look very weird otherwise). b)由于是3D应用程序,因此它们基本上必须具有圆柱形状(否则看起来会很奇怪)。

After reading up on thick lines in OpenGL, I figured that this is relatively complicated, especially given my additional cylindrical shape in 3d requirement. 在OpenGL中读取粗线后,我发现这是相对复杂的,特别是考虑到我在3d要求中还添加了圆柱形状。

So I thought "Why not just take a cylinder model, and translate/rotate/scale it in place to represent the edge". 因此,我想到了“为什么不仅仅采用圆柱模型,并对其进行平移/旋转/缩放以表示边缘”。

It works fine for me, and also achieves the look I am going for. 它对我来说效果很好,并且可以实现我想要的外观。

As I never saw anything similar online when researching "thick lines in OpenGL" I was wondering if there are any major drawback with my approach? 在研究“ OpenGL中的粗线”时,我从未在网上看到类似的东西,所以我想知道我的方法是否存在任何重大缺陷?

I would use GLSL 我会使用GLSL

  1. pass interpolation polynomial/control points of rendered part of your curve plot 通过曲线图的渲染部分的插值多项​​式/控制点

    so divide your plot to chunks, fit polynomial or use cubic interpolation. 因此,将您的图划分成块,拟合多项式或使用三次插值。

  2. render rectangle covering your actually rendered chunk 渲染矩形,覆盖您实际渲染的块

  3. in fragment 零碎地

    compute distance of fragment to your curve and either render it (color based on distance) or discard it if more distant then cylinder radius. 计算片段到曲线的距离,然后渲染(基于距离的颜色),如果距离圆柱体半径更远,则将其丢弃。

Here some related QA s that can help you with your task: 以下是一些可以帮助您完成任务的相关质量检查

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM