简体   繁体   English

OpenGL:如何绘制比8高的Bezier曲线?

[英]OpenGL: How to draw Bezier curve of degree higher then 8?

I am trying to draw high order Bezier Curve using OpenGL evaluators: 我正在尝试使用OpenGL评估器绘制高阶Bezier曲线:

glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 30, &points[0][0]);

glMapGrid1f(30, 0, 1);
glEvalMesh1(GL_LINE, 0, 30);

or 要么

glBegin(GL_LINE_STRIP);
for (int i = 0; i <= 30; i++) 
  glEvalCoord1f((GLfloat) i/30.0);
glEnd();

When number of points exceeds 8, curve disappears. 当点数超过8时,曲线消失。 How to draw higher order Bezier curve using evaluators? 如何使用评估器绘制高阶贝塞尔曲线?

See the paper: 见论文:

Watkins and Worsey, Degree reduction of Bézier curves. 沃特金斯和沃西, 贝塞尔曲线的度降低。 Computer-Aided Design. 计算机辅助设计。 20(7), Sept. 1988, 398-405. 1988年9月,20(7),398-405。

What they do is convert the Bézier curve into Chebyshev polynomial form, so the last term of the polynomial has the least effect on the shape, drop the last term, and convert it back to Bézier form. 他们所做的是将Bézier曲线转换为Chebyshev多项式形式,因此多项式的最后一项对形状的影响最小,删除最后一项,然后将其转换回Bézier形式。 If this produces too much error, the Bézier is subdivided and the process is run again. 如果这产生太多错误,则将贝塞尔(Bézier)细分,然后再次运行该过程。

This makes it very easy to convert the high order curve down to a cubic Bézier the system can natively render efficiently. 这使得将高阶曲线向下转换为三次贝塞尔曲线非常容易,系统可以自然地有效渲染。 I've used this method for a couple different situations, and it works well. 我已经在几种不同的情况下使用了此方法,并且效果很好。 One caveat though; 需要注意的是 the matrix equations in the paper have some typos. 本文中的矩阵方程式有一些错别字。 See: 看到:

Peterson, J., Letter to the Editor , CAD, 23(6), August 1991, p.460 Peterson,J., 致编辑的信 CAD,23(6),1991年8月,第460页

for the corrected equations. 对于校正后的方程式。 Unfortunately CAD is an old-school academic journal, and so the papers aren't conveniently on-line. 不幸的是, CAD是一本老派的学术期刊,因此论文不方便在线。 You'll need to dig them out of a library someplace, or pay the fine to get them from Elsevier. 您需要从某个地方将它们从图书馆中挖掘出来,或者支付罚款才能从Elsevier获得它们。

By any chance are you get a GL_MAX_EVAL_ORDER error? 您有机会遇到GL_MAX_EVAL_ORDER错误吗? Bezier curves become unstable at high degrees. 贝塞尔曲线在高度上变得不稳定。 I wouldn't be surprised if your OpenGL implementation just gave up. 如果您的OpenGL实现只是放弃,我不会感到惊讶。

You can use glGet with GL_MAX_EVAL_ORDER to see what your implementation maxes at. 您可以将glGet与GL_MAX_EVAL_ORDER结合使用,以查看实现的最大化。 If you need something higher, you can always roll your own, which isn't too bad. 如果您需要更高的东西,可以随时自己动手,这还不错。

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

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