我有这个算法,我发现这里只有一两件事让我为难一下:帮助理解这一点?
Clear the stencil buffer to 1.
Pick an arbitrary vertex v0, probably somewhere near the polygon to reduce floating-point errors.
For each vertex v[i] of the polygon in clockwise order:
let s be the segment v[i]->v[i+1] (where i+1 will wrap to 0 when the last vertex is reached)
if v0 is to the "right" of s:
draw a triangle defined by s, v[i], v[i+1] that adds 1 to the stencil buffer
else
draw a triangle defined by s, v[i], v[i+1] that subtracts 1 from the stencil buffer
end for
fill the screen with the desired color/texture, testing for stencil buffer values >= 2.
By "right of s" I mean from the perspective of someone standing on v[i] and facing v[i+1]. This can be tested by using a cross product:
cross(v0 - v[i], v[i+1] - v[i]) > 0
是困惑我的是,我需要绘制由S,V [I],V [定义的三角形的部分我+ 1]。如果S是段v [i] - > v [i + 1]那么这是如何实现的?
感谢
是的,它看起来像一个错误,因为* s *是由v [i]和[i + 1]定义的段。我的镜头是应该有* v0 *而不是* s *。如果你已经提供了关于这个算法应该做什么的更多信息,它也会有很大的帮助。它有影子卷吗? – Rekin 2010-08-21 15:16:35
不,我正在尝试使用模具而不是GLUTESS绘制凹面多边形 – jmasterx 2010-08-21 15:18:20