void DrawCurve(HDC context, POINT *points, int npoints, float tension, int color) { // First segment DrawCurveSegment(points[0].x, points[0].y, points[0].x, points[0].y, points[1].x, points[1].y, points[2].x, points[2].y, tension, color, context); // Middle segments int i; for (i = 1; i < npoints - 2; i += 1) { DrawCurveSegment(points[i - 1].x, points[i - 1].y, points[i].x, points[i].y, points[i + 1].x, points[i + 1].y, points[i + 2].x, points[i + 2].y, tension, color, context); } // Last segment //DrawCurveSegment(points[i - 1].x, points[i - 1].y, points[i].x, points[i].y, points[i + 1].x, points[i + 1].y, points[i + 2].x, points[i + 2].y, tension, color, context); }
/* Draw the spline in the viewport by iterating over the respective nodes */ void ASplineComponent::DrawCurve() { ASplineNode* start = *(this->splineNodes.GetTypedData()); for (TArray<class ASplineNode*>::TIterator iter = this->splineNodes.CreateIterator(); iter; iter++) { if (start == *iter) { // Draw a connection between first and last node if ConnectEndPoints is true, else skip to next iteration if(!this->ConnectEndPoints) continue; ASplineNode* end = this->splineNodes.Last(); DrawCurveSegment(start->GetActorLocation(), start->front, end->back, end->GetActorLocation()); } else { ASplineNode* end = *iter; DrawCurveSegment(start->GetActorLocation(), start->front, end->back, end->GetActorLocation()); start = end; } } }