本文整理汇总了C++中BezierCurve::GetControlPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ BezierCurve::GetControlPoint方法的具体用法?C++ BezierCurve::GetControlPoint怎么用?C++ BezierCurve::GetControlPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BezierCurve
的用法示例。
在下文中一共展示了BezierCurve::GetControlPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildCurves
static void BuildCurves(float3* points, int count, bool isClosed,
std::vector<BezierCurve>* out)
{
assert(count > 1);
float3 cp[4];
if(count == 2)
{
cp[0] = points[0];
cp[3] = points[1];
cp[1] = cp[0] + 0.3333f * (cp[3] - cp[0]);
cp[2] = cp[0] + 0.6666f * (cp[3] - cp[0]);
out->push_back(BezierCurve(cp));
}
else
{
float3 zerov(0.0f,0.0f,0.0f);
std::vector<float3> tangents(count,zerov);
CalcPointTangents(points,&tangents[0],count,isClosed);
for (int i = 1; i < count; i++)
{
float3 chord = points[i] - points[i - 1];
float segLen = length(chord) * 0.3333f;
cp[0] = points[i - 1];
cp[3] = points[i];
float3 tangent1 = tangents[i - 1];
if (dot(chord, tangent1) < 0)
tangent1 = -tangent1;
cp[1] = cp[0] + (tangent1 * segLen);
float3 tangent2 = tangents[i];
if (dot(-chord, tangent2) < 0)
tangent2 = -tangent2;
cp[2] = cp[3] + (tangent2 * segLen);
BezierCurve curve(cp);
out->push_back(curve);
}
// Calculate last curve if is closed
if (isClosed)
{
float3 lastcp1 = cp[1];
float3 lastcp2 = cp[2];
cp[0] = points[count - 1];
cp[3] = points[0];
BezierCurve lastCurve = out->back();
float tanLen = length(cp[3] - cp[0]) * 0.3333f;
float3 v = normalize(lastCurve.GetControlPoint(2) - cp[0]);
cp[1] = cp[0] - (v * tanLen);
BezierCurve firstCurve = out->front();
v = normalize(firstCurve.GetControlPoint(1) - cp[3]);
cp[2] = cp[3] - (v * tanLen);
BezierCurve curve(cp);
out->push_back(curve);
}
}
}