OpenGL - 扫描表示

发布于 2024-12-11 15:54:32 字数 230 浏览 0 评论 0原文

我有一组点,仅限于二维坐标平面,特别是第一和第四象限(正 x 值)。我能够通过这些点画一条线。

我还可以在 3D 空间中的另一个窗口中将这些点绘制为一条线。我该如何围绕轴(例如 Y)扫描它们,以便获得 3D 网格?我相信通常的例子是使用点在 Maya 中创建一条线,创建一个高脚杯等。

我似乎无法通过谷歌搜索术语“扫描表示”找到太多信息,这就是我的教科书所指的这个过程。我只是在寻找某种思维过程或指导方针来指导我!

I have a set of points, confined to a two dimensional coordinate plane, specifically the first and fourth quadrants (positive x values). I am able to draw a line through these points.

I can also draw these points in 3D space, in another window, as a line. How would I go about sweeping them around an axis, say, Y, so that I can achieve a 3D mesh? I believe the usual example for this is using points to create a line in Maya, to create a goblet or the like.

I can't seem to find much by Googling the term "Sweep Representation", which is what my textbook refers to this process as. I'm just seeking some kind of thought process, or guidelines to, um, guide me!

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

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

发布评论

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

评论(2

戒ㄋ 2024-12-18 15:54:32

有很多方法可以做到这一点,但最重要的原则是围绕某个轴旋转原始线,然后将顶点从当前线发射到下一行以生成三角形,记住通过加入三角形来“闭合”形状最后一行与第一行。

就我个人而言,我会生成一个顶点缓冲区和一个索引缓冲区。我将绕 Y 轴旋转线 N 次,将每条旋转线的点存储到顶点缓冲区中。

然后,算法的下一部分将为一个或多个线带生成索引(多个线带更容易,因为否则您需要创建简并三角形以从一个线带到下一个线带)

所以,假设您有一个顶点缓冲区 V、原始线 P 中的多个点和多个线 N,您可以简单地迭代,通过发出索引 I 和索引 I + P、P * N 次来生成三角形带。然后,在给定顶点缓冲区和索引缓冲区的情况下渲染 N 个三角形条带。

如果你想聪明点,你可以只存储一个带有单个条带索引的索引缓冲区,并在每次渲染时将 P 添加到基本顶点索引。请小心具有大量索引的高度细分的网格。有些卡的最大顶点索引为 65535,其他卡的最大顶点索引稍大一些。

我希望这是有道理的!

There are many ways to do this, but the overriding principle is to rotate the original line around some axis, and then emit vertices from the current line to the next line in order to generate triangles, remembering to "close" the shape by joining the last line with the first.

Personally I would generate a vertex buffer and an index buffer. I would rotate the line N times around the Y axis, storing each rotated line's points into the vertex buffer.

Then, the next part of the algorithm would generate indices for one or more line strips (multiple line strips are easier because otherwise you'd need to create degenerate triangles to go from one strip to the next)

So, given that you have a vertex buffer V, a number of points in your original line P and a number of lines N, you can simply iterate across, generating triangle strips by emitting index I and index I + P, P * N times. You then render N triangle strips given the vertex buffer and index buffer.

If you want to be clever, you can just store an index buffer with a single strips indices in, and add P to the base vertex index each time you render. Be careful with highly tessellated meshes with lots of indices. Some cards have a max vertex index which is 65535, others have one only slightly larger.

I hope that made sense!

无悔心 2024-12-18 15:54:32

不太确定你想要实现的最终图像,但据我了解,你有一条“线”(这是一条直线吗?弯曲的“线”? - 不清楚这一点) - 并且你想围绕它们旋转某个轴,以便创建某种二维“网格”,例如圆盘或圆锥体或其他东西?

你可以简单地尝试 glRotatef(a,x,y,z) 其中:

“a”是你想要旋转的角度
是您旋转的矢量。

因此,如果您想围绕 y 轴绘制图形 10 次,那么它可能如下所示:

for(int i = 0; i<10; i++)
{
    float da = 2.0*3.14/10.0
    plotLine(); // function for plotting the line once in 3 space
    glRotatef(da, 0, 1, 0);
}

这将绘制线条,将整个图形旋转少量,然后再次绘制(这将重复 10 次,以便原始线绕轴绘制 10 次 - 创建我相信您想要实现的“网格”

not quite sure the final image you want to achieve, but from what i understand, you have a "line" (is this a straight line? a curved "line"? - not clear about this) - and you want to revolve them around some axis so that it creates some sort of 2 dimensional "mesh" like a disc or cone or something?

you could simply try glRotatef(a,x,y,z) where:

"a" is the angle you want to rotate and
is the vector around which you are rotating.

thus, if you want to plot the figure 10 times around the y axis then it might look like this:

for(int i = 0; i<10; i++)
{
    float da = 2.0*3.14/10.0
    plotLine(); // function for plotting the line once in 3 space
    glRotatef(da, 0, 1, 0);
}

this will plot the line, rotate the entire figure by a small amount, then plot it again (this will repeat 10 times so that the original line is plotted 10 times around an axis - creating the "mesh" that i believe you are trying to achieve

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