本文整理汇总了C++中Curve::add_segment方法的典型用法代码示例。如果您正苦于以下问题:C++ Curve::add_segment方法的具体用法?C++ Curve::add_segment怎么用?C++ Curve::add_segment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Curve
的用法示例。
在下文中一共展示了Curve::add_segment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render_functions
void render_functions()
{
CurveEndPoint cep[3];
cep[0].p = Float2(0.0f, 0.0f);
float r1 = (1.0f + sin(function_theta * 1.0f));
cep[0].t = Float2(cep[0].p[0] + r1 * cos(function_theta * 1.5f), cep[0].p[1] + r1 * sin(function_theta * 1.5f));
cep[1].p = Float2(0.5f, 1.0f);
float r2 = (1.0f + sin(function_theta * 1.0f));
cep[1].t = Float2(cep[1].p[0] + r2 * cos(function_theta), cep[1].p[1] + r2 * sin(function_theta));
cep[2].p = Float2(1.0f, 0.0f);
cep[2].t = Float2(0.9f, 0.0f);
CurveSegmentBezier csc;
CurveSegmentLerp csl;
csc.set_endpoints(cep[0], cep[1]);
csl.set_endpoints(cep[1], cep[2]);
Curve c;
c.add_segment(&csc);
c.add_segment(&csl);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPointSize(3.0f);
glScalef(1.2f, 1.2f, 0.0f);
glTranslatef(-0.5f, -0.5f, 0.0f);
glColor3f(0.0f, 0.0f, 1.0f);
glBegin(GL_POINTS);
glVertex3f(cep[0].p[0], cep[0].p[1], 0.0f);
glVertex3f(cep[1].p[0], cep[1].p[1], 0.0f);
glVertex3f(cep[2].p[0], cep[2].p[1], 0.0f);
glEnd();
glColor3f(1.0f, 0.0f, 0.0f);
glBegin(GL_POINTS);
glVertex3f(cep[0].t[0], cep[0].t[1], 0.0f);
glVertex3f(cep[1].t[0], cep[1].t[1], 0.0f);
glVertex3f(cep[2].t[0], cep[2].t[1], 0.0f);
glEnd();
glBegin(GL_LINES);
glVertex3f(cep[0].p[0], cep[0].p[1], 0.0f);
glVertex3f(cep[0].t[0], cep[0].t[1], 0.0f);
glVertex3f(cep[1].p[0], cep[1].p[1], 0.0f);
glVertex3f(cep[1].t[0], cep[1].t[1], 0.0f);
glVertex3f(cep[2].p[0], cep[2].p[1], 0.0f);
glVertex3f(cep[2].t[0], cep[2].t[1], 0.0f);
glEnd();
glColor3f(1.0f, 1.0f, 1.0f);
int num_slices = 100;
glBegin(GL_LINE_STRIP);
for(int i = 0; i < num_slices + 1; i++)
{
float x = (float)i / (float)num_slices;
float y = c.evaluate(x);
glVertex3f(x, y, 0.0f);
}
glEnd();
//draw bounding box
glBegin(GL_LINE_STRIP);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(1.0f, 0.0f, 0.0f);
glVertex3f(1.0f, 1.0f, 0.0f);
glVertex3f(0.0f, 1.0f, 0.0f);
glVertex3f(0.0f, 0.0f, 0.0f);
glEnd();
}